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

Method run

test/expr/MemoryIncrease.cpp:66–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64class MemoryIncreaseMobileNetV1Test : public MNNTestCase {
65public:
66 virtual bool run(int precision) {
67 auto y = _mobileNetV1Expr();
68 std::unique_ptr<MNN::NetT> net(new NetT);
69 Variable::save({y}, net.get());
70 flatbuffers::FlatBufferBuilder builderOutput(1024);
71 auto len = MNN::Net::Pack(builderOutput, net.get());
72 builderOutput.Finish(len);
73 int sizeOutput = builderOutput.GetSize();
74 auto bufferOutput = builderOutput.GetBufferPointer();
75 std::shared_ptr<Interpreter> interp(Interpreter::createFromBuffer(bufferOutput, sizeOutput));
76 ScheduleConfig config;
77 config.type = MNN_FORWARD_CPU;
78 auto session = interp->createSession(config);
79 auto input = interp->getSessionInput(session, nullptr);
80 float initMemory = 0.0f;
81 interp->getSessionInfo(session, MNN::Interpreter::MEMORY, &initMemory);
82 for (int i = 0; i < 100; ++i) {
83 if (i % 2 == 0) {
84 interp->resizeTensor(input, {1, 3, 112, 112});
85 } else {
86 interp->resizeTensor(input, {1, 3, 224, 224});
87 }
88 interp->resizeSession(session);
89 }
90 float lastMemory = 0.0f;
91 interp->getSessionInfo(session, MNN::Interpreter::MEMORY, &lastMemory);
92 MNN_PRINT("From init %f mb to %f mb\n", initMemory, lastMemory);
93 if (lastMemory > initMemory) {
94 return false;
95 }
96 return true;
97 }
98};
99MNNTestSuiteRegister(MemoryIncreaseMobileNetV1Test, "expr/MemoryIncrease/mobilenetv1");
100

Callers

nothing calls this directly

Calls 10

getSessionInputMethod · 0.80
getSessionInfoMethod · 0.80
resizeTensorMethod · 0.80
resizeSessionMethod · 0.80
_mobileNetV1ExprFunction · 0.70
saveFunction · 0.50
getMethod · 0.45
FinishMethod · 0.45
GetSizeMethod · 0.45
createSessionMethod · 0.45

Tested by

no test coverage detected