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,
auto& second = (arg0_shape.empty() ? args[1] : args[0]);
writer << "{ // " << n->get_name() << "\n";
writer.indent++;
// clang-format off
writer << "cublasSdot("
<< "cublas_handle,"
<< second.get_size() << ","
<< first.get_name() << ","
<< "1,"
<< second.get_name() << ","
<< "1,"
<< out[0].get_name() << ");\n";
// clang-format on
<< "cublas_handle," << second.get_size() << "," << first.get_name() << ","
<< "1," << second.get_name() << ","
<< "1," << out[0].get_name() << ");\n";
writer.indent--;
writer << "}\n";
}
......@@ -172,16 +166,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
{
writer << "{ // " << n->get_name() << "\n";
writer.indent++;
// clang-format off
writer << "cublasSdot("
<< "cublas_handle,"
<< arg0_shape[0] << ","
<< args[0].get_name() << ","
<< "1,"
<< args[1].get_name() << ","
<< "1,"
<< out[0].get_name() << ");\n";
// clang-format on
<< "cublas_handle," << arg0_shape[0] << "," << args[0].get_name() << ","
<< "1," << args[1].get_name() << ","
<< "1," << out[0].get_name() << ");\n";
writer.indent--;
writer << "}\n";
}
......@@ -193,22 +181,15 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer << "static const float beta = 1.0;\n";
writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";
;
// clang-format off
writer << "cublasSgemv("
<< "cublas_handle,"
<< "CUBLAS_OP_T,"
<< arg0_shape[0] << ","
<< arg0_shape[1] << ","
<< "CUBLAS_OP_T," << arg0_shape[0] << "," << arg0_shape[1] << ","
<< "&alpha," // Alpha
<< args[0].get_name() << ","
<< arg0_shape[1] << ","
<< args[1].get_name() << ","
<< args[0].get_name() << "," << arg0_shape[1] << "," << args[1].get_name() << ","
<< "1,"
<< "&beta," // beta
<< out[0].get_name() << ","
<< "1);\n";
// clang-format on
;
writer.indent--;
writer << "}\n";
}
......@@ -226,7 +207,6 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer << "int n = " << arg1_shape[1] << ";\n";
writer << "int k = " << arg0_shape[0] << ";\n";
writer << "cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);\n";
// clang-format off
writer << "cublasSgemm("
<< "cublas_handle,"
<< "CUBLAS_OP_N,"
......@@ -236,13 +216,11 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
<< "k,"
<< "&alpha," // Alpha
<< args[1].get_name() << ","
<< "n,"
<< args[0].get_name() << ","
<< "n," << args[0].get_name() << ","
<< "k,"
<< "&beta," // beta
<< out[0].get_name() << ","
<< "n);\n";
// clang-format on
writer.indent--;
writer << "}\n";
}
......@@ -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.
else if (arg_rank == 2)
{
// clang-format off
// TODO Assert arg0_shape[0] == arg1_shape[0]?
writer << "{ // " << n->get_name() << "\n";
writer.indent++;
writer << "static const float alpha = 1.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("
<< "cublas_handle,"
<< "CUBLAS_OP_T,"
<< "CUBLAS_OP_T,"
<< arg_shape[0] << ","
<< arg_shape[1] << ","
<< "CUBLAS_OP_T," << arg_shape[0] << "," << arg_shape[1] << ","
<< "&alpha," // Alpha
<< args[0].get_name() << ","
<< arg_shape[1] << ","
<< args[0].get_name() << "," << arg_shape[1] << ","
<< "&beta," // beta
<< args[0].get_name() << ","
<< arg_shape[1] << ","
<< out[0].get_name() << ","
<< args[0].get_name() << "," << arg_shape[1] << "," << out[0].get_name() << ","
<< out[0].get_shape()[1] << ");\n";
writer.indent--;
writer << "}\n";
//clang-format on
}
// Other cases (reordering of axes for tensors with rank>2) are not handled yet.
else
......@@ -630,17 +602,13 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer << "cudnnOpTensor(cudnn_handle,"
<< "opTensorDesc,"
<< "&alpha1,"
<< "descriptor,"
<< args[0].get_name() << ","
<< "descriptor," << args[0].get_name() << ","
<< "&alpha2,"
<< "descriptor,"
<< args[1].get_name() << ","
<< "descriptor," << args[1].get_name() << ","
<< "&beta,"
<< "descriptor,"
<< out[0].get_name() << ");\n";
<< "descriptor," << out[0].get_name() << ");\n";
writer.indent--;
writer << "}\n";
}
void runtime::gpu::GPU_Emitter::EmitExp(codegen::CodeWriter& writer,
......@@ -796,14 +764,11 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer << "cudnnOpTensor(cudnn_handle,"
<< "opTensorDesc,"
<< "&alpha1,"
<< "descriptor,"
<< args[0].get_name() << ","
<< "descriptor," << args[0].get_name() << ","
<< "&alpha2,"
<< "descriptor,"
<< args[0].get_name() << ","
<< "descriptor," << args[0].get_name() << ","
<< "&beta,"
<< "descriptor,"
<< out[0].get_name() << ");\n";
<< "descriptor," << out[0].get_name() << ");\n";
writer.indent--;
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