diff options
author | janeil01 <jan.eilers@arm.com> | 2019-11-07 09:32:28 +0000 |
---|---|---|
committer | janeil01 <jan.eilers@arm.com> | 2019-11-07 13:32:47 +0000 |
commit | c4946c7addd65f032951dbf16fb824cdd67fd463 (patch) | |
tree | 4cca1b17024d55529cac74b809d08703e2541406 | |
parent | e63a026bd987e78bdaa5b94c3e53201b62011faa (diff) | |
download | armnn-c4946c7addd65f032951dbf16fb824cdd67fd463.tar.gz |
IVGCVSW-4102 Move ProfilingGuid to public interface
* Moved ProfilingGuid to Types.hpp
* Refactoring to enable ProfilingGuid
Signed-off-by: janeil01 <jan.eilers@arm.com>
Change-Id: Ibf77002d74e484f8a63ffd96aa14303c1f0d38ae
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/armnn/Types.hpp | 93 | ||||
-rw-r--r-- | src/profiling/IProfilingGuidGenerator.hpp | 2 | ||||
-rw-r--r-- | src/profiling/LabelsAndEventClasses.hpp | 3 | ||||
-rw-r--r-- | src/profiling/ProfilingGuid.hpp | 70 | ||||
-rw-r--r-- | src/profiling/TimelineUtilityMethods.hpp | 2 | ||||
-rw-r--r-- | src/profiling/test/ProfilingGuidTest.cpp | 2 |
7 files changed, 98 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b80430d7d..6856da63f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -485,7 +485,6 @@ list(APPEND armnn_sources src/profiling/ProfilingConnectionDumpToFileDecorator.hpp src/profiling/ProfilingConnectionFactory.cpp src/profiling/ProfilingConnectionFactory.hpp - src/profiling/ProfilingGuid.hpp src/profiling/ProfilingGuidGenerator.hpp src/profiling/ProfilingService.cpp src/profiling/ProfilingService.hpp diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp index 51162e6cf3..b2aa52edb2 100644 --- a/include/armnn/Types.hpp +++ b/include/armnn/Types.hpp @@ -7,6 +7,7 @@ #include <array> #include <functional> #include <memory> +#include <stdint.h> #include "BackendId.hpp" #include "Exceptions.hpp" @@ -219,4 +220,96 @@ class ITensorHandle; /// @param tensorHandle - TensorHandle for the input tensor to the Debug layer using DebugCallbackFunction = std::function<void(LayerGuid guid, unsigned int slotIndex, ITensorHandle* tensorHandle)>; + +namespace profiling +{ + +class ProfilingGuid +{ +public: + ProfilingGuid(uint64_t guid) : m_Guid(guid) {} + + operator uint64_t() const { return m_Guid; } + + bool operator==(const ProfilingGuid& other) const + { + return m_Guid == other.m_Guid; + } + + bool operator!=(const ProfilingGuid& other) const + { + return m_Guid != other.m_Guid; + } + + bool operator<(const ProfilingGuid& other) const + { + return m_Guid < other.m_Guid; + } + + bool operator<=(const ProfilingGuid& other) const + { + return m_Guid <= other.m_Guid; + } + + bool operator>(const ProfilingGuid& other) const + { + return m_Guid > other.m_Guid; + } + + bool operator>=(const ProfilingGuid& other) const + { + return m_Guid >= other.m_Guid; + } + +protected: + uint64_t m_Guid; +}; + +/// Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined. +struct ProfilingDynamicGuid : public ProfilingGuid +{ + using ProfilingGuid::ProfilingGuid; +}; + +struct ProfilingStaticGuid : public ProfilingGuid +{ + using ProfilingGuid::ProfilingGuid; +}; + +} // namespace profiling + } // namespace armnn + + +namespace std +{ +// make ProfilingGuid hashable +template<> +struct hash<armnn::profiling::ProfilingGuid> +{ + std::size_t operator()(armnn::profiling::ProfilingGuid const& guid) const noexcept + { + return hash<uint64_t>()(uint64_t(guid)); + } +}; + +// make ProfilingDynamicGuid hashable +template<> +struct hash<armnn::profiling::ProfilingDynamicGuid> +{ + std::size_t operator()(armnn::profiling::ProfilingDynamicGuid const& guid) const noexcept + { + return hash<uint64_t>()(uint64_t(guid)); + } +}; + +// make ProfilingStaticGuid hashable +template<> +struct hash<armnn::profiling::ProfilingStaticGuid> +{ + std::size_t operator()(armnn::profiling::ProfilingStaticGuid const& guid) const noexcept + { + return hash<uint64_t>()(uint64_t(guid)); + } +}; +} diff --git a/src/profiling/IProfilingGuidGenerator.hpp b/src/profiling/IProfilingGuidGenerator.hpp index 34ee9673b5..fb9f7401fb 100644 --- a/src/profiling/IProfilingGuidGenerator.hpp +++ b/src/profiling/IProfilingGuidGenerator.hpp @@ -5,7 +5,7 @@ #pragma once -#include "ProfilingGuid.hpp" +#include <armnn/Types.hpp> #include <string> diff --git a/src/profiling/LabelsAndEventClasses.hpp b/src/profiling/LabelsAndEventClasses.hpp index 07aeb81099..daa33addab 100644 --- a/src/profiling/LabelsAndEventClasses.hpp +++ b/src/profiling/LabelsAndEventClasses.hpp @@ -5,9 +5,10 @@ #pragma once -#include "ProfilingGuid.hpp" #include "ProfilingGuidGenerator.hpp" +#include <armnn/Types.hpp> + namespace armnn { diff --git a/src/profiling/ProfilingGuid.hpp b/src/profiling/ProfilingGuid.hpp deleted file mode 100644 index 5deee11783..0000000000 --- a/src/profiling/ProfilingGuid.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include <stdint.h> - -namespace armnn -{ - -namespace profiling -{ - -class ProfilingGuid -{ -public: - ProfilingGuid(uint64_t guid) : m_Guid(guid) {} - - operator uint64_t() const { return m_Guid; } - - bool operator==(const ProfilingGuid& other) const - { - return m_Guid == other.m_Guid; - } - - bool operator!=(const ProfilingGuid& other) const - { - return m_Guid != other.m_Guid; - } - - bool operator<(const ProfilingGuid& other) const - { - return m_Guid < other.m_Guid; - } - - bool operator<=(const ProfilingGuid& other) const - { - return m_Guid <= other.m_Guid; - } - - bool operator>(const ProfilingGuid& other) const - { - return m_Guid > other.m_Guid; - } - - bool operator>=(const ProfilingGuid& other) const - { - return m_Guid >= other.m_Guid; - } - -protected: - uint64_t m_Guid; -}; - -/// Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined. -struct ProfilingDynamicGuid : public ProfilingGuid -{ - using ProfilingGuid::ProfilingGuid; -}; - -struct ProfilingStaticGuid : public ProfilingGuid -{ - using ProfilingGuid::ProfilingGuid; -}; - -} // namespace profiling - -} // namespace armnn diff --git a/src/profiling/TimelineUtilityMethods.hpp b/src/profiling/TimelineUtilityMethods.hpp index 5bb4342197..51fceb95f4 100644 --- a/src/profiling/TimelineUtilityMethods.hpp +++ b/src/profiling/TimelineUtilityMethods.hpp @@ -6,7 +6,7 @@ #pragma once #include "ISendTimelinePacket.hpp" -#include "ProfilingGuid.hpp" +#include <armnn/Types.hpp> namespace armnn { diff --git a/src/profiling/test/ProfilingGuidTest.cpp b/src/profiling/test/ProfilingGuidTest.cpp index fa0143572b..f72cc1c452 100644 --- a/src/profiling/test/ProfilingGuidTest.cpp +++ b/src/profiling/test/ProfilingGuidTest.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT // -#include "ProfilingGuid.hpp" +#include <armnn/Types.hpp> #include <boost/test/unit_test.hpp> |