ArmNN
 24.02
ArmnnDevice Class Reference

#include <ArmnnDevice.hpp>

Collaboration diagram for ArmnnDevice:
[legend]

Public Member Functions

 ArmnnDevice (DriverOptions options)
 
 ~ArmnnDevice ()
 

Protected Attributes

armnn::IRuntimePtr m_Runtime
 
armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
 
DriverOptions m_Options
 

Friends

class ArmnnDriver
 

Detailed Description

Definition at line 15 of file ArmnnDevice.hpp.

Constructor & Destructor Documentation

◆ ArmnnDevice()

ArmnnDevice ( DriverOptions  options)

Definition at line 42 of file ArmnnDevice.cpp.

43  : m_Runtime(nullptr, nullptr)
44  , m_ClTunedParameters(nullptr)
45  , m_Options(std::move(options))
46 {
47  // First check if the DriverOptions is happy.
48  if (options.ShouldExit())
49  {
50  // Is this a good or bad exit?
51  if (options.GetExitCode() != EXIT_SUCCESS)
52  {
53  throw armnn::InvalidArgumentException("ArmnnDevice: Insufficient or illegal options specified.");
54  }
55  else
56  {
57  throw armnn::InvalidArgumentException("ArmnnDevice: Nothing to do.");
58  }
59  }
60 
61  initVLogMask();
62  VLOG(DRIVER) << "ArmnnDevice::ArmnnDevice()";
63 
64 #ifdef __ANDROID__
65  __android_log_print(ANDROID_LOG_DEBUG, "ARMNN_SL", "ArmnnDevice::ArmnnDevice()");
66 #endif
67 
70  {
71  SetMinimumLogSeverity(android::base::VERBOSE);
72  }
73  else
74  {
75  SetMinimumLogSeverity(android::base::INFO);
76  }
77  armnn::IRuntime::CreationOptions runtimeOptions;
78 
79  if (std::find(m_Options.GetBackends().begin(),
80  m_Options.GetBackends().end(),
82  {
83  try
84  {
85  if (!m_Options.GetClTunedParametersFile().empty())
86  {
89  try
90  {
92  }
93  catch (std::exception& error)
94  {
95  // This is only a warning because the file won't exist the first time you are generating it.
96  VLOG(DRIVER) << "ArmnnDevice: Failed to load CL tuned parameters file "
97  << m_Options.GetClTunedParametersFile().c_str() << " : " << error.what();
98  }
100  }
101  }
102  catch (const armnn::ClRuntimeUnavailableException& error)
103  {
104  VLOG(DRIVER) << "ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable." << error.what();
105  }
106  catch (std::exception& error)
107  {
108  VLOG(DRIVER) << "ArmnnDevice: Unknown exception: %s. Device will be unavailable." << error.what();
109  }
110  }
112  m_Runtime = armnn::IRuntime::Create(runtimeOptions);
113 
114  std::vector<armnn::BackendId> backends;
115 
116  if (m_Runtime)
117  {
118  const armnn::BackendIdSet supportedDevices = m_Runtime->GetDeviceSpec().GetSupportedBackends();
119  for (auto &backend : m_Options.GetBackends())
120  {
121  if (std::find(supportedDevices.cbegin(), supportedDevices.cend(), backend) == supportedDevices.cend())
122  {
123  VLOG(DRIVER) << "ArmnnDevice: Requested unknown backend " << backend.Get().c_str();
124  }
125  else
126  {
129  backend))
130  {
131  VLOG(DRIVER) << "ArmnnDevice: ArmNN does not support AsyncExecution with the following backend: "
132  << backend.Get().c_str();
133  }
134  else
135  {
136  backends.push_back(backend);
137  }
138  }
139  }
140  }
141 
142  if (backends.empty())
143  {
144  // No known backend specified
145  throw armnn::InvalidArgumentException("ArmnnDevice: No known backend specified.");
146  }
147 
148  m_Options.SetBackends(backends);
149  VLOG(DRIVER) << "ArmnnDevice: Created device with the following backends: " << GetBackendString(m_Options).c_str();
150 
151 #ifdef __ANDROID__
152  __android_log_print(ANDROID_LOG_DEBUG,
153  "ARMNN_SL",
154  "ArmnnDevice: Created device with the following backends: %s",
155  GetBackendString(m_Options).c_str());
156 #endif
157 }

References armnn::ConfigureLogging(), IRuntime::Create(), IGpuAccTunedParameters::Create(), DriverOptions::GetBackends(), DriverOptions::GetClTunedParametersFile(), DriverOptions::GetClTunedParametersMode(), DriverOptions::GetClTuningLevel(), DriverOptions::GetExitCode(), armnn::GpuAcc, armnn::HasMatchingCapability(), DriverOptions::isAsyncModelExecutionEnabled(), DriverOptions::IsGpuProfilingEnabled(), DriverOptions::IsVerboseLoggingEnabled(), ArmnnDevice::m_ClTunedParameters, IRuntime::CreationOptions::m_EnableGpuProfiling, IRuntime::CreationOptions::m_GpuAccTunedParameters, ArmnnDevice::m_Options, ArmnnDevice::m_Runtime, DriverOptions::SetBackends(), DriverOptions::ShouldExit(), and armnn::Trace.

◆ ~ArmnnDevice()

~ArmnnDevice ( )
inline

Definition at line 21 of file ArmnnDevice.hpp.

21 {}

Friends And Related Function Documentation

◆ ArmnnDriver

friend class ArmnnDriver
friend

Definition at line 17 of file ArmnnDevice.hpp.

Member Data Documentation

◆ m_ClTunedParameters

armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
protected

Definition at line 24 of file ArmnnDevice.hpp.

Referenced by ArmnnDevice::ArmnnDevice().

◆ m_Options

DriverOptions m_Options
protected

Definition at line 25 of file ArmnnDevice.hpp.

Referenced by ArmnnDevice::ArmnnDevice().

◆ m_Runtime

armnn::IRuntimePtr m_Runtime
protected

Definition at line 23 of file ArmnnDevice.hpp.

Referenced by ArmnnDevice::ArmnnDevice().


The documentation for this class was generated from the following files:
armnn_driver::DriverOptions::IsGpuProfilingEnabled
bool IsGpuProfilingEnabled() const
Definition: DriverOptions.hpp:35
armnn_driver::ArmnnDevice::m_Runtime
armnn::IRuntimePtr m_Runtime
Definition: ArmnnDevice.hpp:23
armnn_driver::DriverOptions::isAsyncModelExecutionEnabled
bool isAsyncModelExecutionEnabled() const
Definition: DriverOptions.hpp:44
armnn::Compute::GpuAcc
@ GpuAcc
GPU Execution: OpenCL: ArmCompute.
armnn::LogSeverity::Trace
@ Trace
armnn::BackendIdSet
std::unordered_set< BackendId > BackendIdSet
Definition: BackendId.hpp:193
armnn::ConfigureLogging
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
Definition: Utils.cpp:18
armnn::BackendOptions::BackendOption
Definition: BackendOptions.hpp:215
armnn::IGpuAccTunedParameters::Create
static IGpuAccTunedParametersPtr Create(Mode mode, TuningLevel tunerMode)
Definition: ArmComputeTuningUtils.cpp:17
armnn_driver::DriverOptions::GetClTunedParametersFile
const std::string & GetClTunedParametersFile() const
Definition: DriverOptions.hpp:31
armnn::BoostLogSeverityMapping::error
@ error
armnn_driver::DriverOptions::SetBackends
void SetBackends(const std::vector< armnn::BackendId > &backends)
Definition: DriverOptions.hpp:38
armnn_driver::ArmnnDevice::m_ClTunedParameters
armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
Definition: ArmnnDevice.hpp:24
armnn_driver::DriverOptions::GetClTunedParametersMode
armnn::IGpuAccTunedParameters::Mode GetClTunedParametersMode() const
Definition: DriverOptions.hpp:33
armnn_driver::DriverOptions::IsVerboseLoggingEnabled
bool IsVerboseLoggingEnabled() const
Definition: DriverOptions.hpp:27
armnn_driver::DriverOptions::GetClTuningLevel
armnn::IGpuAccTunedParameters::TuningLevel GetClTuningLevel() const
Definition: DriverOptions.hpp:34
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::IRuntime::CreationOptions
Definition: IRuntime.hpp:78
armnn_driver::DriverOptions::GetBackends
const std::vector< armnn::BackendId > & GetBackends() const
Definition: DriverOptions.hpp:26
armnn::IRuntime::Create
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:52
armnn_driver::ArmnnDevice::m_Options
DriverOptions m_Options
Definition: ArmnnDevice.hpp:25
armnn::IRuntime::CreationOptions::m_GpuAccTunedParameters
std::shared_ptr< IGpuAccTunedParameters > m_GpuAccTunedParameters
If set, uses the GpuAcc tuned parameters from the given object when executing GPU workloads.
Definition: IRuntime.hpp:91
armnn::ClRuntimeUnavailableException
Definition: Exceptions.hpp:74
armnn::IRuntime::CreationOptions::m_EnableGpuProfiling
bool m_EnableGpuProfiling
Setting this flag will allow the user to obtain GPU profiling information from the runtime.
Definition: IRuntime.hpp:94
armnn::HasMatchingCapability
bool HasMatchingCapability(const BackendOptions::BackendOption &capability, const BackendCapabilities &capabilities)
Convenience function to check if a given capability matches a capability in a BackendCapabilities str...
Definition: BackendHelper.cpp:85