ArmNN
 21.02
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 443 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 579 of file ProfilingMocks.hpp.

579 { return m_Categories; }

◆ GetCategory()

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

Implements ICounterDirectory.

Definition at line 585 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

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

◆ GetCategoryCount()

uint16_t GetCategoryCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 573 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

573 { 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 614 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 576 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

576 { 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 582 of file ProfilingMocks.hpp.

582 { return m_Counters; }

◆ GetCounterSet()

const CounterSet* GetCounterSet ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 608 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetCounterSetCount()

uint16_t GetCounterSetCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 575 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

575 { 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 581 of file ProfilingMocks.hpp.

581 { return m_CounterSets; }

◆ GetDevice()

const Device* GetDevice ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 602 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetDeviceCount()

uint16_t GetDeviceCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 574 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

574 { 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 580 of file ProfilingMocks.hpp.

580 { return m_Devices; }

◆ RegisterCategory()

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

Definition at line 450 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE().

451  {
452  // Create the category
453  CategoryPtr category = std::make_unique<Category>(categoryName);
454  ARMNN_ASSERT(category);
455 
456  // Get the raw category pointer
457  const Category* categoryPtr = category.get();
458  ARMNN_ASSERT(categoryPtr);
459 
460  // Register the category
461  m_Categories.insert(std::move(category));
462 
463  return categoryPtr;
464  }
#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 507 of file ProfilingMocks.hpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

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

Referenced by BOOST_AUTO_TEST_CASE().

489  {
490  // Get the counter set UID
491  uint16_t counterSetUid = GetNextUid();
492 
493  // Create the counter set
494  CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, count);
495  ARMNN_ASSERT(counterSet);
496 
497  // Get the raw counter set pointer
498  const CounterSet* counterSetPtr = counterSet.get();
499  ARMNN_ASSERT(counterSetPtr);
500 
501  // Register the counter set
502  m_CounterSets.insert(std::make_pair(counterSetUid, std::move(counterSet)));
503 
504  return counterSetPtr;
505  }
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 466 of file ProfilingMocks.hpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

468  {
469  // Get the device UID
470  uint16_t deviceUid = GetNextUid();
471 
472  // Create the device
473  DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
474  ARMNN_ASSERT(device);
475 
476  // Get the raw device pointer
477  const Device* devicePtr = device.get();
478  ARMNN_ASSERT(devicePtr);
479 
480  // Register the device
481  m_Devices.insert(std::make_pair(deviceUid, std::move(device)));
482 
483  return devicePtr;
484  }
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: