MCPcopy Create free account
hub / github.com/MegEngine/MegCC / GetKernelBody

Method GetKernelBody

compiler/lib/KernelGen/BareMetal/Fp32Gevm.cpp:66–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66std::string Fp32GevmKernel::GetKernelBody(TContext* context) const {
67 std::stringstream writer;
68 writer << "#include <string.h>\n";
69 bool trans_b = context->getAttrBool("transposeB");
70
71 writer << GenCommonRet() << " ";
72 writer << GetKernelSignature(context) << "{\n";
73 // clang-format off
74 writer << R"(
75 float* A = (float*)inputs[0]->ptr;
76 float* B = (float*)inputs[1]->ptr;
77 float* C = (float*)outputs[0]->ptr;
78 TINYNN_ASSERT(A);
79 TINYNN_ASSERT(B);
80 TINYNN_ASSERT(C);
81 const Tensor* a_tensor = inputs[0];
82 const Tensor* b_tensor = inputs[1];
83 const Tensor* c_tensor = outputs[0];
84 const Layout a_layout = a_tensor->layout;
85 const Layout b_layout = b_tensor->layout;
86 const Layout c_layout = c_tensor->layout;
87 const int Astride = a_layout.stride[0];
88 const int Bstride = b_layout.stride[0];
89 const int Cstride = c_layout.stride[0];
90 const int M = c_layout.dims[0];
91 const int K = a_layout.dims[1];
92 const int N = c_layout.dims[1];
93 )";
94 if(trans_b)
95 writer << vec_mul_matrix_n_t();
96 else
97 writer << vec_mul_matrix_n_n();
98 writer << R"(
99 return TinyNN_SUCCESS;
100 })";
101 // clang-format on
102 return writer.str();
103}
104
105} // namespace BareMetal
106} // namespace KernelGen

Callers

nothing calls this directly

Calls 4

GenCommonRetFunction · 0.85
getAttrBoolMethod · 0.80
vec_mul_matrix_n_tFunction · 0.70
vec_mul_matrix_n_nFunction · 0.70

Tested by

no test coverage detected