MCPcopy Create free account
hub / github.com/alibaba/MNN / getInfo

Method getInfo

source/core/Session.cpp:349–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349bool 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
406const Backend* Session::getBackEnd(const Tensor* tensor) const {

Callers 3

OpenCLRuntimeMethod · 0.45
logForRunSessionMethod · 0.45
getSessionInfoMethod · 0.45

Calls 5

getMainForwardTypeMethod · 0.80
onGetMemoryInMBMethod · 0.45
getMethod · 0.45
flopsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected