| 347 | } |
| 348 | |
| 349 | bool Session::getInfo(Interpreter::SessionInfoCode code, void* ptr) const { |
| 350 | switch (code) { |
| 351 | case Interpreter::MEMORY: { |
| 352 | auto dst = (float*)ptr; |
| 353 | float summer = mRuntime.second->onGetMemoryInMB(); |
| 354 | for (auto& r : mRuntime.first) { |
| 355 | if (r.second.get() != mRuntime.second.get()) { |
| 356 | summer += r.second->onGetMemoryInMB(); |
| 357 | } |
| 358 | } |
| 359 | *dst = summer; |
| 360 | return true; |
| 361 | } break; |
| 362 | case Interpreter::BACKENDS: { |
| 363 | int pos = 0; |
| 364 | auto res = (int32_t*)ptr; |
| 365 | for (auto& r : mPipelines) { |
| 366 | auto type = r->getMainForwardType(); |
| 367 | res[pos++] = type; |
| 368 | } |
| 369 | return true; |
| 370 | } break; |
| 371 | case Interpreter::FLOPS: { |
| 372 | float flo = 0.0f; |
| 373 | for (auto& iter : mPipelines) { |
| 374 | flo += iter->flops(); |
| 375 | } |
| 376 | auto dst = (float*)ptr; |
| 377 | *dst = flo; |
| 378 | return true; |
| 379 | } break; |
| 380 | case Interpreter::RESIZE_STATUS: { |
| 381 | auto dst = (int*)ptr; |
| 382 | if (mNeedResize) { |
| 383 | *dst = 2; |
| 384 | } else if (mNeedMalloc) { |
| 385 | *dst = 1; |
| 386 | } else { |
| 387 | *dst = 0; |
| 388 | } |
| 389 | return true; |
| 390 | } break; |
| 391 | case Interpreter::THREAD_NUMBER: { |
| 392 | auto dst = (int*)ptr; |
| 393 | if (mPipelines.empty()) { |
| 394 | break; |
| 395 | } |
| 396 | *dst = mPipelines[0]->getPipelineInfo().first.info.numThread; |
| 397 | return true; |
| 398 | } |
| 399 | // TODO: Support other debug info |
| 400 | default: |
| 401 | break; |
| 402 | } |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | const Backend* Session::getBackEnd(const Tensor* tensor) const { |
no test coverage detected