| 9 | using namespace mgb; |
| 10 | |
| 11 | TEST(TestOprMegDNNWrapper, Stream) { |
| 12 | using Param = opr::Convolution::Param; |
| 13 | Param param; |
| 14 | HostTensorGenerator<> gen; |
| 15 | auto host_x = gen({8, 1, 20, 20}), host_kern = gen({3, 1, 4, 4}); |
| 16 | HostTensorND host_y_expect; |
| 17 | { |
| 18 | // gen host_y_expect |
| 19 | auto graph = ComputingGraph::make(); |
| 20 | auto x = opr::Host2DeviceCopy::make(*graph, host_x), |
| 21 | kern = opr::Host2DeviceCopy::make(*graph, host_kern), |
| 22 | y = opr::Convolution::make(x, kern, param); |
| 23 | auto func = graph->compile({make_callback_copy(y, host_y_expect)}); |
| 24 | func->execute(); |
| 25 | } |
| 26 | auto graph = ComputingGraph::make(); |
| 27 | auto x = opr::Host2DeviceCopy::make(*graph, host_x), |
| 28 | kern = opr::Host2DeviceCopy::make(*graph, host_kern), |
| 29 | y = opr::Convolution::make(x, kern, param); |
| 30 | // change stream |
| 31 | auto chg = [](SymbolVar var) { |
| 32 | auto opr = var.node()->owner_opr(); |
| 33 | for (auto i : opr->output()) |
| 34 | i->comp_node(CompNode::load("xpu0:1")); |
| 35 | opr->on_output_comp_node_stream_changed(); |
| 36 | }; |
| 37 | chg(x); |
| 38 | chg(kern); |
| 39 | chg(y); |
| 40 | HostTensorND host_y; |
| 41 | |
| 42 | opr::Sleep::sleep(host_x->comp_node(), 0.5); |
| 43 | auto func = graph->compile({make_callback_copy(y, host_y)}); |
| 44 | func->execute(); |
| 45 | MGB_ASSERT_TENSOR_EQ(host_y_expect, host_y); |
| 46 | } |
| 47 | |
| 48 | TEST(TestOprMegDNNWrapper, ShapeDep) { |
| 49 | using Param = opr::Convolution::Param; |
nothing calls this directly
no test coverage detected