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

Function run_typecvt

src/jit/test/codegen.cpp:442–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440
441template <typename itype, typename otype>
442void run_typecvt(CompNode cn) {
443 set_backend(Backend::MLIR);
444 auto graph = ComputingGraph::make();
445 HostTensorGenerator<itype, RandomDistribution::UNIFORM> gen(-10, 10);
446
447 auto host_x = gen({23, 42}, cn);
448 auto x = opr::Host2DeviceCopy::make(*graph, host_x);
449 auto y = opr::TypeCvt::make(x, otype());
450
451 auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr());
452
453 for (auto i : get_rev_topo_order(y)) {
454 if (!i->template same_type<opr::Host2DeviceCopy>()) {
455 ig_gen->add_opr(i);
456 }
457 }
458
459 auto igraph = ig_gen->generate();
460 auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps());
461
462 HostTensorND host_y, host_y_jit;
463 auto func = graph->compile(
464 {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)});
465 func->execute();
466
467 MGB_ASSERT_TENSOR_EQ(host_y, host_y_jit);
468};
469
470#define add_typecvt_gtest(itype, otype) \
471 TEST(TestJITMlirTypeCvt, itype##_to_##otype) { \

Callers

nothing calls this directly

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