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> 18 struct IsMemorySource 19 { 20 static const bool value = false; 21 }; 22 23 template<> 24 struct IsMemorySource<MemorySource> 25 { 26 static const bool value = true; 27 }; 28 29 template <typename Arg, typename std::enable_if<IsMemorySource<Arg>::value>::type* = nullptr> Combine(Arg sourceA,Arg sourceB)30MemorySourceFlags 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> Combine(Arg source,Args...rest)36MemorySourceFlags Combine(Arg source, Args... rest) 37 { 38 return static_cast<MemorySourceFlags>(source) | Combine(rest...); 39 } 40 CheckFlag(MemorySourceFlags flags,MemorySource source)41inline bool CheckFlag(MemorySourceFlags flags, MemorySource source) 42 { 43 return (static_cast<MemorySourceFlags>(source) & flags) != 0; 44 } 45 46 } //namespace armnn