| 24 | using namespace mlir; |
| 25 | |
| 26 | KernelGen::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 | |
| 48 | KernelGen::KernelObj codegen::AutoKernelFuncInternal::CompileKernel( |
| 49 | mlir::ModuleOp mod, std::string func_name) const { |
no test coverage detected