MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / run_mlir_mode

Function run_mlir_mode

src/jit/test/codegen.cpp:251–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249
250template <typename tag, int arity>
251void run_mlir_mode(CompNode cn) {
252 set_backend(Backend::MLIR);
253 auto graph = ComputingGraph::make();
254 auto opt = get_mode_opt(tag::mode);
255 HostTensorGenerator<dtype::Float32, RandomDistribution::UNIFORM> gen(
256 opt.low, opt.high);
257
258 SmallVector<std::shared_ptr<HostTensorND>> hosts;
259 VarNodeArray input_vars;
260 for (int i = 0; i < arity; i++) {
261 hosts.push_back(gen({2323, 4242}, cn));
262 input_vars.push_back(opr::Host2DeviceCopy::make(*graph, hosts[i]).node());
263 }
264
265 auto y = opr::Elemwise::make(input_vars, tag::mode);
266
267 auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr());
268
269 for (auto i : get_rev_topo_order(y)) {
270 if (!i->template same_type<opr::Host2DeviceCopy>()) {
271 ig_gen->add_opr(i);
272 }
273 }
274
275 auto igraph = ig_gen->generate();
276 auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps());
277
278 HostTensorND host_y, host_y_jit;
279 auto func = graph->compile(
280 {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)});
281 func->execute();
282
283 MGB_ASSERT_TENSOR_NEAR(host_y, host_y_jit, opt.maxerr);
284}
285#endif
286} // anonymous namespace
287

Callers

nothing calls this directly

Calls 11

get_mode_optFunction · 0.85
make_callback_copyFunction · 0.85
makeFunction · 0.50
genFunction · 0.50
push_backMethod · 0.45
nodeMethod · 0.45
owner_oprMethod · 0.45
add_oprMethod · 0.45
generateMethod · 0.45
compileMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected