ArmNN
 22.05.01
MockCounterDirectory Class Reference

#include <ProfilingMocks.hpp>

Inheritance diagram for MockCounterDirectory:

Public Member Functions

 MockCounterDirectory ()=default
 
 ~MockCounterDirectory ()=default
 
const Category * RegisterCategory (const std::string &categoryName)
 
const Device * RegisterDevice (const std::string &deviceName, uint16_t cores=0)
 
const CounterSet * RegisterCounterSet (const std::string &counterSetName, uint16_t count=0)
 
const Counter * RegisterCounter (const std::string &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 arm::pipe::Optional< std::string > &units=arm::pipe::EmptyOptional(), const arm::pipe::Optional< uint16_t > &numberOfCores=arm::pipe::EmptyOptional(), const arm::pipe::Optional< uint16_t > &deviceUid=arm::pipe::EmptyOptional(), const arm::pipe::Optional< uint16_t > &counterSetUid=arm::pipe::EmptyOptional())
 
uint16_t GetCategoryCount () const override
 
uint16_t GetDeviceCount () const override
 
uint16_t GetCounterSetCount () const override
 
uint16_t GetCounterCount () const override
 
const Categories & GetCategories () const override
 
const Devices & GetDevices () const override
 
const CounterSets & GetCounterSets () const override
 
const Counters & GetCounters () const override
 
const Category * GetCategory (const std::string &name) const override
 
const Device * GetDevice (uint16_t uid) const override
 
const CounterSet * GetCounterSet (uint16_t uid) const override
 
const Counter * GetCounter (uint16_t uid) const override
 

Detailed Description

Definition at line 447 of file ProfilingMocks.hpp.

Constructor & Destructor Documentation

◆ MockCounterDirectory()

MockCounterDirectory ( )
default

◆ ~MockCounterDirectory()

~MockCounterDirectory ( )
default

Member Function Documentation

◆ GetCategories()

const Categories& GetCategories ( ) const
inlineoverride

Definition at line 583 of file ProfilingMocks.hpp.

583 { return m_Categories; }

◆ GetCategory()

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

Definition at line 589 of file ProfilingMocks.hpp.

590  {
591  auto it = std::find_if(m_Categories.begin(), m_Categories.end(), [&name](const CategoryPtr& category)
592  {
593  ARM_PIPE_ASSERT(category);
594 
595  return category->m_Name == name;
596  });
597 
598  if (it == m_Categories.end())
599  {
600  return nullptr;
601  }
602 
603  return it->get();
604  }

◆ GetCategoryCount()

uint16_t GetCategoryCount ( ) const
inlineoverride

Definition at line 577 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

577 { return arm::pipe::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
inlineoverride

Definition at line 618 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

619  {
621  return nullptr; // Not used by the unit tests
622  }
void IgnoreUnused(Ts &&...)

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
inlineoverride

Definition at line 580 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

580 { return arm::pipe::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
inlineoverride

Definition at line 586 of file ProfilingMocks.hpp.

586 { return m_Counters; }

◆ GetCounterSet()

const CounterSet* GetCounterSet ( uint16_t  uid) const
inlineoverride

Definition at line 612 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetCounterSetCount()

uint16_t GetCounterSetCount ( ) const
inlineoverride

Definition at line 579 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

579 { return arm::pipe::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
inlineoverride

Definition at line 585 of file ProfilingMocks.hpp.

585 { return m_CounterSets; }

◆ GetDevice()

const Device* GetDevice ( uint16_t  uid) const
inlineoverride

Definition at line 606 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ GetDeviceCount()

uint16_t GetDeviceCount ( ) const
inlineoverride

Definition at line 578 of file ProfilingMocks.hpp.

References armnn::numeric_cast().

578 { return arm::pipe::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
inlineoverride

Definition at line 584 of file ProfilingMocks.hpp.

584 { return m_Devices; }

◆ RegisterCategory()

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

Definition at line 454 of file ProfilingMocks.hpp.

455  {
456  // Create the category
457  CategoryPtr category = std::make_unique<Category>(categoryName);
458  ARM_PIPE_ASSERT(category);
459 
460  // Get the raw category pointer
461  const Category* categoryPtr = category.get();
462  ARM_PIPE_ASSERT(categoryPtr);
463 
464  // Register the category
465  m_Categories.insert(std::move(category));
466 
467  return categoryPtr;
468  }

◆ RegisterCounter()

const Counter* RegisterCounter ( const std::string &  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 arm::pipe::Optional< std::string > &  units = arm::pipe::EmptyOptional(),
const arm::pipe::Optional< uint16_t > &  numberOfCores = arm::pipe::EmptyOptional(),
const arm::pipe::Optional< uint16_t > &  deviceUid = arm::pipe::EmptyOptional(),
const arm::pipe::Optional< uint16_t > &  counterSetUid = arm::pipe::EmptyOptional() 
)
inline

Definition at line 511 of file ProfilingMocks.hpp.

References armnn::IgnoreUnused().

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

◆ RegisterCounterSet()

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

Definition at line 490 of file ProfilingMocks.hpp.

493  {
494  // Get the counter set UID
495  uint16_t counterSetUid = GetNextUid();
496 
497  // Create the counter set
498  CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, count);
499  ARM_PIPE_ASSERT(counterSet);
500 
501  // Get the raw counter set pointer
502  const CounterSet* counterSetPtr = counterSet.get();
503  ARM_PIPE_ASSERT(counterSetPtr);
504 
505  // Register the counter set
506  m_CounterSets.insert(std::make_pair(counterSetUid, std::move(counterSet)));
507 
508  return counterSetPtr;
509  }

◆ RegisterDevice()

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

Definition at line 470 of file ProfilingMocks.hpp.

472  {
473  // Get the device UID
474  uint16_t deviceUid = GetNextUid();
475 
476  // Create the device
477  DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
478  ARM_PIPE_ASSERT(device);
479 
480  // Get the raw device pointer
481  const Device* devicePtr = device.get();
482  ARM_PIPE_ASSERT(devicePtr);
483 
484  // Register the device
485  m_Devices.insert(std::make_pair(deviceUid, std::move(device)));
486 
487  return devicePtr;
488  }

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