| 22 | using namespace serialization; |
| 23 | |
| 24 | TEST(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 | |
| 54 | TEST(TestOprAtlas, DynamicBatch) { |
| 55 | for (size_t batch : {1, 6, 20}) { |
nothing calls this directly
no test coverage detected