MCPcopy Create free account
hub / github.com/alibaba/MNN / run

Method run

test/expr/ModuleTest.cpp:1509–1612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1507class SequenceForwardResizeTest : public MNNTestCase {
1508public:
1509 virtual bool run(int precision) {
1510 auto executor = cloneCurrentExecutor();
1511 ExecutorScope scope(executor);
1512 // Make Model include convolution in shape compute and content compute
1513 auto x = _Input({1, 3, 24, 24}, NCHW, halide_type_of<float>());
1514 x->setName("x");
1515 auto y = _Square(x);
1516 auto z = _Erf(y);
1517 z = _Sqrt(z);
1518 z->setName("z");
1519 auto buffer = Variable::save({z});
1520 ScheduleConfig config;
1521 config.type = getCurrentType();
1522 std::shared_ptr<Executor::RuntimeManager> rtm0( Executor::RuntimeManager::createRuntimeManager(config));
1523 std::shared_ptr<Executor::RuntimeManager> rtm1( Executor::RuntimeManager::createRuntimeManager(config));
1524
1525 Module::Config mconfig;
1526 mconfig.rearrange = false;
1527 std::shared_ptr<MNN::Express::Module> m0(Module::load({"x"}, {"z"}, (const unsigned char*)buffer.data(), buffer.size(), rtm0, &mconfig), Module::destroy);
1528 std::shared_ptr<MNN::Express::Module> m1(Module::load({"x"}, {"z"}, (const unsigned char*)buffer.data(), buffer.size(), rtm1, &mconfig), Module::destroy);
1529 x = _Input({1, 3, 24, 24}, NCHW, halide_type_of<float>());
1530 auto xPtr = x->writeMap<float>();
1531 ::memset(xPtr, 0, x->getInfo()->size * sizeof(float));
1532 x->unMap();
1533 y = m0->onForward({x})[0];
1534 z = m1->onForward({y})[0];
1535 int status0 = 0;
1536 int status1 = 0;
1537 rtm0->getInfo(MNN::Interpreter::RESIZE_STATUS, &status0);
1538 rtm1->getInfo(MNN::Interpreter::RESIZE_STATUS, &status1);
1539 if (status0 != 2 || status1 != 2) {
1540 FUNC_PRINT(1);
1541 return false;
1542 }
1543 const_cast<Tensor*>(z->getTensor())->wait(MNN::Tensor::MAP_TENSOR_READ, true);
1544 y = m0->onForward({x})[0];
1545 z = m1->onForward({y})[0];
1546 rtm0->getInfo(MNN::Interpreter::RESIZE_STATUS, &status0);
1547 rtm1->getInfo(MNN::Interpreter::RESIZE_STATUS, &status1);
1548 if (status0 != 1 || status1 != 1) {
1549 FUNC_PRINT(1);
1550 return false;
1551 }
1552 y = nullptr;
1553 z = nullptr;
1554 y = m0->onForward({x})[0];
1555 z = m1->onForward({y})[0];
1556 rtm0->getInfo(MNN::Interpreter::RESIZE_STATUS, &status0);
1557 rtm1->getInfo(MNN::Interpreter::RESIZE_STATUS, &status1);
1558 if (status0 != 0 || status1 != 0) {
1559 FUNC_PRINT(1);
1560 return false;
1561 }
1562 x = _Input({1, 3, 12, 12}, NCHW, halide_type_of<float>());
1563 y = m0->onForward({x})[0];
1564 rtm0->getInfo(MNN::Interpreter::RESIZE_STATUS, &status0);
1565 if (2 != status0) {
1566 FUNC_PRINT(1);

Callers

nothing calls this directly

Calls 15

cloneCurrentExecutorFunction · 0.85
_InputFunction · 0.85
_ErfFunction · 0.85
_SqrtFunction · 0.85
getCurrentTypeFunction · 0.85
unMapMethod · 0.80
_SquareFunction · 0.50
saveFunction · 0.50
loadFunction · 0.50
cloneFunction · 0.50
setNameMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected