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

Method GetCVKernelBody

compiler/lib/KernelGen/GeneralIntrinsic/CVTranspose.cpp:43–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 common_tran.GetDependInternalSymbol(ctx)}};
42}
43std::string CvTransposeKernel::GetCVKernelBody(TContext* context) const {
44 GeneralIntrinsic::CommonTransposeKernel common_tran;
45 std::shared_ptr<TContext> tran_ctx = std::make_shared<CodeGenContext>();
46 auto kernel_sig = GetCVKernelSignature(context);
47 auto dtype_str = context->getAttrOprand("operand:0").dtype;
48 int32_t type_size = Utils::get_dtype_size(dtype_str);
49 tran_ctx->setAttr("type_size", CCAttr(type_size));
50 std::string body_temp = R"(
51 #include <string.h>
52 #include "gi_int.h"
53 #include "tinycv_c.h"
54
55 ${gi_fast_transpose_impl}
56
57 void ${kernel_sig}{
58 uint8_t * src_base_ptr = src->data;
59 uint8_t * dst_base_ptr = dst->data;
60 int src_cols = src->cols;
61 int src_rows = src->rows;
62 int src_chans = src->channels;
63 fast_transpose_impl_8(src_base_ptr, dst_base_ptr, src_cols, src_rows, src_chans, src_cols * src_chans, src_rows * src_chans);
64 }
65 )";
66 return StringTemplate::StringTemplateArgs()
67 .add("kernel_sig", kernel_sig)
68 .add("gi_fast_transpose_impl",
69 common_tran.GetKernelSignature(tran_ctx.get()))
70 .render(body_temp);
71}
72
73// vim: syntax=cpp.doxygen

Callers

nothing calls this directly

Calls 9

get_dtype_sizeFunction · 0.85
CCAttrClass · 0.85
StringTemplateArgsClass · 0.85
getAttrOprandMethod · 0.80
setAttrMethod · 0.80
renderMethod · 0.45
addMethod · 0.45
GetKernelSignatureMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected