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

Function TEST

test/src/autocheck.cpp:402–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400} // namespace mgb
401
402TEST(TestAutoCheck, APlusB) {
403 using Checker = AutoOprChecker<2, 1>;
404 auto make_graph = [](const Checker::SymInpArray& inputs) -> Checker::SymOutArray {
405 return {inputs[0] + inputs[1] * inputs[1]};
406 };
407 auto fwd = [](Checker::NumOutArray& dest, Checker::NumInpArray inp) {
408 DeviceTensorND i0, i1, tmp, out;
409 i0.copy_from(*inp[0]);
410 i1.copy_from(*inp[1]);
411 auto opr = opr::intl::create_megdnn_opr<megdnn::Elemwise>(dest[0].comp_node());
412 using Mode = opr::Elemwise::Mode;
413 opr::Elemwise::perform(Mode::MUL, tmp, {i1, i1}, opr);
414 opr::Elemwise::perform(Mode::ADD, out, {tmp, i0}, opr);
415 dest[0].copy_from(out).sync();
416 };
417 Checker(make_graph, fwd)
418 .run({TensorShape{2, 3}, TensorShape{2, 3}})
419 .run({TensorShape{5, 2, 3}, TensorShape{5, 1, 1}})
420 .run({TensorShape{2, 3, 4, 5}, TensorShape{1}});
421}
422
423#undef DEF_IMPL
424#undef DEF_IMPL_CHAIN

Callers

nothing calls this directly

Calls 5

CheckerClass · 0.50
copy_fromMethod · 0.45
comp_nodeMethod · 0.45
syncMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected