2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
8 #include <armnn/BackendId.hpp>
13 #include <unordered_set>
14 #include <unordered_map>
22 // Forward declarations
28 // Profiling objects smart pointer types
29 using CategoryPtr = std::unique_ptr<Category>;
30 using DevicePtr = std::unique_ptr<Device>;
31 using CounterSetPtr = std::unique_ptr<CounterSet>;
32 using CounterPtr = std::shared_ptr<Counter>;
34 // Profiling objects collection types
35 using Categories = std::unordered_set<CategoryPtr>;
36 using Devices = std::unordered_map<uint16_t, DevicePtr>;
37 using CounterSets = std::unordered_map<uint16_t, CounterSetPtr>;
38 using Counters = std::unordered_map<uint16_t, CounterPtr>;
40 // Profiling objects collection iterator types
41 using CategoriesIt = Categories::const_iterator;
42 using DevicesIt = Devices::const_iterator;
43 using CounterSetsIt = CounterSets::const_iterator;
44 using CountersIt = Counters::const_iterator;
50 Category(const std::string& name)
58 std::vector<uint16_t> m_Counters; // The UIDs of the counters associated with this category
65 Device(uint16_t deviceUid, const std::string& name, uint16_t cores)
77 class CounterSet final
81 CounterSet(uint16_t counterSetUid, const std::string& name, uint16_t count)
82 : m_Uid(counterSetUid)
97 Counter(BackendId backendId,
99 uint16_t maxCounterUid,
100 uint16_t counterClass,
101 uint16_t interpolation,
103 const std::string& name,
104 const std::string& description,
105 const std::string& units,
107 uint16_t counterSetUid)
108 : m_BackendId(backendId)
110 , m_MaxCounterUid(maxCounterUid)
111 , m_Class(counterClass)
112 , m_Interpolation(interpolation)
113 , m_Multiplier(multiplier)
115 , m_Description(description)
117 , m_DeviceUid(deviceUid)
118 , m_CounterSetUid(counterSetUid)
122 BackendId m_BackendId;
124 uint16_t m_MaxCounterUid;
126 uint16_t m_Interpolation;
129 std::string m_Description;
130 std::string m_Units; // Optional, leave empty if the counter does not need units
133 uint16_t m_DeviceUid; // Optional, set to zero if the counter is not associated with a device
134 uint16_t m_CounterSetUid; // Optional, set to zero if the counter is not associated with a counter set
137 class ICounterDirectory
140 virtual ~ICounterDirectory() {}
142 // Getters for counts
143 virtual uint16_t GetCategoryCount() const = 0;
144 virtual uint16_t GetDeviceCount() const = 0;
145 virtual uint16_t GetCounterSetCount() const = 0;
146 virtual uint16_t GetCounterCount() const = 0;
148 // Getters for collections
149 virtual const Categories& GetCategories() const = 0;
150 virtual const Devices& GetDevices() const = 0;
151 virtual const CounterSets& GetCounterSets() const = 0;
152 virtual const Counters& GetCounters() const = 0;
154 // Getters for profiling objects
155 virtual const Category* GetCategory(const std::string& name) const = 0;
156 virtual const Device* GetDevice(uint16_t uid) const = 0;
157 virtual const CounterSet* GetCounterSet(uint16_t uid) const = 0;
158 virtual const Counter* GetCounter(uint16_t uid) const = 0;
161 } // namespace profiling