diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-08-22 12:56:34 +0100 |
---|---|---|
committer | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-08-23 11:16:39 +0100 |
commit | e898db9aaf07b4d0ea0242a1f3296f0192c42939 (patch) | |
tree | 017e040f9b18251f288f1f57ec270eac27ef85f6 /src/profiling/EncodeVersion.hpp | |
parent | 91e1d89ad35ad081a4d5995d541791fbefdb3060 (diff) | |
download | armnn-e898db9aaf07b4d0ea0242a1f3296f0192c42939.tar.gz |
IVGCVSW-3427 Create PacketVersionResolver class
* Create first version of PacketVersionResolver class
* Add basic unit test
* Move existing classes inside the armnn::profiling namespace
* Add utility methods for Version
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: If0ea0e1b9dea7fbfcd8b808e97b1e2aa91964dfa
Diffstat (limited to 'src/profiling/EncodeVersion.hpp')
-rw-r--r-- | src/profiling/EncodeVersion.hpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/profiling/EncodeVersion.hpp b/src/profiling/EncodeVersion.hpp index 257393329a..f66f7278a5 100644 --- a/src/profiling/EncodeVersion.hpp +++ b/src/profiling/EncodeVersion.hpp @@ -4,20 +4,21 @@ // #pragma once -#include <cstddef> +#include <cstdint> +#include <string> +#include <ostream> +#include <sstream> -namespace mlutil +namespace armnn { -namespace Impl +namespace profiling { - constexpr uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch) - { - return (major << 22) | (minor << 12) | patch; - } - -} // namespace Impl +constexpr inline uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch) +{ + return (major << 22) | (minor << 12) | patch; +} // Encodes a semantic version https://semver.org/ into a 32 bit integer in the following fashion // @@ -35,17 +36,35 @@ public: m_Patch = encodedValue & 4095; } - Version(uint32_t major, uint32_t minor, uint32_t patch) - : m_Major(major), m_Minor(minor), m_Patch(patch) {} + Version(uint32_t major, uint32_t minor, uint32_t patch) : + m_Major(major), + m_Minor(minor), + m_Patch(patch) + {} uint32_t GetEncodedValue() { - return mlutil::Impl::EncodeVersion(m_Major, m_Minor, m_Patch); + return EncodeVersion(m_Major, m_Minor, m_Patch); } - uint32_t GetMajor() {return m_Major;} - uint32_t GetMinor() {return m_Minor;} - uint32_t GetPatch() {return m_Patch;} + uint32_t GetMajor() { return m_Major; } + uint32_t GetMinor() { return m_Minor; } + uint32_t GetPatch() { return m_Patch; } + + bool operator==(const Version& other) const + { + return m_Major == other.m_Major && m_Minor == other.m_Minor && m_Patch == other.m_Patch; + } + + std::string ToString() const + { + constexpr char separator = '.'; + + std::stringstream stringStream; + stringStream << m_Major << separator << m_Minor << separator << m_Patch; + + return stringStream.str(); + } private: uint32_t m_Major; @@ -53,4 +72,12 @@ private: uint32_t m_Patch; }; -} // namespace mlutil +inline std::ostream& operator<<(std::ostream& os, const Version& version) +{ + os << version.ToString(); + return os; +} + +} // namespace profiling + +} // namespace armnn |