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

Method run

test/expr/ModuleTest.cpp:495–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493class ModuleReleaseTest : public MNNTestCase {
494public:
495 virtual bool run(int precision) {
496 auto y = _mobileNetV1Expr();
497 std::unique_ptr<MNN::NetT> net(new NetT);
498 Variable::save({y}, net.get());
499 y = nullptr;
500 flatbuffers::FlatBufferBuilder builderOutput(1024);
501 auto len = MNN::Net::Pack(builderOutput, net.get());
502 builderOutput.Finish(len);
503 int sizeOutput = builderOutput.GetSize();
504 auto bufferOutput = builderOutput.GetBufferPointer();
505 // Force use CPU Runtime
506 BackendConfig bnConfig;
507 auto exe = Executor::newExecutor(MNN_FORWARD_CPU, bnConfig, 1);
508 ExecutorScope scope(exe);
509 auto rtInfo = exe->getRuntime();
510 float memory;
511 auto countMemory = [&rtInfo, &memory]() {
512 memory = 0.0f;
513 for (auto& iter : rtInfo.first) {
514 memory += iter.second->onGetMemoryInMB();
515 }
516 memory += rtInfo.second->onGetMemoryInMB();
517 };
518 countMemory();
519 FUNC_PRINT_ALL(memory, f);
520 Module::Config config;
521 config.shapeMutable = false;
522 config.rearrange = true;
523 std::shared_ptr<Module> interp0;
524 {
525 MNN::ScheduleConfig sconfig;
526 sconfig.numThread = 1;
527 std::vector<MNN::ScheduleConfig> sconfigs = {sconfig};
528 std::shared_ptr<Executor::RuntimeManager> rtMgr(Executor::RuntimeManager::createRuntimeManager(sconfigs));
529 interp0.reset(Module::load({"Input"}, {"Prob"}, bufferOutput, sizeOutput, rtMgr, &config), Module::destroy);
530 }
531 countMemory();
532 FUNC_PRINT_ALL(memory, f);
533 interp0.reset();
534 countMemory();
535 FUNC_PRINT_ALL(memory, f);
536 if (memory > 1.0f) {
537 return false;
538 }
539 return true;
540 };
541};
542MNNTestSuiteRegister(ModuleReleaseTest, "expr/ModuleReleaseTest");
543

Callers

nothing calls this directly

Calls 9

_mobileNetV1ExprFunction · 0.70
saveFunction · 0.50
loadFunction · 0.50
getMethod · 0.45
FinishMethod · 0.45
GetSizeMethod · 0.45
getRuntimeMethod · 0.45
onGetMemoryInMBMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected