ArmNN
 22.11
ArmnnDriver Class Reference

#include <ArmnnDriver.hpp>

Inheritance diagram for ArmnnDriver:
ArmnnDevice

Public Member Functions

 ArmnnDriver (DriverOptions options)
 
 ~ArmnnDriver ()
 
const std::string & getName () const override
 
const std::string & getVersionString () const override
 
Version getFeatureLevel () const override
 
DeviceType getType () const override
 
const std::vector< Extension > & getSupportedExtensions () const override
 
const Capabilities & getCapabilities () const override
 
std::pair< uint32_t, uint32_t > getNumberOfCacheFilesNeeded () const override
 
GeneralResult< void > wait () const override
 
GeneralResult< std::vector< bool > > getSupportedOperations (const Model &model) const override
 
GeneralResult< SharedPreparedModel > prepareModel (const Model &model, ExecutionPreference preference, Priority priority, OptionalTimePoint deadline, const std::vector< SharedHandle > &modelCache, const std::vector< SharedHandle > &dataCache, const CacheToken &token, const std::vector< android::nn::TokenValuePair > &hints, const std::vector< android::nn::ExtensionNameAndPrefix > &extensionNameToPrefix) const override
 
GeneralResult< SharedPreparedModel > prepareModelFromCache (OptionalTimePoint deadline, const std::vector< SharedHandle > &modelCache, const std::vector< SharedHandle > &dataCache, const CacheToken &token) const override
 
GeneralResult< SharedBuffer > allocate (const BufferDesc &, const std::vector< SharedPreparedModel > &, const std::vector< BufferRole > &, const std::vector< BufferRole > &) const override
 

Additional Inherited Members

- Protected Member Functions inherited from ArmnnDevice
 ArmnnDevice (DriverOptions options)
 
virtual ~ArmnnDevice ()
 
- Protected Attributes inherited from ArmnnDevice
armnn::IRuntimePtr m_Runtime
 
armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
 
DriverOptions m_Options
 

Detailed Description

Definition at line 31 of file ArmnnDriver.hpp.

Constructor & Destructor Documentation

◆ ArmnnDriver()

ArmnnDriver ( DriverOptions  options)
inline

Definition at line 35 of file ArmnnDriver.hpp.

36  : ArmnnDevice(std::move(options))
37  {
38  VLOG(DRIVER) << "ArmnnDriver::ArmnnDriver()";
39  }
ArmnnDevice(DriverOptions options)
Definition: ArmnnDevice.cpp:42

◆ ~ArmnnDriver()

~ArmnnDriver ( )
inline

Definition at line 40 of file ArmnnDriver.hpp.

41  {
42  VLOG(DRIVER) << "ArmnnDriver::~ArmnnDriver()";
43  }

Member Function Documentation

◆ allocate()

GeneralResult<SharedBuffer> allocate ( const BufferDesc &  ,
const std::vector< SharedPreparedModel > &  ,
const std::vector< BufferRole > &  ,
const std::vector< BufferRole > &   
) const
inlineoverride

Definition at line 232 of file ArmnnDriver.hpp.

236  {
237  VLOG(DRIVER) << "ArmnnDriver::allocate()";
238  return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "ArmnnDriver::allocate -- does not support allocate.";
239  }

◆ getCapabilities()

const Capabilities& getCapabilities ( ) const
inlineoverride

Definition at line 80 of file ArmnnDriver.hpp.

References ArmnnDriverImpl::GetCapabilities(), and ArmnnDevice::m_Runtime.

81  {
82  VLOG(DRIVER) << "ArmnnDriver::GetCapabilities()";
84  }
armnn::IRuntimePtr m_Runtime
Definition: ArmnnDevice.hpp:23
static const Capabilities & GetCapabilities(const armnn::IRuntimePtr &runtime)

◆ getFeatureLevel()

Version getFeatureLevel ( ) const
inlineoverride

Definition at line 61 of file ArmnnDriver.hpp.

62  {
63  VLOG(DRIVER) << "ArmnnDriver::getFeatureLevel()";
64  return kVersionFeatureLevel6;
65  }

◆ getName()

const std::string& getName ( ) const
inlineoverride

Definition at line 47 of file ArmnnDriver.hpp.

48  {
49  VLOG(DRIVER) << "ArmnnDriver::getName()";
50  static const std::string name = "arm-armnn-sl";
51  return name;
52  }

◆ getNumberOfCacheFilesNeeded()

std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded ( ) const
inlineoverride

Definition at line 86 of file ArmnnDriver.hpp.

References DriverOptions::GetBackends(), armnn::GetNumberOfCacheFiles(), and ArmnnDevice::m_Options.

87  {
88  VLOG(DRIVER) << "ArmnnDriver::getNumberOfCacheFilesNeeded()";
89  unsigned int numberOfCachedModelFiles = 0;
90  for (auto& backend : m_Options.GetBackends())
91  {
92  numberOfCachedModelFiles += GetNumberOfCacheFiles(backend);
93  VLOG(DRIVER) << "ArmnnDriver::getNumberOfCacheFilesNeeded() = " << std::to_string(numberOfCachedModelFiles);
94  }
95  return std::make_pair(numberOfCachedModelFiles, 1ul);
96  }
unsigned int GetNumberOfCacheFiles(const armnn::BackendId &backend)
Returns the number of cached files if backend supports caching.
const std::vector< armnn::BackendId > & GetBackends() const

◆ getSupportedExtensions()

const std::vector<Extension>& getSupportedExtensions ( ) const
inlineoverride

Definition at line 73 of file ArmnnDriver.hpp.

74  {
75  VLOG(DRIVER) << "ArmnnDriver::getSupportedExtensions()";
76  static const std::vector<Extension> extensions = {};
77  return extensions;
78  }

◆ getSupportedOperations()

GeneralResult<std::vector<bool> > getSupportedOperations ( const Model model) const
inlineoverride

Definition at line 104 of file ArmnnDriver.hpp.

References DriverOptions::GetBackends(), DriverOptions::GetForcedUnsupportedOperations(), DriverOptions::GetRequestInputsAndOutputsDumpDir(), ModelToINetworkTransformer::IsOperationSupported(), ArmnnDevice::m_Options, ArmnnDevice::m_Runtime, armnn_driver::Success, and armnn_driver::UnsupportedFeature.

105  {
106  VLOG(DRIVER) << "ArmnnDriver::getSupportedOperations()";
107 
108  std::stringstream ss;
109  ss << "ArmnnDriverImpl::getSupportedOperations()";
110  std::string fileName;
111  std::string timestamp;
113  {
114  ss << " : "
116  << "/"
117  // << GetFileTimestamp()
118  << "_getSupportedOperations.txt";
119  }
120  VLOG(DRIVER) << ss.str().c_str();
121 
123  {
124  //dump the marker file
125  std::ofstream fileStream;
126  fileStream.open(fileName, std::ofstream::out | std::ofstream::trunc);
127  if (fileStream.good())
128  {
129  fileStream << timestamp << std::endl;
130  fileStream << timestamp << std::endl;
131  }
132  fileStream.close();
133  }
134 
135  std::vector<bool> result;
136  if (!m_Runtime)
137  {
138  return NN_ERROR(ErrorStatus::DEVICE_UNAVAILABLE) << "Device Unavailable!";
139  }
140 
141  // Run general model validation, if this doesn't pass we shouldn't analyse the model anyway.
142  if (const auto result = validate(model); !result.ok())
143  {
144  return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Invalid Model!";
145  }
146 
147  // Attempt to convert the model to an ArmNN input network (INetwork).
149  model,
151 
152  if (modelConverter.GetConversionResult() != ConversionResult::Success
153  && modelConverter.GetConversionResult() != ConversionResult::UnsupportedFeature)
154  {
155  return NN_ERROR(ErrorStatus::GENERAL_FAILURE) << "Conversion Error!";
156  }
157 
158  // Check each operation if it was converted successfully and copy the flags
159  // into the result (vector<bool>) that we need to return to Android.
160  result.reserve(model.main.operations.size());
161  for (uint32_t operationIdx = 0; operationIdx < model.main.operations.size(); ++operationIdx)
162  {
163  bool operationSupported = modelConverter.IsOperationSupported(operationIdx);
164  result.push_back(operationSupported);
165  }
166 
167  return result;
168  }
const std::set< unsigned int > & GetForcedUnsupportedOperations() const
armnn::IRuntimePtr m_Runtime
Definition: ArmnnDevice.hpp:23
const std::string & GetRequestInputsAndOutputsDumpDir() const
bool IsOperationSupported(uint32_t operationIndex) const
const std::vector< armnn::BackendId > & GetBackends() const

◆ getType()

DeviceType getType ( ) const
inlineoverride

Definition at line 67 of file ArmnnDriver.hpp.

68  {
69  VLOG(DRIVER) << "ArmnnDriver::getType()";
70  return DeviceType::CPU;
71  }

◆ getVersionString()

const std::string& getVersionString ( ) const
inlineoverride

Definition at line 54 of file ArmnnDriver.hpp.

References ARMNN_VERSION.

55  {
56  VLOG(DRIVER) << "ArmnnDriver::getVersionString()";
57  static const std::string versionString = ARMNN_VERSION;
58  return versionString;
59  }
#define ARMNN_VERSION
ARMNN_VERSION: "X.Y.Z" where: X = Major version number Y = Minor version number Z = Patch version num...
Definition: Version.hpp:22

◆ prepareModel()

GeneralResult<SharedPreparedModel> prepareModel ( const Model model,
ExecutionPreference  preference,
Priority  priority,
OptionalTimePoint  deadline,
const std::vector< SharedHandle > &  modelCache,
const std::vector< SharedHandle > &  dataCache,
const CacheToken &  token,
const std::vector< android::nn::TokenValuePair > &  hints,
const std::vector< android::nn::ExtensionNameAndPrefix > &  extensionNameToPrefix 
) const
inlineoverride

Definition at line 170 of file ArmnnDriver.hpp.

References DriverOptions::GetFp16Enabled(), ArmnnDevice::m_ClTunedParameters, ArmnnDevice::m_Options, ArmnnDevice::m_Runtime, and ArmnnDriverImpl::PrepareArmnnModel().

179  {
180  VLOG(DRIVER) << "ArmnnDriver::prepareModel()";
181 
182  // Validate arguments.
183  if (const auto result = validate(model); !result.ok()) {
184  return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Invalid Model: " << result.error();
185  }
186  if (const auto result = validate(preference); !result.ok()) {
187  return NN_ERROR(ErrorStatus::INVALID_ARGUMENT)
188  << "Invalid ExecutionPreference: " << result.error();
189  }
190  if (const auto result = validate(priority); !result.ok()) {
191  return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Invalid Priority: " << result.error();
192  }
193 
194  // Check if deadline has passed.
195  if (hasDeadlinePassed(deadline)) {
196  return NN_ERROR(ErrorStatus::MISSED_DEADLINE_PERSISTENT);
197  }
198 
201  m_Options,
202  model,
203  modelCache,
204  dataCache,
205  token,
206  model.relaxComputationFloat32toFloat16 && m_Options.GetFp16Enabled(),
207  priority);
208  }
armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
Definition: ArmnnDevice.hpp:24
armnn::IRuntimePtr m_Runtime
Definition: ArmnnDevice.hpp:23
static GeneralResult< SharedPreparedModel > PrepareArmnnModel(const armnn::IRuntimePtr &runtime, const armnn::IGpuAccTunedParametersPtr &clTunedParameters, const DriverOptions &options, const Model &model, const std::vector< SharedHandle > &modelCacheHandle, const std::vector< SharedHandle > &dataCacheHandle, const CacheToken &token, bool float32ToFloat16=false, Priority priority=Priority::MEDIUM)

◆ prepareModelFromCache()

GeneralResult<SharedPreparedModel> prepareModelFromCache ( OptionalTimePoint  deadline,
const std::vector< SharedHandle > &  modelCache,
const std::vector< SharedHandle > &  dataCache,
const CacheToken &  token 
) const
inlineoverride

Definition at line 210 of file ArmnnDriver.hpp.

References DriverOptions::GetFp16Enabled(), ArmnnDevice::m_ClTunedParameters, ArmnnDevice::m_Options, ArmnnDevice::m_Runtime, and ArmnnDriverImpl::PrepareArmnnModelFromCache().

214  {
215  VLOG(DRIVER) << "ArmnnDriver::prepareModelFromCache()";
216 
217  // Check if deadline has passed.
218  if (hasDeadlinePassed(deadline)) {
219  return NN_ERROR(ErrorStatus::MISSED_DEADLINE_PERSISTENT);
220  }
221 
223  m_Runtime,
225  m_Options,
226  modelCache,
227  dataCache,
228  token,
230  }
armnn::IGpuAccTunedParametersPtr m_ClTunedParameters
Definition: ArmnnDevice.hpp:24
armnn::IRuntimePtr m_Runtime
Definition: ArmnnDevice.hpp:23
static GeneralResult< SharedPreparedModel > PrepareArmnnModelFromCache(const armnn::IRuntimePtr &runtime, const armnn::IGpuAccTunedParametersPtr &clTunedParameters, const DriverOptions &options, const std::vector< SharedHandle > &modelCacheHandle, const std::vector< SharedHandle > &dataCacheHandle, const CacheToken &token, bool float32ToFloat16=false)

◆ wait()

GeneralResult<void> wait ( ) const
inlineoverride

Definition at line 98 of file ArmnnDriver.hpp.

99  {
100  VLOG(DRIVER) << "ArmnnDriver::wait()";
101  return {};
102  }

The documentation for this class was generated from the following file: