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

Function TEST

src/opr/test/megdnn_wrapper.cpp:11–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace mgb;
10
11TEST(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
48TEST(TestOprMegDNNWrapper, ShapeDep) {
49 using Param = opr::Convolution::Param;

Callers

nothing calls this directly

Calls 15

make_callback_copyFunction · 0.85
gradFunction · 0.85
makeFunction · 0.70
genFunction · 0.50
loadFunction · 0.50
reduce_sumFunction · 0.50
compileMethod · 0.45
executeMethod · 0.45
owner_oprMethod · 0.45
nodeMethod · 0.45
outputMethod · 0.45
comp_nodeMethod · 0.45

Tested by

no test coverage detected