ArmNN
 20.08
CounterDirectory Class Referencefinal

#include <CounterDirectory.hpp>

Inheritance diagram for CounterDirectory:
ICounterDirectory ICounterRegistry

Public Member Functions

 CounterDirectory ()=default
 
 ~CounterDirectory ()=default
 
const CategoryRegisterCategory (const std::string &categoryName) override
 
const DeviceRegisterDevice (const std::string &deviceName, uint16_t cores=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
 
const CounterSetRegisterCounterSet (const std::string &counterSetName, uint16_t count=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
 
const CounterRegisterCounter (const BackendId &backendId, const uint16_t uid, const std::string &parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, const std::string &name, const std::string &description, const Optional< std::string > &units=EmptyOptional(), const Optional< uint16_t > &numberOfCores=EmptyOptional(), const Optional< uint16_t > &deviceUid=EmptyOptional(), const Optional< uint16_t > &counterSetUid=EmptyOptional()) override
 
uint16_t GetCategoryCount () const override
 
uint16_t GetDeviceCount () const override
 
uint16_t GetCounterSetCount () const override
 
uint16_t GetCounterCount () const override
 
const CategoriesGetCategories () const override
 
const DevicesGetDevices () const override
 
const CounterSetsGetCounterSets () const override
 
const CountersGetCounters () const override
 
const CategoryGetCategory (const std::string &name) const override
 
const DeviceGetDevice (uint16_t uid) const override
 
const CounterSetGetCounterSet (uint16_t uid) const override
 
const CounterGetCounter (uint16_t uid) const override
 
bool IsCategoryRegistered (const std::string &categoryName) const
 
bool IsDeviceRegistered (uint16_t deviceUid) const
 
bool IsDeviceRegistered (const std::string &deviceName) const
 
bool IsCounterSetRegistered (uint16_t counterSetUid) const
 
bool IsCounterSetRegistered (const std::string &counterSetName) const
 
bool IsCounterRegistered (uint16_t counterUid) const
 
bool IsCounterRegistered (const std::string &counterName) const
 
void Clear ()
 
- Public Member Functions inherited from ICounterDirectory
virtual ~ICounterDirectory ()
 
- Public Member Functions inherited from ICounterRegistry
virtual ~ICounterRegistry ()
 

Detailed Description

Definition at line 23 of file CounterDirectory.hpp.

Constructor & Destructor Documentation

◆ CounterDirectory()

CounterDirectory ( )
default

◆ ~CounterDirectory()

~CounterDirectory ( )
default

Member Function Documentation

◆ Clear()

void Clear ( )

Definition at line 441 of file CounterDirectory.cpp.

References ARMNN_ASSERT, OptionalBase::has_value(), and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by CounterDirectory::GetCounters(), and ProfilingService::GetSendTimelinePacket().

442 {
443  // Clear all the counter directory contents
444  m_Categories.clear();
445  m_Devices.clear();
446  m_CounterSets.clear();
447  m_Counters.clear();
448 }

◆ GetCategories()

const Categories& GetCategories ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 57 of file CounterDirectory.hpp.

57 { return m_Categories; }

◆ GetCategory()

const Category * GetCategory ( const std::string &  name) const
overridevirtual

Implements ICounterDirectory.

Definition at line 332 of file CounterDirectory.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), and CounterDirectory::GetCounters().

333 {
334  auto it = FindCategory(categoryName);
335  if (it == m_Categories.end())
336  {
337  return nullptr;
338  }
339 
340  const Category* category = it->get();
341  ARMNN_ASSERT(category);
342 
343  return category;
344 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ GetCategoryCount()

uint16_t GetCategoryCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 51 of file CounterDirectory.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

51 { return armnn::numeric_cast<uint16_t>(m_Categories.size()); }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetCounter()

const Counter * GetCounter ( uint16_t  uid) const
overridevirtual

Implements ICounterDirectory.

Definition at line 376 of file CounterDirectory.cpp.

References ARMNN_ASSERT, Counter::m_MaxCounterUid, and Counter::m_Uid.

Referenced by BOOST_AUTO_TEST_CASE(), CounterDirectory::GetCounters(), and CounterDirectory::RegisterCounter().

377 {
378  auto it = FindCounter(counterUid);
379  if (it == m_Counters.end())
380  {
381  return nullptr;
382  }
383 
384  const Counter* counter = it->second.get();
385  ARMNN_ASSERT(counter);
386  ARMNN_ASSERT(counter->m_Uid <= counterUid);
387  ARMNN_ASSERT(counter->m_Uid <= counter->m_MaxCounterUid);
388 
389  return counter;
390 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 54 of file CounterDirectory.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::GetCounterCount().

54 { return armnn::numeric_cast<uint16_t>(m_Counters.size()); }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetCounters()

◆ GetCounterSet()

const CounterSet * GetCounterSet ( uint16_t  uid) const
overridevirtual

Implements ICounterDirectory.

Definition at line 361 of file CounterDirectory.cpp.

References ARMNN_ASSERT, and CounterSet::m_Uid.

Referenced by BOOST_AUTO_TEST_CASE(), and CounterDirectory::GetCounters().

362 {
363  auto it = FindCounterSet(counterSetUid);
364  if (it == m_CounterSets.end())
365  {
366  return nullptr;
367  }
368 
369  const CounterSet* counterSet = it->second.get();
370  ARMNN_ASSERT(counterSet);
371  ARMNN_ASSERT(counterSet->m_Uid == counterSetUid);
372 
373  return counterSet;
374 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ GetCounterSetCount()

uint16_t GetCounterSetCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 53 of file CounterDirectory.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

53 { return armnn::numeric_cast<uint16_t>(m_CounterSets.size()); }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetCounterSets()

const CounterSets& GetCounterSets ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 59 of file CounterDirectory.hpp.

59 { return m_CounterSets; }

◆ GetDevice()

const Device * GetDevice ( uint16_t  uid) const
overridevirtual

Implements ICounterDirectory.

Definition at line 346 of file CounterDirectory.cpp.

References ARMNN_ASSERT, and Device::m_Uid.

Referenced by BOOST_AUTO_TEST_CASE(), and CounterDirectory::GetCounters().

347 {
348  auto it = FindDevice(deviceUid);
349  if (it == m_Devices.end())
350  {
351  return nullptr;
352  }
353 
354  const Device* device = it->second.get();
355  ARMNN_ASSERT(device);
356  ARMNN_ASSERT(device->m_Uid == deviceUid);
357 
358  return device;
359 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ GetDeviceCount()

uint16_t GetDeviceCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 52 of file CounterDirectory.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

52 { return armnn::numeric_cast<uint16_t>(m_Devices.size()); }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetDevices()

const Devices& GetDevices ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 58 of file CounterDirectory.hpp.

58 { return m_Devices; }

◆ IsCategoryRegistered()

bool IsCategoryRegistered ( const std::string &  categoryName) const

Definition at line 392 of file CounterDirectory.cpp.

Referenced by CounterDirectory::GetCounters(), ProfilingService::GetSendTimelinePacket(), and CounterDirectory::RegisterCategory().

393 {
394  auto it = FindCategory(categoryName);
395 
396  return it != m_Categories.end();
397 }

◆ IsCounterRegistered() [1/2]

bool IsCounterRegistered ( uint16_t  counterUid) const

Definition at line 427 of file CounterDirectory.cpp.

Referenced by CounterDirectory::GetCounters(), ProfilingService::GetSendTimelinePacket(), and ProfilingService::IsCounterRegistered().

428 {
429  auto it = FindCounter(counterUid);
430 
431  return it != m_Counters.end();
432 }

◆ IsCounterRegistered() [2/2]

bool IsCounterRegistered ( const std::string &  counterName) const

Definition at line 434 of file CounterDirectory.cpp.

435 {
436  auto it = FindCounter(counterName);
437 
438  return it != m_Counters.end();
439 }

◆ IsCounterSetRegistered() [1/2]

bool IsCounterSetRegistered ( uint16_t  counterSetUid) const

Definition at line 413 of file CounterDirectory.cpp.

Referenced by CounterDirectory::GetCounters(), CounterDirectory::RegisterCounter(), and CounterDirectory::RegisterCounterSet().

414 {
415  auto it = FindCounterSet(counterSetUid);
416 
417  return it != m_CounterSets.end();
418 }

◆ IsCounterSetRegistered() [2/2]

bool IsCounterSetRegistered ( const std::string &  counterSetName) const

Definition at line 420 of file CounterDirectory.cpp.

421 {
422  auto it = FindCounterSet(counterSetName);
423 
424  return it != m_CounterSets.end();
425 }

◆ IsDeviceRegistered() [1/2]

bool IsDeviceRegistered ( uint16_t  deviceUid) const

Definition at line 399 of file CounterDirectory.cpp.

Referenced by CounterDirectory::GetCounters(), and CounterDirectory::RegisterDevice().

400 {
401  auto it = FindDevice(deviceUid);
402 
403  return it != m_Devices.end();
404 }

◆ IsDeviceRegistered() [2/2]

bool IsDeviceRegistered ( const std::string &  deviceName) const

Definition at line 406 of file CounterDirectory.cpp.

407 {
408  auto it = FindDevice(deviceName);
409 
410  return it != m_Devices.end();
411 }

◆ RegisterCategory()

const Category * RegisterCategory ( const std::string &  categoryName)
overridevirtual

Implements ICounterRegistry.

Definition at line 23 of file CounterDirectory.cpp.

References ARMNN_ASSERT, and CounterDirectory::IsCategoryRegistered().

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::GetSendTimelinePacket().

24 {
25  // Check that the given category name is valid
26  if (categoryName.empty() ||
27  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(categoryName))
28  {
29  throw InvalidArgumentException("Trying to register a category with an invalid name");
30  }
31 
32  // Check that the given category is not already registered
33  if (IsCategoryRegistered(categoryName))
34  {
35  throw InvalidArgumentException(
36  boost::str(boost::format("Trying to register a category already registered (\"%1%\")")
37  % categoryName));
38  }
39 
40  // Create the category
41  CategoryPtr category = std::make_unique<Category>(categoryName);
42  ARMNN_ASSERT(category);
43 
44  // Get the raw category pointer
45  const Category* categoryPtr = category.get();
46  ARMNN_ASSERT(categoryPtr);
47 
48  // Register the category
49  m_Categories.insert(std::move(category));
50 
51  return categoryPtr;
52 }
bool IsCategoryRegistered(const std::string &categoryName) const
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::unique_ptr< Category > CategoryPtr

◆ RegisterCounter()

const Counter * RegisterCounter ( const BackendId backendId,
const uint16_t  uid,
const std::string &  parentCategoryName,
uint16_t  counterClass,
uint16_t  interpolation,
double  multiplier,
const std::string &  name,
const std::string &  description,
const Optional< std::string > &  units = EmptyOptional(),
const Optional< uint16_t > &  numberOfCores = EmptyOptional(),
const Optional< uint16_t > &  deviceUid = EmptyOptional(),
const Optional< uint16_t > &  counterSetUid = EmptyOptional() 
)
overridevirtual

Implements ICounterRegistry.

Definition at line 183 of file CounterDirectory.cpp.

References ARMNN_ASSERT, CounterDirectory::GetCounter(), armnn::profiling::GetNextCounterUids(), OptionalBase::has_value(), armnn::IgnoreUnused(), CounterDirectory::IsCounterSetRegistered(), Counter::m_Name, OptionalReferenceSwitch< std::is_reference< T >::value, T >::value(), and OptionalReferenceSwitch< IsReference, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::GetSendTimelinePacket().

195 {
196  IgnoreUnused(backendId);
197 
198  // Check that the given parent category name is valid
199  if (parentCategoryName.empty() ||
200  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(parentCategoryName))
201  {
202  throw InvalidArgumentException("Trying to register a counter with an invalid parent category name");
203  }
204 
205  // Check that the given class is valid
206  if (counterClass != 0 && counterClass != 1)
207  {
208  throw InvalidArgumentException("Trying to register a counter with an invalid class");
209  }
210 
211  // Check that the given interpolation is valid
212  if (interpolation != 0 && interpolation != 1)
213  {
214  throw InvalidArgumentException("Trying to register a counter with an invalid interpolation");
215  }
216 
217  // Check that the given multiplier is valid
218  if (multiplier == .0f)
219  {
220  throw InvalidArgumentException("Trying to register a counter with an invalid multiplier");
221  }
222 
223  // Check that the given name is valid
224  if (name.empty() ||
225  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(name))
226  {
227  throw InvalidArgumentException("Trying to register a counter with an invalid name");
228  }
229 
230  // Check that the given description is valid
231  if (description.empty() ||
232  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(description))
233  {
234  throw InvalidArgumentException("Trying to register a counter with an invalid description");
235  }
236 
237  // Check that the given units are valid
238  if (units.has_value()
239  && !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(units.value()))
240  {
241  throw InvalidArgumentException("Trying to register a counter with a invalid units");
242  }
243 
244  // Check that the given parent category is registered
245  auto categoryIt = FindCategory(parentCategoryName);
246  if (categoryIt == m_Categories.end())
247  {
248  throw InvalidArgumentException(
249  boost::str(boost::format("Trying to connect a counter to a category "
250  "that is not registered (name: \"%1%\")")
251  % parentCategoryName));
252  }
253 
254  // Get the parent category
255  const CategoryPtr& parentCategory = *categoryIt;
256  ARMNN_ASSERT(parentCategory);
257 
258  // Check that a counter with the given name is not already registered within the parent category
259  const std::vector<uint16_t>& parentCategoryCounters = parentCategory->m_Counters;
260  for (uint16_t parentCategoryCounterUid : parentCategoryCounters)
261  {
262  const Counter* parentCategoryCounter = GetCounter(parentCategoryCounterUid);
263  ARMNN_ASSERT(parentCategoryCounter);
264 
265  if (parentCategoryCounter->m_Name == name)
266  {
267  throw InvalidArgumentException(
268  boost::str(boost::format("Trying to register a counter to category \"%1%\" with a name that "
269  "is already used within that category (name: \"%2%\")")
270  % parentCategoryName
271  % name));
272  }
273  }
274 
275  // Check that a counter set with the given (optional) UID is already registered
276  uint16_t counterSetUidValue = counterSetUid.has_value() ? counterSetUid.value() : 0;
277  if (counterSetUidValue > 0)
278  {
279  // Check that the (optional) counter set is already registered
280  if (!IsCounterSetRegistered(counterSetUidValue))
281  {
282  throw InvalidArgumentException(
283  boost::str(boost::format("Trying to connect a counter to a counter set that is "
284  "not registered (counter set UID: %1%)")
285  % counterSetUidValue));
286  }
287  }
288 
289  // Get the number of cores (this call may throw)
290  uint16_t deviceUidValue = deviceUid.has_value() ? deviceUid.value() : 0;
291  uint16_t deviceCores = GetNumberOfCores(numberOfCores, deviceUidValue);
292 
293  // Get the counter UIDs and calculate the max counter UID
294  std::vector<uint16_t> counterUids = GetNextCounterUids(uid, deviceCores);
295  ARMNN_ASSERT(!counterUids.empty());
296  uint16_t maxCounterUid = deviceCores <= 1 ? counterUids.front() : counterUids.back();
297 
298  // Get the counter units
299  const std::string unitsValue = units.has_value() ? units.value() : "";
300 
301  // Create the counter
302  CounterPtr counter = std::make_shared<Counter>(armnn::profiling::BACKEND_ID,
303  counterUids.front(),
304  maxCounterUid,
305  counterClass,
306  interpolation,
307  multiplier,
308  name,
309  description,
310  unitsValue,
311  deviceUidValue,
312  counterSetUidValue);
313  ARMNN_ASSERT(counter);
314 
315  // Get the raw counter pointer
316  const Counter* counterPtr = counter.get();
317  ARMNN_ASSERT(counterPtr);
318 
319  // Process multiple counters if necessary
320  for (uint16_t counterUid : counterUids)
321  {
322  // Connect the counter to the parent category
323  parentCategory->m_Counters.push_back(counterUid);
324 
325  // Register the counter
326  m_Counters.insert(std::make_pair(counterUid, counter));
327  }
328 
329  return counterPtr;
330 }
void IgnoreUnused(Ts &&...)
std::shared_ptr< Counter > CounterPtr
bool has_value() const noexcept
Definition: Optional.hpp:53
std::vector< uint16_t > GetNextCounterUids(uint16_t firstUid, uint16_t cores)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const Counter * GetCounter(uint16_t uid) const override
std::unique_ptr< Category > CategoryPtr
bool IsCounterSetRegistered(uint16_t counterSetUid) const

◆ RegisterCounterSet()

const CounterSet * RegisterCounterSet ( const std::string &  counterSetName,
uint16_t  count = 0,
const Optional< std::string > &  parentCategoryName = EmptyOptional() 
)
overridevirtual

Implements ICounterRegistry.

Definition at line 116 of file CounterDirectory.cpp.

References ARMNN_ASSERT, armnn::profiling::GetNextUid(), OptionalBase::has_value(), CounterDirectory::IsCounterSetRegistered(), and OptionalReferenceSwitch< IsReference, T >::value().

Referenced by BOOST_AUTO_TEST_CASE().

119 {
120  // Check that the given counter set name is valid
121  if (counterSetName.empty() ||
122  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterSetName))
123  {
124  throw InvalidArgumentException("Trying to register a counter set with an invalid name");
125  }
126 
127  // Check that a counter set with the given name is not already registered
128  if (IsCounterSetRegistered(counterSetName))
129  {
130  throw InvalidArgumentException(
131  boost::str(boost::format("Trying to register a counter set already registered (\"%1%\")")
132  % counterSetName));
133  }
134 
135  // Peek the next UID, do not get an actual valid UID just now as we don't want to waste a good UID in case
136  // the registration fails. We'll get a proper one once we're sure that the counter set can be registered
137  uint16_t counterSetUidPeek = GetNextUid(true);
138 
139  // Check that a category with the given (optional) parent category name is already registered
140  if (parentCategoryName.has_value())
141  {
142  // Get the (optional) parent category name
143  const std::string& parentCategoryNameValue = parentCategoryName.value();
144  if (parentCategoryNameValue.empty())
145  {
146  throw InvalidArgumentException(
147  boost::str(boost::format("Trying to connect a counter set (UID: %1%) to an invalid "
148  "parent category (name: \"%2%\")")
149  % counterSetUidPeek
150  % parentCategoryNameValue));
151  }
152 
153  // Check that the given parent category is already registered
154  auto it = FindCategory(parentCategoryNameValue);
155  if (it == m_Categories.end())
156  {
157  throw InvalidArgumentException(
158  boost::str(boost::format("Trying to connect a counter set (UID: %1%) to a parent category "
159  "that is not registered (name: \"%2%\")")
160  % counterSetUidPeek
161  % parentCategoryNameValue));
162  }
163  }
164 
165  // Get the counter set UID
166  uint16_t counterSetUid = GetNextUid();
167  ARMNN_ASSERT(counterSetUid == counterSetUidPeek);
168 
169  // Create the counter set
170  CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, count);
171  ARMNN_ASSERT(counterSet);
172 
173  // Get the raw counter set pointer
174  const CounterSet* counterSetPtr = counterSet.get();
175  ARMNN_ASSERT(counterSetPtr);
176 
177  // Register the counter set
178  m_CounterSets.insert(std::make_pair(counterSetUid, std::move(counterSet)));
179 
180  return counterSetPtr;
181 }
std::unique_ptr< CounterSet > CounterSetPtr
uint16_t GetNextUid(bool peekOnly)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
bool IsCounterSetRegistered(uint16_t counterSetUid) const

◆ RegisterDevice()

const Device * RegisterDevice ( const std::string &  deviceName,
uint16_t  cores = 0,
const Optional< std::string > &  parentCategoryName = EmptyOptional() 
)
overridevirtual

Implements ICounterRegistry.

Definition at line 54 of file CounterDirectory.cpp.

References ARMNN_ASSERT, armnn::profiling::GetNextUid(), OptionalBase::has_value(), CounterDirectory::IsDeviceRegistered(), and OptionalReferenceSwitch< IsReference, T >::value().

Referenced by BOOST_AUTO_TEST_CASE().

57 {
58  // Check that the given device name is valid
59  if (deviceName.empty() ||
60  !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName))
61  {
62  throw InvalidArgumentException("Trying to register a device with an invalid name");
63  }
64 
65  // Check that a device with the given name is not already registered
66  if (IsDeviceRegistered(deviceName))
67  {
68  throw InvalidArgumentException(
69  boost::str(boost::format("Trying to register a device already registered (\"%1%\")")
70  % deviceName));
71  }
72 
73  // Check that a category with the given (optional) parent category name is already registered
74  if (parentCategoryName.has_value())
75  {
76  // Get the (optional) parent category name
77  const std::string& parentCategoryNameValue = parentCategoryName.value();
78  if (parentCategoryNameValue.empty())
79  {
80  throw InvalidArgumentException(
81  boost::str(boost::format("Trying to connect a device (name: \"%1%\") to an invalid "
82  "parent category (name: \"%2%\")")
83  % deviceName
84  % parentCategoryNameValue));
85  }
86 
87  // Check that the given parent category is already registered
88  auto categoryIt = FindCategory(parentCategoryNameValue);
89  if (categoryIt == m_Categories.end())
90  {
91  throw InvalidArgumentException(
92  boost::str(boost::format("Trying to connect a device (name: \"%1%\") to a parent category that "
93  "is not registered (name: \"%2%\")")
94  % deviceName
95  % parentCategoryNameValue));
96  }
97  }
98 
99  // Get the device UID
100  uint16_t deviceUid = GetNextUid();
101 
102  // Create the device
103  DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
104  ARMNN_ASSERT(device);
105 
106  // Get the raw device pointer
107  const Device* devicePtr = device.get();
108  ARMNN_ASSERT(devicePtr);
109 
110  // Register the device
111  m_Devices.insert(std::make_pair(deviceUid, std::move(device)));
112 
113  return devicePtr;
114 }
std::unique_ptr< Device > DevicePtr
bool IsDeviceRegistered(uint16_t deviceUid) const
uint16_t GetNextUid(bool peekOnly)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

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