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

Method GetKernelObj

compiler/lib/CodeGen/AutoKernelFunc.cpp:26–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24using namespace mlir;
25
26KernelGen::KernelObj codegen::AutoKernelFuncInternal::GetKernelObj(
27 TContext* context) const {
28 auto ctx = codegen::getGlobalCTX();
29 mlir::OwningOpRef<mlir::ModuleOp> mod =
30 mlir::ModuleOp::create(mlir::UnknownLoc::get(ctx));
31 mlir::OpBuilder op_builder(ctx);
32 op_builder.setInsertionPointToEnd(mod->getBody());
33 auto func_name = GetKernelSymbol(context);
34 auto func = op_builder.create<FuncOp>(
35 op_builder.getUnknownLoc(), func_name, get_func_type_memref(context, ctx));
36 Block* entryBlock = func.addEntryBlock();
37 op_builder.setInsertionPointToStart(entryBlock);
38 CreateCompute(entryBlock, op_builder, ctx, context);
39
40 mlir::PassManager pm(ctx);
41 CreatePass(pm, ctx, context);
42 if (failed(pm.run(mod.get()))) {
43 CC_ABORT << "pass error\n";
44 }
45 return CompileKernel(mod.get(), func_name);
46}
47
48KernelGen::KernelObj codegen::AutoKernelFuncInternal::CompileKernel(
49 mlir::ModuleOp mod, std::string func_name) const {

Callers 2

Calls 3

get_func_type_memrefFunction · 0.85
runMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected