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

Function TEST

imperative/src/test/opr_utility.cpp:11–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace opr;
10
11TEST(TestOprUtility, InputCallback) {
12 HostTensorGenerator<> gen;
13 DeviceTensorND dv;
14 auto hv = gen({2, 3});
15 dv.copy_from(*hv).sync();
16 auto graph = ComputingGraph::make();
17 auto callback = [dv]() { return dv; };
18 auto outputs = opr::InputCallback::make(
19 *graph, callback, dv.comp_node(), dv.dtype(), {2, 3});
20
21 HostTensorND hout;
22 ComputingGraph::OutputSpec outspec{make_callback_copy(outputs[0], hout)};
23 auto func = graph->compile(outspec);
24 func->execute();
25 MGB_ASSERT_TENSOR_EQ(hout, *hv);
26}
27
28TEST(TestOprUtility, OutputCallback) {
29 HostTensorGenerator<> gen;

Callers

nothing calls this directly

Calls 15

make_callback_copyFunction · 0.85
OperatorNodeConfigClass · 0.85
storageMethod · 0.80
comp_node_validMethod · 0.80
genFunction · 0.50
makeFunction · 0.50
loadFunction · 0.50
syncMethod · 0.45
copy_fromMethod · 0.45
comp_nodeMethod · 0.45
dtypeMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected