| 163 | class NetModule : public Module { |
| 164 | public: |
| 165 | NetModule(std::shared_ptr<Module> m, std::shared_ptr<Module::Info> info, const MNN::Net* net, size_t size, float costTime) { |
| 166 | mChildren = {m}; |
| 167 | auto mModule = mChildren[0]; |
| 168 | mInfo = info; |
| 169 | setType("Net"); |
| 170 | #ifdef MNN_INTERNAL_ENABLED |
| 171 | if (nullptr != net) { |
| 172 | mLogInfo = logBasicInfo(); |
| 173 | std::string uuid = std::string(net->mnn_uuid() ? net->mnn_uuid()->c_str() : ""); |
| 174 | mLogInfo.emplace("UUID", uuid); |
| 175 | mLogInfo.emplace("ModelVersion", info->version); |
| 176 | int backend = MNN_FORWARD_CPU; |
| 177 | int precision = BackendConfig::Precision_Normal; |
| 178 | int mode = 1; |
| 179 | if (info->runTimeManager.get() != nullptr) { |
| 180 | auto attr = info->runTimeManager->getInside(); |
| 181 | mode = attr->mContent->mNumberThread; |
| 182 | int backendTypes[MNN_FORWARD_ALL]; |
| 183 | info->runTimeManager->getInfo(Interpreter::BACKENDS, &backendTypes); |
| 184 | backend = backendTypes[0]; |
| 185 | auto config = info->runTimeManager->getBnConfig(); |
| 186 | if (nullptr != config) { |
| 187 | precision = config->precision; |
| 188 | } |
| 189 | } |
| 190 | mLogInfo.emplace("Backend", std::to_string(backend)); |
| 191 | mLogInfo.emplace("Mode", std::to_string(mode)); |
| 192 | mLogInfo.emplace("Precision", std::to_string(precision)); |
| 193 | if (shouldLog(FREQ_HIGH)) { |
| 194 | std::map<std::string, std::string> metrics = mLogInfo; |
| 195 | metrics.emplace("Time", std::to_string(costTime)); |
| 196 | auto sizeInMB = (float)size / 1024.0f / 1024.0f; |
| 197 | metrics.emplace("ModelSize", std::to_string(sizeInMB)); |
| 198 | metrics.emplace("API", "Express::Module::NetModule"); |
| 199 | logAsync(metrics); |
| 200 | } |
| 201 | } |
| 202 | #endif // MNN_INTERNAL_ENABLED |
| 203 | } |
| 204 | virtual ~ NetModule(){ |
| 205 | mChildren.clear(); |
| 206 | mInfo.reset(); |