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

Method GetCVKernelBody

compiler/lib/KernelGen/GeneralIntrinsic/CvtColor.cpp:470–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470std::string CvtColorKernel::GetCVKernelBody(TContext* context) const {
471 auto kernel_sig = GetCVKernelSignature(context);
472 auto mode = context->getAttrStr("mode");
473 auto gen_func = g_cvt_reg.get_func(mode);
474 auto code = gen_func(context);
475 std::stringstream writer;
476 writer << R"(
477 #include <limits.h>
478 #include <string.h>
479 #include "gi_int.h"
480 #include "tinycv_c.h"
481 )";
482
483 std::string body_temp = R"(
484 ${aux_func}
485 void ${kernel_sig}{
486 uint8_t * sptr = src->data;
487 uint8_t * dptr = dst->data;
488 size_t rows = src->rows;
489 size_t cols = src->cols;
490 size_t hw = rows * cols;
491 size_t ch = src->channels;
492
493 ${cvt_code}
494
495 }
496 )";
497
498 writer << StringTemplate::StringTemplateArgs()
499 .add("aux_func", code.aux_func)
500 .add("cvt_code", code.cvt_code)
501 .add("kernel_sig", kernel_sig)
502 .render(body_temp);
503 return writer.str();
504}
505
506// vim: syntax=cpp.doxygen

Callers

nothing calls this directly

Calls 5

StringTemplateArgsClass · 0.85
getAttrStrMethod · 0.80
get_funcMethod · 0.45
renderMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected