ArmNN
 24.08
MemorySources.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <armnn/Types.hpp>
9 
10 #include <type_traits>
11 
12 namespace armnn
13 {
14 
15 using MemorySourceFlags = unsigned int;
16 
17 template<typename T>
19 {
20  static const bool value = false;
21 };
22 
23 template<>
25 {
26  static const bool value = true;
27 };
28 
29 template <typename Arg, typename std::enable_if<IsMemorySource<Arg>::value>::type* = nullptr>
30 MemorySourceFlags Combine(Arg sourceA, Arg sourceB)
31 {
32  return static_cast<MemorySourceFlags>(sourceA) | static_cast<MemorySourceFlags>(sourceB);
33 }
34 
35 template <typename Arg, typename ... Args, typename std::enable_if<IsMemorySource<Arg>::value>::type* = nullptr>
36 MemorySourceFlags Combine(Arg source, Args... rest)
37 {
38  return static_cast<MemorySourceFlags>(source) | Combine(rest...);
39 }
40 
41 inline bool CheckFlag(MemorySourceFlags flags, MemorySource source)
42 {
43  return (static_cast<MemorySourceFlags>(source) & flags) != 0;
44 }
45 
46 } //namespace armnn
armnn::Combine
MemorySourceFlags Combine(Arg sourceA, Arg sourceB)
Definition: MemorySources.hpp:30
armnn::IsMemorySource
Definition: MemorySources.hpp:18
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::CheckFlag
bool CheckFlag(MemorySourceFlags flags, MemorySource source)
Definition: MemorySources.hpp:41
armnn::MemorySource
MemorySource
Define the Memory Source to reduce copies.
Definition: Types.hpp:244
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnn::IsMemorySource::value
static const bool value
Definition: MemorySources.hpp:20