ArmNN
 21.08
MockCounterDirectory Class Reference

#include <ProfilingMocks.hpp>

Inheritance diagram for MockCounterDirectory:
ICounterDirectory

Public Member Functions

 MockCounterDirectory ()=default
 
 ~MockCounterDirectory ()=default
 
const CategoryRegisterCategory (const std::string &categoryName)
 
const DeviceRegisterDevice (const std::string &deviceName, uint16_t cores=0)
 
const CounterSetRegisterCounterSet (const std::string &counterSetName, uint16_t count=0)
 
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 armnn::Optional< std::string > &units=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &numberOfCores=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &deviceUid=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &counterSetUid=armnn::EmptyOptional())
 
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
 
- Public Member Functions inherited from ICounterDirectory
virtual ~ICounterDirectory ()
 

Detailed Description

Definition at line 444 of file ProfilingMocks.hpp.

Constructor & Destructor Documentation

◆ MockCounterDirectory()

MockCounterDirectory ( )
default

◆ ~MockCounterDirectory()

~MockCounterDirectory ( )
default

Member Function Documentation

◆ GetCategories()

const Categories& GetCategories ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 580 of file ProfilingMocks.hpp.

580 { return m_Categories; }

◆ GetCategory()

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

Implements ICounterDirectory.

Definition at line 586 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

587  {
588  auto it = std::find_if(m_Categories.begin(), m_Categories.end(), [&name](const CategoryPtr& category)
589  {
590  ARMNN_ASSERT(category);
591 
592  return category->m_Name == name;
593  });
594 
595  if (it == m_Categories.end())
596  {
597  return nullptr;
598  }
599 
600  return it->get();
601  }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::unique_ptr< Category > CategoryPtr

◆ GetCategoryCount()

uint16_t GetCategoryCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 574 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

574 { 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:35

◆ GetCounter()

const Counter* GetCounter ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 615 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

616  {
617  IgnoreUnused(uid);
618  return nullptr; // Not used by the unit tests
619  }
void IgnoreUnused(Ts &&...)

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 577 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

577 { 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:35

◆ GetCounters()

const Counters& GetCounters ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 583 of file ProfilingMocks.hpp.

583 { return m_Counters; }

◆ GetCounterSet()

const CounterSet* GetCounterSet ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 609 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

610  {
611  IgnoreUnused(uid);
612  return nullptr; // Not used by the unit tests
613  }
void IgnoreUnused(Ts &&...)

◆ GetCounterSetCount()

uint16_t GetCounterSetCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 576 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

576 { 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:35

◆ GetCounterSets()

const CounterSets& GetCounterSets ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 582 of file ProfilingMocks.hpp.

582 { return m_CounterSets; }

◆ GetDevice()

const Device* GetDevice ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 603 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

604  {
605  IgnoreUnused(uid);
606  return nullptr; // Not used by the unit tests
607  }
void IgnoreUnused(Ts &&...)

◆ GetDeviceCount()

uint16_t GetDeviceCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 575 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

575 { 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:35

◆ GetDevices()

const Devices& GetDevices ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 581 of file ProfilingMocks.hpp.

581 { return m_Devices; }

◆ RegisterCategory()

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

Definition at line 451 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

452  {
453  // Create the category
454  CategoryPtr category = std::make_unique<Category>(categoryName);
455  ARMNN_ASSERT(category);
456 
457  // Get the raw category pointer
458  const Category* categoryPtr = category.get();
459  ARMNN_ASSERT(categoryPtr);
460 
461  // Register the category
462  m_Categories.insert(std::move(category));
463 
464  return categoryPtr;
465  }
#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 armnn::Optional< std::string > &  units = armnn::EmptyOptional(),
const armnn::Optional< uint16_t > &  numberOfCores = armnn::EmptyOptional(),
const armnn::Optional< uint16_t > &  deviceUid = armnn::EmptyOptional(),
const armnn::Optional< uint16_t > &  counterSetUid = armnn::EmptyOptional() 
)
inline

Definition at line 508 of file ProfilingMocks.hpp.

References ARMNN_ASSERT, armnn::profiling::GetNextCounterUids(), armnn::IgnoreUnused(), and Category::m_Counters.

520  {
521  IgnoreUnused(backendId);
522 
523  // Get the number of cores from the argument only
524  uint16_t deviceCores = numberOfCores.has_value() ? numberOfCores.value() : 0;
525 
526  // Get the device UID
527  uint16_t deviceUidValue = deviceUid.has_value() ? deviceUid.value() : 0;
528 
529  // Get the counter set UID
530  uint16_t counterSetUidValue = counterSetUid.has_value() ? counterSetUid.value() : 0;
531 
532  // Get the counter UIDs and calculate the max counter UID
533  std::vector<uint16_t> counterUids = GetNextCounterUids(uid, deviceCores);
534  ARMNN_ASSERT(!counterUids.empty());
535  uint16_t maxCounterUid = deviceCores <= 1 ? counterUids.front() : counterUids.back();
536 
537  // Get the counter units
538  const std::string unitsValue = units.has_value() ? units.value() : "";
539 
540  // Create the counter
541  CounterPtr counter = std::make_shared<Counter>(armnn::profiling::BACKEND_ID,
542  counterUids.front(),
543  maxCounterUid,
544  counterClass,
545  interpolation,
546  multiplier,
547  name,
548  description,
549  unitsValue,
550  deviceUidValue,
551  counterSetUidValue);
552  ARMNN_ASSERT(counter);
553 
554  // Get the raw counter pointer
555  const Counter* counterPtr = counter.get();
556  ARMNN_ASSERT(counterPtr);
557 
558  // Process multiple counters if necessary
559  for (uint16_t counterUid : counterUids)
560  {
561  // Connect the counter to the parent category
562  Category* parentCategory = const_cast<Category*>(GetCategory(parentCategoryName));
563  ARMNN_ASSERT(parentCategory);
564  parentCategory->m_Counters.push_back(counterUid);
565 
566  // Register the counter
567  m_Counters.insert(std::make_pair(counterUid, counter));
568  }
569 
570  return counterPtr;
571  }
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)
const Category * GetCategory(const std::string &name) const override
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ RegisterCounterSet()

const CounterSet* RegisterCounterSet ( const std::string &  counterSetName,
uint16_t  count = 0 
)
inline

Definition at line 487 of file ProfilingMocks.hpp.

References ARMNN_ASSERT, and armnn::profiling::GetNextUid().

490  {
491  // Get the counter set UID
492  uint16_t counterSetUid = GetNextUid();
493 
494  // Create the counter set
495  CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, count);
496  ARMNN_ASSERT(counterSet);
497 
498  // Get the raw counter set pointer
499  const CounterSet* counterSetPtr = counterSet.get();
500  ARMNN_ASSERT(counterSetPtr);
501 
502  // Register the counter set
503  m_CounterSets.insert(std::make_pair(counterSetUid, std::move(counterSet)));
504 
505  return counterSetPtr;
506  }
std::unique_ptr< CounterSet > CounterSetPtr
uint16_t GetNextUid(bool peekOnly)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ RegisterDevice()

const Device* RegisterDevice ( const std::string &  deviceName,
uint16_t  cores = 0 
)
inline

Definition at line 467 of file ProfilingMocks.hpp.

References ARMNN_ASSERT, and armnn::profiling::GetNextUid().

469  {
470  // Get the device UID
471  uint16_t deviceUid = GetNextUid();
472 
473  // Create the device
474  DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
475  ARMNN_ASSERT(device);
476 
477  // Get the raw device pointer
478  const Device* devicePtr = device.get();
479  ARMNN_ASSERT(devicePtr);
480 
481  // Register the device
482  m_Devices.insert(std::make_pair(deviceUid, std::move(device)));
483 
484  return devicePtr;
485  }
std::unique_ptr< Device > DevicePtr
uint16_t GetNextUid(bool peekOnly)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

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