| 209 | } |
| 210 | |
| 211 | virtual std::vector<Express::VARP> onForward(const std::vector<Express::VARP>& inputs) override { |
| 212 | auto mModule = mChildren[0]; |
| 213 | // Reset resize staus |
| 214 | mInfo->runTimeManager->getInside()->mResizeStatus = 0; |
| 215 | #ifdef MNN_INTERNAL_ENABLED |
| 216 | Timer _time; |
| 217 | auto glo = ExecutorScope::Current(); |
| 218 | glo->getDebugTools()->flops = 0.0f; |
| 219 | #endif |
| 220 | std::vector<VARP> outputs; |
| 221 | { |
| 222 | Executor::RuntimeExecuteWrap wrap(mInfo->runTimeManager->getInside()->mRuntime); |
| 223 | outputs = mModule->onForward(inputs); |
| 224 | } |
| 225 | |
| 226 | // Check execution status after forward |
| 227 | if (!outputs.empty()) { |
| 228 | bool hasNoExecution = false; |
| 229 | for (auto& v : outputs) { |
| 230 | auto t = Utils::getTensor(v); |
| 231 | if (nullptr != t) { |
| 232 | auto backend = TensorUtils::getDescribeOrigin(t)->getBackend(); |
| 233 | if (nullptr != backend) { |
| 234 | // Try to sync to check execution status |
| 235 | int syncResult = backend->onSync(Tensor::MAP_TENSOR_READ, false, t); |
| 236 | if (NO_EXECUTION == syncResult) { |
| 237 | hasNoExecution = true; |
| 238 | break; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | if (hasNoExecution) { |
| 244 | MNN_PRINT("Warning, Backend has stop execute, return empty output vector varps\n"); |
| 245 | outputs.clear(); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | #ifdef MNN_INTERNAL_ENABLED |
| 250 | do { |
| 251 | if (outputs.empty()) { |
| 252 | break; |
| 253 | } |
| 254 | if (!shouldLog(FREQ_LOW)) { |
| 255 | break; |
| 256 | } |
| 257 | for (auto& v : outputs) { |
| 258 | auto t = Utils::getTensor(v); |
| 259 | t->wait(Tensor::MAP_TENSOR_READ, true); |
| 260 | } |
| 261 | auto metrics = mLogInfo; |
| 262 | metrics.emplace("Time", std::to_string((float)_time.durationInUs() / 1000.0f)); |
| 263 | metrics.emplace("API", "NetModule::onForward"); |
| 264 | if (mInfo->runTimeManager.get() != nullptr) { |
| 265 | float memory = 0.0f; |
| 266 | mInfo->runTimeManager->getInfo(Interpreter::MEMORY, &memory); |
| 267 | metrics.emplace("Flops", std::to_string(glo->getDebugTools()->flops)); |
| 268 | metrics.emplace("Memory", std::to_string(memory)); |
no test coverage detected