ArmNN
 20.05
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 441 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 577 of file ProfilingMocks.hpp.

577 { return m_Categories; }

◆ GetCategory()

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

Implements ICounterDirectory.

Definition at line 583 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

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

◆ GetCategoryCount()

uint16_t GetCategoryCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 571 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

571 { return boost::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
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 612 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 574 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

574 { return boost::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()

const Counters& GetCounters ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 580 of file ProfilingMocks.hpp.

580 { return m_Counters; }

◆ GetCounterSet()

const CounterSet* GetCounterSet ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 606 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetCounterSetCount()

uint16_t GetCounterSetCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 573 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

573 { return boost::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 579 of file ProfilingMocks.hpp.

579 { return m_CounterSets; }

◆ GetDevice()

const Device* GetDevice ( uint16_t  uid) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 600 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetDeviceCount()

uint16_t GetDeviceCount ( ) const
inlineoverridevirtual

Implements ICounterDirectory.

Definition at line 572 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

572 { return boost::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 578 of file ProfilingMocks.hpp.

578 { return m_Devices; }

◆ RegisterCategory()

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

Definition at line 448 of file ProfilingMocks.hpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE().

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

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

Referenced by BOOST_AUTO_TEST_CASE().

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

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

Referenced by BOOST_AUTO_TEST_CASE().

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

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

Referenced by BOOST_AUTO_TEST_CASE().

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