MCPcopy Create free account
hub / github.com/ARM-software/armnn / InferenceModel

Method InferenceModel

tests/InferenceModel.hpp:405–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403 }
404
405 InferenceModel(const Params& params,
406 bool enableProfiling,
407 const std::string& dynamicBackendsPath,
408 const std::shared_ptr<armnn::IRuntime>& runtime = nullptr)
409 : m_EnableProfiling(enableProfiling),
410 m_ProfilingDetailsMethod(armnn::ProfilingDetailsMethod::Undefined),
411 m_DynamicBackendsPath(dynamicBackendsPath),
412 m_ImportInputsIfAligned(params.m_ImportInputsIfAligned)
413 {
414 if (runtime)
415 {
416 m_Runtime = runtime;
417 }
418 else
419 {
420 armnn::IRuntime::CreationOptions options;
421 options.m_EnableGpuProfiling = m_EnableProfiling;
422 options.m_DynamicBackendsPath = m_DynamicBackendsPath;
423 m_Runtime = armnn::IRuntime::Create(options);
424 }
425
426 // Configure the Profiler if the the profiling details are opted for
427 if (params.m_OutputDetailsOnlyToStdOut)
428 m_ProfilingDetailsMethod = armnn::ProfilingDetailsMethod::DetailsOnly;
429 else if (params.m_OutputDetailsToStdOut)
430 m_ProfilingDetailsMethod = armnn::ProfilingDetailsMethod::DetailsWithEvents;
431
432 std::string invalidBackends;
433 if (!CheckRequestedBackendsAreValid(params.m_ComputeDevices, armnn::Optional<std::string&>(invalidBackends)))
434 {
435 throw armnn::Exception("Some backend IDs are invalid: " + invalidBackends);
436 }
437
438 armnn::IOptimizedNetworkPtr optNet{nullptr, [](armnn::IOptimizedNetwork*){}};
439 {
440 const auto parsing_start_time = armnn::GetTimeNow();
441 armnn::INetworkPtr network = CreateNetworkImpl<IParser>::Create(params, m_InputBindings, m_OutputBindings);
442
443 ARMNN_LOG(info) << "Network parsing time: " << std::setprecision(2)
444 << std::fixed << armnn::GetTimeDuration(parsing_start_time).count() << " ms.";
445
446 ARMNN_SCOPED_HEAP_PROFILING("Optimizing");
447
448 armnn::OptimizerOptionsOpaque options;
449 options.SetReduceFp32ToFp16(params.m_EnableFp16TurboMode);
450 options.SetDebugEnabled(params.m_PrintIntermediateLayers);
451 options.SetDebugToFileEnabled(params.m_PrintIntermediateLayersToFile);
452 options.SetShapeInferenceMethod(params.m_InferOutputShape ?
453 armnn::ShapeInferenceMethod::InferAndValidate : armnn::ShapeInferenceMethod::ValidateOnly);
454 options.SetProfilingEnabled(m_EnableProfiling);
455
456 armnn::BackendOptions gpuAcc("GpuAcc",
457 {
458 { "FastMathEnabled", params.m_EnableFastMath },
459 { "SaveCachedNetwork", params.m_SaveCachedNetwork },
460 { "CachedNetworkFilePath", params.m_CachedNetworkFilePath },
461 { "MLGOTuningFilePath", params.m_MLGOTuningFilePath }
462 });

Callers

nothing calls this directly

Calls 15

GetTimeNowFunction · 0.85
GetTimeDurationFunction · 0.85
OptimizeFunction · 0.85
SetReduceFp32ToFp16Method · 0.80
SetDebugEnabledMethod · 0.80
SetDebugToFileEnabledMethod · 0.80
SetProfilingEnabledMethod · 0.80
AddModelOptionMethod · 0.80
LoadNetworkMethod · 0.80
ExceptionClass · 0.50
countMethod · 0.45

Tested by

no test coverage detected