ArmNN
 21.05
ProfilingTestUtils.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "ProfilingUtils.hpp"
9 #include "Runtime.hpp"
10 
11 #include <armnn/BackendId.hpp>
12 #include <armnn/Optional.hpp>
13 #include <armnn/Types.hpp>
14 #include <BufferManager.hpp>
15 #include <ProfilingService.hpp>
16 
17 using namespace armnn;
18 using namespace armnn::profiling;
19 
20 const static uint32_t bodyHeaderSize = 6;
21 
23 
24 /// Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered
25 std::vector<BackendId> GetSuitableBackendRegistered();
26 
27 inline unsigned int OffsetToNextWord(unsigned int numberOfBytes);
28 
29 void VerifyTimelineHeaderBinary(const unsigned char* readableData,
30  unsigned int& offset,
31  uint32_t packetDataLength);
32 
34  const std::string& label,
35  const unsigned char* readableData,
36  unsigned int& offset);
37 
39  ProfilingGuid nameGuid,
40  const unsigned char* readableData,
41  unsigned int& offset);
42 
44  Optional<ProfilingGuid> relationshipGuid,
45  Optional<ProfilingGuid> headGuid,
46  Optional<ProfilingGuid> tailGuid,
47  Optional<ProfilingGuid> attributeGuid,
48  const unsigned char* readableData,
49  unsigned int& offset);
50 
52  const unsigned char* readableData,
53  unsigned int& offset);
54 
56  Optional<int> threadId,
57  Optional<ProfilingGuid> eventGuid,
58  const unsigned char* readableData,
59  unsigned int& offset);
60 
62 
63 bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput);
64 
65 namespace armnn
66 {
67 
68 namespace profiling
69 {
70 
72 {
73 public:
75  : m_ProfilingService(profilingService) {}
76  ~ProfilingServiceRuntimeHelper() = default;
77 
79  {
80  return GetBufferManager(m_ProfilingService);
81  }
83 
85  {
86  TransitionToState(m_ProfilingService, newState);
87  }
88 };
89 
90 } // namespace profiling
91 
92 } // namespace armnn
93 
ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
void ForceTransitionToState(ProfilingState newState)
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
uint32_t GetStreamMetaDataPacketSize()
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< BackendId > GetSuitableBackendRegistered()
Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered.
bool CompareOutput(std::vector< std::string > output, std::vector< std::string > expectedOutput)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< int > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingServiceRuntimeHelper(ProfilingService &profilingService)
armnn::profiling::ProfilingService & m_ProfilingService
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)