ArmNN
 20.05
ProfilingMocks.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <Holder.hpp>
10 #include <ProfilingService.hpp>
12 #include <ProfilingUtils.hpp>
13 #include <SendCounterPacket.hpp>
14 #include <SendThread.hpp>
15 
16 #include <armnn/Exceptions.hpp>
17 #include <armnn/Optional.hpp>
18 #include <armnn/Conversion.hpp>
19 #include <armnn/utility/Assert.hpp>
21 
22 #include <boost/numeric/conversion/cast.hpp>
23 
24 #include <atomic>
25 #include <condition_variable>
26 #include <mutex>
27 #include <thread>
28 
29 namespace armnn
30 {
31 
32 namespace profiling
33 {
34 
36 {
37 public:
39  : m_IsOpen(true)
40  , m_WrittenData()
41  , m_Packet()
42  {}
43 
44  enum class PacketType
45  {
56  Unknown
57  };
58 
59  bool IsOpen() const override
60  {
61  std::lock_guard<std::mutex> lock(m_Mutex);
62 
63  return m_IsOpen;
64  }
65 
66  void Close() override
67  {
68  std::lock_guard<std::mutex> lock(m_Mutex);
69 
70  m_IsOpen = false;
71  }
72 
73  bool WritePacket(const unsigned char* buffer, uint32_t length) override
74  {
75  if (buffer == nullptr || length == 0)
76  {
77  return false;
78  }
79 
80  uint32_t header = ReadUint32(buffer, 0);
81 
82  uint32_t packetFamily = (header >> 26);
83  uint32_t packetId = ((header >> 16) & 1023);
84 
85  PacketType packetType;
86 
87  switch (packetFamily)
88  {
89  case 0:
90  packetType = packetId < 8 ? PacketType(packetId) : PacketType::Unknown;
91  break;
92  case 1:
93  packetType = packetId == 0 ? PacketType::TimelineMessageDirectory : PacketType::Unknown;
94  break;
95  case 3:
96  packetType = packetId == 0 ? PacketType::PeriodicCounterCapture : PacketType::Unknown;
97  break;
98  default:
99  packetType = PacketType::Unknown;
100  }
101 
102  std::lock_guard<std::mutex> lock(m_Mutex);
103 
104  m_WrittenData.push_back({ packetType, length });
105  return true;
106  }
107 
108  long CheckForPacket(const std::pair<PacketType, uint32_t> packetInfo)
109  {
110  std::lock_guard<std::mutex> lock(m_Mutex);
111 
112  if(packetInfo.second != 0)
113  {
114  return std::count(m_WrittenData.begin(), m_WrittenData.end(), packetInfo);
115  }
116  else
117  {
118  return std::count_if(m_WrittenData.begin(), m_WrittenData.end(),
119  [&packetInfo](const std::pair<PacketType, uint32_t> pair) { return packetInfo.first == pair.first; });
120  }
121  }
122 
123  bool WritePacket(Packet&& packet)
124  {
125  std::lock_guard<std::mutex> lock(m_Mutex);
126 
127  m_Packet = std::move(packet);
128  return true;
129  }
130 
131  Packet ReadPacket(uint32_t timeout) override
132  {
133  IgnoreUnused(timeout);
134 
135  // Simulate a delay in the reading process. The default timeout is way too long.
136  std::this_thread::sleep_for(std::chrono::milliseconds(5));
137  std::lock_guard<std::mutex> lock(m_Mutex);
138  return std::move(m_Packet);
139  }
140 
141  unsigned long GetWrittenDataSize()
142  {
143  std::lock_guard<std::mutex> lock(m_Mutex);
144 
145  return m_WrittenData.size();
146  }
147 
148  void Clear()
149  {
150  std::lock_guard<std::mutex> lock(m_Mutex);
151 
152  m_WrittenData.clear();
153  }
154 
155 private:
156  bool m_IsOpen;
157  std::vector<std::pair<PacketType, uint32_t>> m_WrittenData;
158  Packet m_Packet;
159  mutable std::mutex m_Mutex;
160 };
161 
163 {
164 public:
166  {
167  IgnoreUnused(options);
168  return std::make_unique<MockProfilingConnection>();
169  }
170 };
171 
173 {
174 public:
175  MockPacketBuffer(unsigned int maxSize)
176  : m_MaxSize(maxSize)
177  , m_Size(0)
178  , m_Data(std::make_unique<unsigned char[]>(m_MaxSize))
179  {}
180 
182 
183  const unsigned char* GetReadableData() const override { return m_Data.get(); }
184 
185  unsigned int GetSize() const override { return m_Size; }
186 
187  void MarkRead() override { m_Size = 0; }
188 
189  void Commit(unsigned int size) override { m_Size = size; }
190 
191  void Release() override { m_Size = 0; }
192 
193  unsigned char* GetWritableData() override { return m_Data.get(); }
194 
195 private:
196  unsigned int m_MaxSize;
197  unsigned int m_Size;
198  std::unique_ptr<unsigned char[]> m_Data;
199 };
200 
202 {
203 public:
204  MockBufferManager(unsigned int size)
205  : m_BufferSize(size),
206  m_Buffer(std::make_unique<MockPacketBuffer>(size)) {}
207 
209 
210  IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int& reservedSize) override
211  {
212  if (requestedSize > m_BufferSize)
213  {
214  reservedSize = m_BufferSize;
215  }
216  else
217  {
218  reservedSize = requestedSize;
219  }
220 
221  return std::move(m_Buffer);
222  }
223 
224  void Commit(IPacketBufferPtr& packetBuffer, unsigned int size, bool notifyConsumer = true) override
225  {
226  packetBuffer->Commit(size);
227  m_Buffer = std::move(packetBuffer);
228 
229  if (notifyConsumer)
230  {
231  FlushReadList();
232  }
233  }
234 
236  {
237  return std::move(m_Buffer);
238  }
239 
240  void Release(IPacketBufferPtr& packetBuffer) override
241  {
242  packetBuffer->Release();
243  m_Buffer = std::move(packetBuffer);
244  }
245 
246  void MarkRead(IPacketBufferPtr& packetBuffer) override
247  {
248  packetBuffer->MarkRead();
249  m_Buffer = std::move(packetBuffer);
250  }
251 
252  void SetConsumer(IConsumer* consumer) override
253  {
254  if (consumer != nullptr)
255  {
256  m_Consumer = consumer;
257  }
258  }
259 
260  void FlushReadList() override
261  {
262  // notify consumer that packet is ready to read
263  if (m_Consumer != nullptr)
264  {
265  m_Consumer->SetReadyToRead();
266  }
267  }
268 
269 private:
270  unsigned int m_BufferSize;
271  IPacketBufferPtr m_Buffer;
272  IConsumer* m_Consumer = nullptr;
273 };
274 
276 {
277 public:
278  MockStreamCounterBuffer(unsigned int maxBufferSize = 4096)
279  : m_MaxBufferSize(maxBufferSize)
280  , m_BufferList()
281  , m_CommittedSize(0)
282  , m_ReadableSize(0)
283  , m_ReadSize(0)
284  {}
286 
287  IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int& reservedSize) override
288  {
289  std::lock_guard<std::mutex> lock(m_Mutex);
290 
291  reservedSize = 0;
292  if (requestedSize > m_MaxBufferSize)
293  {
294  throw armnn::InvalidArgumentException("The maximum buffer size that can be requested is [" +
295  std::to_string(m_MaxBufferSize) + "] bytes");
296  }
297  reservedSize = requestedSize;
298  return std::make_unique<MockPacketBuffer>(requestedSize);
299  }
300 
301  void Commit(IPacketBufferPtr& packetBuffer, unsigned int size, bool notifyConsumer = true) override
302  {
303  std::lock_guard<std::mutex> lock(m_Mutex);
304 
305  packetBuffer->Commit(size);
306  m_BufferList.push_back(std::move(packetBuffer));
307  m_CommittedSize += size;
308 
309  if (notifyConsumer)
310  {
311  FlushReadList();
312  }
313  }
314 
315  void Release(IPacketBufferPtr& packetBuffer) override
316  {
317  std::lock_guard<std::mutex> lock(m_Mutex);
318 
319  packetBuffer->Release();
320  }
321 
323  {
324  std::lock_guard<std::mutex> lock(m_Mutex);
325 
326  if (m_BufferList.empty())
327  {
328  return nullptr;
329  }
330  IPacketBufferPtr buffer = std::move(m_BufferList.back());
331  m_BufferList.pop_back();
332  m_ReadableSize += buffer->GetSize();
333  return buffer;
334  }
335 
336  void MarkRead(IPacketBufferPtr& packetBuffer) override
337  {
338  std::lock_guard<std::mutex> lock(m_Mutex);
339 
340  m_ReadSize += packetBuffer->GetSize();
341  packetBuffer->MarkRead();
342  }
343 
344  void SetConsumer(IConsumer* consumer) override
345  {
346  if (consumer != nullptr)
347  {
348  m_Consumer = consumer;
349  }
350  }
351 
352  void FlushReadList() override
353  {
354  // notify consumer that packet is ready to read
355  if (m_Consumer != nullptr)
356  {
357  m_Consumer->SetReadyToRead();
358  }
359  }
360 
361  unsigned int GetCommittedSize() const { return m_CommittedSize; }
362  unsigned int GetReadableSize() const { return m_ReadableSize; }
363  unsigned int GetReadSize() const { return m_ReadSize; }
364 
365 private:
366  // The maximum buffer size when creating a new buffer
367  unsigned int m_MaxBufferSize;
368 
369  // A list of buffers
370  std::vector<IPacketBufferPtr> m_BufferList;
371 
372  // The mutex to synchronize this mock's methods
373  std::mutex m_Mutex;
374 
375  // The total size of the buffers that has been committed for reading
376  unsigned int m_CommittedSize;
377 
378  // The total size of the buffers that can be read
379  unsigned int m_ReadableSize;
380 
381  // The total size of the buffers that has already been read
382  unsigned int m_ReadSize;
383 
384  // Consumer thread to notify packet is ready to read
385  IConsumer* m_Consumer = nullptr;
386 };
387 
389 {
390 public:
391  MockSendCounterPacket(IBufferManager& sendBuffer) : m_BufferManager(sendBuffer) {}
392 
393  void SendStreamMetaDataPacket() override
394  {
395  std::string message("SendStreamMetaDataPacket");
396  unsigned int reserved = 0;
397  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
398  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
399  m_BufferManager.Commit(buffer, reserved, false);
400  }
401 
402  void SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory) override
403  {
404  IgnoreUnused(counterDirectory);
405 
406  std::string message("SendCounterDirectoryPacket");
407  unsigned int reserved = 0;
408  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
409  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
410  m_BufferManager.Commit(buffer, reserved);
411  }
412 
413  void SendPeriodicCounterCapturePacket(uint64_t timestamp,
414  const std::vector<CounterValue>& values) override
415  {
416  IgnoreUnused(timestamp, values);
417 
418  std::string message("SendPeriodicCounterCapturePacket");
419  unsigned int reserved = 0;
420  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
421  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
422  m_BufferManager.Commit(buffer, reserved);
423  }
424 
425  void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
426  const std::vector<uint16_t>& selectedCounterIds) override
427  {
428  IgnoreUnused(capturePeriod, selectedCounterIds);
429 
430  std::string message("SendPeriodicCounterSelectionPacket");
431  unsigned int reserved = 0;
432  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
433  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
434  m_BufferManager.Commit(buffer, reserved);
435  }
436 
437 private:
438  IBufferManager& m_BufferManager;
439 };
440 
442 {
443 public:
444  MockCounterDirectory() = default;
445  ~MockCounterDirectory() = default;
446 
447  // Register profiling objects
448  const Category* RegisterCategory(const std::string& categoryName)
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  }
463 
464  const Device* RegisterDevice(const std::string& deviceName,
465  uint16_t cores = 0)
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  }
483 
485  const std::string& counterSetName,
486  uint16_t count = 0)
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  }
504 
505  const Counter* RegisterCounter(const BackendId& backendId,
506  const uint16_t uid,
507  const std::string& parentCategoryName,
508  uint16_t counterClass,
509  uint16_t interpolation,
510  double multiplier,
511  const std::string& name,
512  const std::string& description,
514  const armnn::Optional<uint16_t>& numberOfCores = armnn::EmptyOptional(),
515  const armnn::Optional<uint16_t>& deviceUid = armnn::EmptyOptional(),
516  const armnn::Optional<uint16_t>& counterSetUid = armnn::EmptyOptional())
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  }
569 
570  // Getters for counts
571  uint16_t GetCategoryCount() const override { return boost::numeric_cast<uint16_t>(m_Categories.size()); }
572  uint16_t GetDeviceCount() const override { return boost::numeric_cast<uint16_t>(m_Devices.size()); }
573  uint16_t GetCounterSetCount() const override { return boost::numeric_cast<uint16_t>(m_CounterSets.size()); }
574  uint16_t GetCounterCount() const override { return boost::numeric_cast<uint16_t>(m_Counters.size()); }
575 
576  // Getters for collections
577  const Categories& GetCategories() const override { return m_Categories; }
578  const Devices& GetDevices() const override { return m_Devices; }
579  const CounterSets& GetCounterSets() const override { return m_CounterSets; }
580  const Counters& GetCounters() const override { return m_Counters; }
581 
582  // Getters for profiling objects
583  const Category* GetCategory(const std::string& name) const override
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  }
599 
600  const Device* GetDevice(uint16_t uid) const override
601  {
602  IgnoreUnused(uid);
603  return nullptr; // Not used by the unit tests
604  }
605 
606  const CounterSet* GetCounterSet(uint16_t uid) const override
607  {
608  IgnoreUnused(uid);
609  return nullptr; // Not used by the unit tests
610  }
611 
612  const Counter* GetCounter(uint16_t uid) const override
613  {
614  IgnoreUnused(uid);
615  return nullptr; // Not used by the unit tests
616  }
617 
618 private:
619  Categories m_Categories;
620  Devices m_Devices;
621  CounterSets m_CounterSets;
622  Counters m_Counters;
623 };
624 
626 {
627 public:
629  bool isProfilingEnabled,
630  const CaptureData& captureData) :
631  m_SendCounterPacket(mockBufferManager),
632  m_IsProfilingEnabled(isProfilingEnabled),
633  m_CaptureData(captureData)
634  {}
635 
636  /// Return the next random Guid in the sequence
638  {
639  return m_GuidGenerator.NextGuid();
640  }
641 
642  /// Create a ProfilingStaticGuid based on a hash of the string
643  ProfilingStaticGuid GenerateStaticId(const std::string& str) override
644  {
645  return m_GuidGenerator.GenerateStaticId(str);
646  }
647 
648  std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const override
649  {
650  return nullptr;
651  }
652 
653  const ICounterMappings& GetCounterMappings() const override
654  {
655  return m_CounterMapping;
656  }
657 
659  {
660  return m_SendCounterPacket;
661  }
662 
663  bool IsProfilingEnabled() const override
664  {
665  return m_IsProfilingEnabled;
666  }
667 
669  {
670  CaptureData copy(m_CaptureData);
671  return copy;
672  }
673 
674  void RegisterMapping(uint16_t globalCounterId,
675  uint16_t backendCounterId,
676  const armnn::BackendId& backendId)
677  {
678  m_CounterMapping.RegisterMapping(globalCounterId, backendCounterId, backendId);
679  }
680 
681  void Reset()
682  {
683  m_CounterMapping.Reset();
684  }
685 
686 private:
687  ProfilingGuidGenerator m_GuidGenerator;
688  CounterIdMap m_CounterMapping;
689  SendCounterPacket m_SendCounterPacket;
690  bool m_IsProfilingEnabled;
691  CaptureData m_CaptureData;
692 };
693 
694 } // namespace profiling
695 
696 } // namespace armnn
const CounterSet * GetCounterSet(uint16_t uid) const override
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) override
MockStreamCounterBuffer(unsigned int maxBufferSize=4096)
ISendCounterPacket & GetSendCounterPacket() override
const Categories & GetCategories() const override
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override
const Devices & GetDevices() const override
void SetConsumer(IConsumer *consumer) override
IPacketBufferPtr GetReadableBuffer() override
std::unordered_map< uint16_t, CounterPtr > Counters
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:296
std::unique_ptr< Device > DevicePtr
std::unique_ptr< CounterSet > CounterSetPtr
std::unique_ptr< IProfilingConnection > IProfilingConnectionPtr
Copyright (c) 2020 ARM Limited.
void IgnoreUnused(Ts &&...)
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
void Release(IPacketBufferPtr &packetBuffer) override
std::unordered_map< uint16_t, CounterSetPtr > CounterSets
uint16_t GetNextUid(bool peekOnly)
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())
void MarkRead(IPacketBufferPtr &packetBuffer) override
uint16_t GetCategoryCount() const override
unsigned char * GetWritableData() override
void MarkRead(IPacketBufferPtr &packetBuffer) override
const unsigned char * GetReadableData() const override
std::shared_ptr< Counter > CounterPtr
const CounterSets & GetCounterSets() const override
const ICounterMappings & GetCounterMappings() const override
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0)
std::vector< uint16_t > GetNextCounterUids(uint16_t firstUid, uint16_t cores)
IPacketBufferPtr GetReadableBuffer() override
const Category * GetCategory(const std::string &name) const override
unsigned int GetSize() const override
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
const Category * RegisterCategory(const std::string &categoryName)
const Counter * GetCounter(uint16_t uid) const override
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const std::vector< CounterValue > &values) override
uint16_t GetCounterCount() const override
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint16_t GetCounterSetCount() const override
std::unordered_set< CategoryPtr > Categories
std::vector< uint16_t > m_Counters
Packet ReadPacket(uint32_t timeout) override
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
const Counters & GetCounters() const override
MockPacketBuffer(unsigned int maxSize)
std::unique_ptr< Category > CategoryPtr
bool WritePacket(const unsigned char *buffer, uint32_t length) override
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0)
long CheckForPacket(const std::pair< PacketType, uint32_t > packetInfo)
const Device * GetDevice(uint16_t uid) const override
std::unordered_map< uint16_t, DevicePtr > Devices
void SetConsumer(IConsumer *consumer) override
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
IProfilingConnectionPtr GetProfilingConnection(const ExternalProfilingOptions &options) const override
MockProfilingService(MockBufferManager &mockBufferManager, bool isProfilingEnabled, const CaptureData &captureData)
void Release(IPacketBufferPtr &packetBuffer) override
std::unique_ptr< IPacketBuffer > IPacketBufferPtr
DataLayout::NCHW DataLayout::NCHW DataLayout::NHWC DataLayout::NHWC true
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) override
MockSendCounterPacket(IBufferManager &sendBuffer)
uint16_t GetDeviceCount() const override
void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId &backendId)
void Commit(unsigned int size) override