| 64 | class MemoryIncreaseMobileNetV1Test : public MNNTestCase { |
| 65 | public: |
| 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 | }; |
| 99 | MNNTestSuiteRegister(MemoryIncreaseMobileNetV1Test, "expr/MemoryIncrease/mobilenetv1"); |
| 100 |
nothing calls this directly
no test coverage detected