Commit 3bbeaa31 authored by fenglei.tian's avatar fenglei.tian

clang format

parent e34a6b2b
...@@ -154,16 +154,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer, ...@@ -154,16 +154,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
auto& second = (arg0_shape.empty() ? args[1] : args[0]); auto& second = (arg0_shape.empty() ? args[1] : args[0]);
writer << "{ // " << n->get_name() << "\n"; writer << "{ // " << n->get_name() << "\n";
writer.indent++; writer.indent++;
// clang-format off
writer << "cublasSdot(" writer << "cublasSdot("
<< "cublas_handle," << "cublas_handle," << second.get_size() << "," << first.get_name() << ","
<< second.get_size() << "," << "1," << second.get_name() << ","
<< first.get_name() << "," << "1," << out[0].get_name() << ");\n";
<< "1,"
<< second.get_name() << ","
<< "1,"
<< out[0].get_name() << ");\n";
// clang-format on
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
...@@ -172,16 +166,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer, ...@@ -172,16 +166,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
{ {
writer << "{ // " << n->get_name() << "\n"; writer << "{ // " << n->get_name() << "\n";
writer.indent++; writer.indent++;
// clang-format off
writer << "cublasSdot(" writer << "cublasSdot("
<< "cublas_handle," << "cublas_handle," << arg0_shape[0] << "," << args[0].get_name() << ","
<< arg0_shape[0] << "," << "1," << args[1].get_name() << ","
<< args[0].get_name() << "," << "1," << out[0].get_name() << ");\n";
<< "1,"
<< args[1].get_name() << ","
<< "1,"
<< out[0].get_name() << ");\n";
// clang-format on
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
...@@ -193,22 +181,15 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer, ...@@ -193,22 +181,15 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer << "static const float beta = 1.0;\n"; writer << "static const float beta = 1.0;\n";
writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n"; writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";
; ;
// clang-format off
writer << "cublasSgemv(" writer << "cublasSgemv("
<< "cublas_handle," << "cublas_handle,"
<< "CUBLAS_OP_T," << "CUBLAS_OP_T," << arg0_shape[0] << "," << arg0_shape[1] << ","
<< arg0_shape[0] << ","
<< arg0_shape[1] << ","
<< "&alpha," // Alpha << "&alpha," // Alpha
<< args[0].get_name() << "," << args[0].get_name() << "," << arg0_shape[1] << "," << args[1].get_name() << ","
<< arg0_shape[1] << ","
<< args[1].get_name() << ","
<< "1," << "1,"
<< "&beta," // beta << "&beta," // beta
<< out[0].get_name() << "," << out[0].get_name() << ","
<< "1);\n"; << "1);\n";
// clang-format on
;
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
...@@ -226,7 +207,6 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer, ...@@ -226,7 +207,6 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer << "int n = " << arg1_shape[1] << ";\n"; writer << "int n = " << arg1_shape[1] << ";\n";
writer << "int k = " << arg0_shape[0] << ";\n"; writer << "int k = " << arg0_shape[0] << ";\n";
writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n"; writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";
// clang-format off
writer << "cublasSgemm(" writer << "cublasSgemm("
<< "cublas_handle," << "cublas_handle,"
<< "CUBLAS_OP_N," << "CUBLAS_OP_N,"
...@@ -236,13 +216,11 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer, ...@@ -236,13 +216,11 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
<< "k," << "k,"
<< "&alpha," // Alpha << "&alpha," // Alpha
<< args[1].get_name() << "," << args[1].get_name() << ","
<< "n," << "n," << args[0].get_name() << ","
<< args[0].get_name() << ","
<< "k," << "k,"
<< "&beta," // beta << "&beta," // beta
<< out[0].get_name() << "," << out[0].get_name() << ","
<< "n);\n"; << "n);\n";
// clang-format on
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
...@@ -522,30 +500,24 @@ void runtime::gpu::GPU_Emitter::EmitReshape(codegen::CodeWriter& writer, ...@@ -522,30 +500,24 @@ void runtime::gpu::GPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
// If there *is* a layout change in the 2D case, we transpose the input. // If there *is* a layout change in the 2D case, we transpose the input.
else if (arg_rank == 2) else if (arg_rank == 2)
{ {
// clang-format off
// TODO Assert arg0_shape[0] == arg1_shape[0]? // TODO Assert arg0_shape[0] == arg1_shape[0]?
writer << "{ // " << n->get_name() << "\n"; writer << "{ // " << n->get_name() << "\n";
writer.indent++; writer.indent++;
writer << "static const float alpha = 1.0;\n"; writer << "static const float alpha = 1.0;\n";
writer << "static const float beta = 0.0;\n"; writer << "static const float beta = 0.0;\n";
writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";; writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";
;
writer << "cublasSgeam(" writer << "cublasSgeam("
<< "cublas_handle," << "cublas_handle,"
<< "CUBLAS_OP_T," << "CUBLAS_OP_T,"
<< "CUBLAS_OP_T," << "CUBLAS_OP_T," << arg_shape[0] << "," << arg_shape[1] << ","
<< arg_shape[0] << ","
<< arg_shape[1] << ","
<< "&alpha," // Alpha << "&alpha," // Alpha
<< args[0].get_name() << "," << args[0].get_name() << "," << arg_shape[1] << ","
<< arg_shape[1] << ","
<< "&beta," // beta << "&beta," // beta
<< args[0].get_name() << "," << args[0].get_name() << "," << arg_shape[1] << "," << out[0].get_name() << ","
<< arg_shape[1] << ","
<< out[0].get_name() << ","
<< out[0].get_shape()[1] << ");\n"; << out[0].get_shape()[1] << ");\n";
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
//clang-format on
} }
// Other cases (reordering of axes for tensors with rank>2) are not handled yet. // Other cases (reordering of axes for tensors with rank>2) are not handled yet.
else else
...@@ -630,17 +602,13 @@ cudnnSetOpTensorDescriptor(opTensorDesc, ...@@ -630,17 +602,13 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer << "cudnnOpTensor(cudnn_handle," writer << "cudnnOpTensor(cudnn_handle,"
<< "opTensorDesc," << "opTensorDesc,"
<< "&alpha1," << "&alpha1,"
<< "descriptor," << "descriptor," << args[0].get_name() << ","
<< args[0].get_name() << ","
<< "&alpha2," << "&alpha2,"
<< "descriptor," << "descriptor," << args[1].get_name() << ","
<< args[1].get_name() << ","
<< "&beta," << "&beta,"
<< "descriptor," << "descriptor," << out[0].get_name() << ");\n";
<< out[0].get_name() << ");\n";
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
void runtime::gpu::GPU_Emitter::EmitExp(codegen::CodeWriter& writer, void runtime::gpu::GPU_Emitter::EmitExp(codegen::CodeWriter& writer,
...@@ -796,14 +764,11 @@ cudnnSetOpTensorDescriptor(opTensorDesc, ...@@ -796,14 +764,11 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer << "cudnnOpTensor(cudnn_handle," writer << "cudnnOpTensor(cudnn_handle,"
<< "opTensorDesc," << "opTensorDesc,"
<< "&alpha1," << "&alpha1,"
<< "descriptor," << "descriptor," << args[0].get_name() << ","
<< args[0].get_name() << ","
<< "&alpha2," << "&alpha2,"
<< "descriptor," << "descriptor," << args[0].get_name() << ","
<< args[0].get_name() << ","
<< "&beta," << "&beta,"
<< "descriptor," << "descriptor," << out[0].get_name() << ");\n";
<< out[0].get_name() << ");\n";
writer.indent--; writer.indent--;
writer << "}\n"; writer << "}\n";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment