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

Method SetUp

src/opr/test/dnn/convolution.cpp:2529–2550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2527 MockConvolutionForward& mock_conv() { return *mock_conv_ptr; }
2528
2529 void SetUp() override {
2530 constexpr uint32_t ih = 10, ic = 16, oc = 32, ph = 0, sh = 1, fh = 2, iw = ih;
2531 comp_node = CompNode::load("cpux");
2532 graph = ComputingGraph::make();
2533 graph->options().graph_opt.weight_preprocess = is_weight_preprocess();
2534 TensorShape x_shape{1, ic, ih, iw}, w_shape{oc, ic, fh, fh};
2535 x_host = std::make_shared<HostTensorND>(comp_node, x_shape);
2536 auto x = opr::Host2DeviceCopy::make(*graph, x_host);
2537 auto w = opr::ImmutableTensor::make(*graph, {comp_node, w_shape});
2538 Param param;
2539 param.pad_h = param.pad_w = ph;
2540 param.stride_h = param.stride_w = sh;
2541 param.format = Param::Format::NCHW;
2542 y = opr::ConvolutionForward::make(x, w, param);
2543 auto& opr = y.node()->owner_opr()->cast_final<opr::ConvolutionForward>();
2544 auto mock = std::make_unique<MockConvolutionForward>(
2545 opr.megdnn_opr(),
2546 ::testing::UnitTest::GetInstance()->current_test_info()->name());
2547 mock_conv_ptr = mock.get();
2548 ConvolutionTestingPeer{&opr}.set_megdnn_opr(std::move(mock));
2549 func = graph->compile({make_callback_copy(y, y_host)});
2550 }
2551
2552 void run() { func->execute().wait(); }
2553

Callers

nothing calls this directly

Calls 10

make_callback_copyFunction · 0.85
loadFunction · 0.50
makeFunction · 0.50
owner_oprMethod · 0.45
nodeMethod · 0.45
megdnn_oprMethod · 0.45
nameMethod · 0.45
getMethod · 0.45
set_megdnn_oprMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected