ArmNN
 20.02
ProfilingGuidGenerator.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 
10 #include <functional>
11 
12 namespace armnn
13 {
14 
15 namespace profiling
16 {
17 
19 {
20 public:
21  /// Construct a generator with the default address space static/dynamic partitioning
22  ProfilingGuidGenerator() : m_Sequence(0) {}
23 
24  /// Return the next random Guid in the sequence
25  inline ProfilingDynamicGuid NextGuid() override
26  {
27  ProfilingDynamicGuid guid(m_Sequence);
28  m_Sequence++;
29  if (m_Sequence >= MIN_STATIC_GUID)
30  {
31  // Reset the sequence to 0 when it reaches the upper bound of dynamic guid
32  m_Sequence = 0;
33  }
34  return guid;
35  }
36 
37  /// Create a ProfilingStaticGuid based on a hash of the string
38  inline ProfilingStaticGuid GenerateStaticId(const std::string& str) override
39  {
40  uint64_t staticHash = m_Hash(str) | MIN_STATIC_GUID;
41  return ProfilingStaticGuid(staticHash);
42  }
43 
44 private:
45  uint64_t m_Sequence;
46  std::hash<std::string> m_Hash;
47 };
48 
49 } // namespace profiling
50 
51 } // namespace armnn
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294
Copyright (c) 2020 ARM Limited.
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.
ProfilingGuidGenerator()
Construct a generator with the default address space static/dynamic partitioning. ...
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.