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

Function TEST

src/opr/test/atlas_runtime_op.cpp:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22using namespace serialization;
23
24TEST(TestOprAtlas, Basic) {
25 HostTensorGenerator<> gen;
26 const auto& graph = ComputingGraph::make();
27 const auto& host_x = gen({4, 3, 16, 16});
28
29 //! run om model
30 const auto& om_buffer = ATLAS_MODEL.at("model_om");
31 auto cn = CompNode::load("atlas0");
32 auto x = Host2DeviceCopy::make(*graph, host_x, cn);
33 auto y = opr::AtlasRuntimeOpr::make(om_buffer.first, om_buffer.second, {x})[0];
34 HostTensorND host_om;
35 auto om_func = graph->compile({make_callback_copy(y, host_om, true)});
36 om_func->execute().wait();
37
38 //! run mdl model
39 const auto& mdl_buffer = ATLAS_MODEL.at("model_mdl");
40 auto loader = GraphLoader::make(
41 InputFile::make_mem_proxy(mdl_buffer.first, mdl_buffer.second));
42 auto rst = loader->load();
43 auto input = rst.tensor_map.at("d");
44 input->copy_from(*host_x).sync();
45 HostTensorND host_mdl;
46 auto mgb_func =
47 rst.graph_compile({make_callback_copy(rst.output_var_list[0], host_mdl)});
48 mgb_func->execute().wait();
49
50 //! In atlas, the inner compute is fp16
51 MGB_ASSERT_TENSOR_NEAR(host_mdl, host_om, 1e-3);
52}
53
54TEST(TestOprAtlas, DynamicBatch) {
55 for (size_t batch : {1, 6, 20}) {

Callers

nothing calls this directly

Calls 15

make_callback_copyFunction · 0.85
output_fileFunction · 0.85
graph_compileMethod · 0.80
to_json_fullMethod · 0.80
makeFunction · 0.70
genFunction · 0.50
loadFunction · 0.50
atMethod · 0.45
compileMethod · 0.45
waitMethod · 0.45
executeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected