| 1229 | class WinogradMemoryTest : public MNNTestCase { |
| 1230 | public: |
| 1231 | float memoryUsed(int level) { |
| 1232 | auto x = _Input({1, 64, 224, 224}, MNN::Express::NC4HW4, halide_type_of<float>()); |
| 1233 | x->setName("Input"); |
| 1234 | auto y = _Conv(0.0f, 0.0f, x, {64, 112}, {3, 3}); |
| 1235 | y->setName("Prob"); |
| 1236 | std::unique_ptr<MNN::NetT> net(new NetT); |
| 1237 | Variable::save({y}, net.get()); |
| 1238 | y = nullptr; |
| 1239 | flatbuffers::FlatBufferBuilder builderOutput(1024); |
| 1240 | auto len = MNN::Net::Pack(builderOutput, net.get()); |
| 1241 | builderOutput.Finish(len); |
| 1242 | int sizeOutput = builderOutput.GetSize(); |
| 1243 | auto bufferOutput = builderOutput.GetBufferPointer(); |
| 1244 | // Force use CPU Runtime |
| 1245 | BackendConfig bnConfig; |
| 1246 | auto exe = Executor::newExecutor(MNN_FORWARD_CPU, bnConfig, 1); |
| 1247 | ExecutorScope scope(exe); |
| 1248 | Module::Config config; |
| 1249 | config.shapeMutable = false; |
| 1250 | std::shared_ptr<Module> interp0; |
| 1251 | |
| 1252 | MNN::ScheduleConfig sconfig; |
| 1253 | sconfig.numThread = 1; |
| 1254 | std::vector<MNN::ScheduleConfig> sconfigs = {sconfig}; |
| 1255 | auto rtInfo = Express::ExecutorScope::Current()->getRuntime(); |
| 1256 | auto rt = rtInfo.first.begin()->second; |
| 1257 | std::shared_ptr<Executor::RuntimeManager> rtMgr(Executor::RuntimeManager::createRuntimeManager(sconfigs)); |
| 1258 | rtMgr->setMode(Interpreter::Session_Memory_Collect); |
| 1259 | rtMgr->setHint(Interpreter::WINOGRAD_MEMORY_LEVEL, level); |
| 1260 | config.rearrange = false; // When set WINOGRAD_MEMORY_LEVEL=0 to test memory, must set rearrange=false. |
| 1261 | interp0.reset(Module::load({"Input"}, {"Prob"}, bufferOutput, sizeOutput, rtMgr, &config), Module::destroy); |
| 1262 | float memoryInMB = 0.0f; |
| 1263 | rtMgr->getInfo(Interpreter::MEMORY, &memoryInMB); |
| 1264 | return memoryInMB; |
| 1265 | } |
| 1266 | virtual bool run(int precision) { |
| 1267 | float mem0 = memoryUsed(0); |
| 1268 | float mem1 = memoryUsed(1); |
nothing calls this directly
no test coverage detected