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

Function run_dimshuffle

src/jit/test/codegen.cpp:515–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513/* ===================== TestJITMlirDimshuffle ===================== */
514
515void run_dimshuffle(CompNode cn, TensorShape ishape, const std::vector<int>& pattern) {
516 set_backend(Backend::MLIR);
517 auto graph = ComputingGraph::make();
518 HostTensorGenerator<> gen;
519
520 auto host_x = gen(ishape, cn);
521 auto x = opr::Host2DeviceCopy::make(*graph, host_x);
522 auto y = opr::Dimshuffle::make(x, pattern);
523
524 auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr());
525
526 for (auto i : get_rev_topo_order(y)) {
527 if (!i->template same_type<opr::Host2DeviceCopy>()) {
528 ig_gen->add_opr(i);
529 }
530 }
531
532 auto igraph = ig_gen->generate();
533 auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps());
534
535 HostTensorND host_y, host_y_jit;
536 auto func = graph->compile(
537 {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)});
538 func->execute();
539
540 MGB_ASSERT_TENSOR_EQ(host_y, host_y_jit);
541}
542
543void run_dimshuffle_cases(CompNode cn) {
544 run_dimshuffle(cn, {3, 4, 5}, {2, 0, 1});

Callers 1

run_dimshuffle_casesFunction · 0.85

Calls 9

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

Tested by

no test coverage detected