22 static const bool value = std::is_same<T, int>::value ||
23 std::is_same<T, float>::value ||
24 std::is_same<T, bool>::value ||
25 std::is_same<T, std::string>::value ||
26 std::is_same<T, const char*>::value;
36 explicit Var(
int i) : m_Vals(i), m_Type(VarTypes::Integer) {};
37 explicit Var(
float f) : m_Vals(f), m_Type(VarTypes::Float) {};
38 explicit Var(
bool b) : m_Vals(b), m_Type(VarTypes::
Boolean) {};
39 explicit Var(
const char* s) : m_Vals(s), m_Type(VarTypes::String) {};
40 explicit Var(std::string s) : m_Vals(s), m_Type(VarTypes::String) {};
43 template<
typename DisallowedType>
46 static_assert(CheckAllowed<DisallowedType>::value,
"Type is not allowed for Var<DisallowedType>.");
47 assert(
false &&
"Unreachable code");
52 : m_Type(other.m_Type)
56 case VarTypes::String:
58 new (&m_Vals.s) std::string(other.m_Vals.s);
63 DoOp(other, [](
auto& a,
auto& b)
76 if (m_Type == VarTypes::String)
81 m_Type = other.m_Type;
84 case VarTypes::String:
87 new (&m_Vals.s) std::string(other.m_Vals.s);
92 DoOp(other, [](
auto& a,
auto& b)
105 bool IsInt()
const {
return m_Type == VarTypes::Integer; }
106 bool IsFloat()
const {
return m_Type == VarTypes::Float; }
107 bool IsString()
const {
return m_Type == VarTypes::String; }
110 bool AsBool()
const { assert(IsBool());
return m_Vals.b; }
111 int AsInt()
const { assert(IsInt());
return m_Vals.i; }
112 float AsFloat()
const { assert(IsFloat());
return m_Vals.f; }
113 std::string
AsString()
const { assert(IsString());
return m_Vals.s; }
118 DoOp(*
this, [
this](
auto& a,
auto&)
124 template<
typename Func>
125 void DoOp(
const Var& other, Func func)
129 func(m_Vals.b, other.m_Vals.b);
131 else if (other.
IsInt())
133 func(m_Vals.i, other.m_Vals.i);
137 func(m_Vals.f, other.m_Vals.f);
141 func(m_Vals.s, other.m_Vals.s);
145 template<
typename Destructable>
146 void Destruct(Destructable& d)
148 if (std::is_destructible<Destructable>::value)
175 explicit Vals(
int i) : i(i) {};
176 explicit Vals(
float f) : f(f) {};
177 explicit Vals(
bool b) : b(b) {};
178 explicit Vals(
const char* s) : s(std::string(s)) {}
179 explicit Vals(std::string s) : s(s) {}
190 : m_Name(name), m_Value(value)
193 : m_Name(name), m_Value(value)
196 : m_Name(name), m_Value(value)
199 : m_Name(name), m_Value(value)
202 : m_Name(name), m_Value(value)
205 template<
typename DisallowedType>
209 static_assert(CheckAllowed<DisallowedType>::value,
"Type is not allowed for BackendOption.");
210 assert(
false &&
"Unreachable code");
219 std::string
GetName()
const {
return m_Name; }
228 : m_TargetBackend(backend)
232 : m_TargetBackend(backend)
243 m_Options.push_back(option);
248 m_Options.push_back(option);
260 std::vector<BackendOption> m_Options;
const BackendOption & GetOption(size_t idx) const
BackendOptions(BackendId backend, std::initializer_list< BackendOption > options)
Very basic type safe variant.
BackendOption(std::string name, bool value)
Var(const Var &other)
Copy Construct.
Copyright (c) 2020 ARM Limited.
BackendOptions(BackendId backend)
size_t GetOptionCount() const noexcept
void AddOption(BackendOption &&option)
Var & operator=(const Var &other)
Copy operator.
BackendOption(std::string name, int value)
std::string AsString() const
Var(DisallowedType)
Disallow implicit conversions from types not explicitly allowed below.
BackendOptions & operator=(const BackendOptions &other)=default
Struct for the users to pass backend specific options.
void AddOption(const BackendOption &option)
bool AsBool() const
Value getters.
std::string GetName() const
bool IsBool() const
Type getters.
BackendOption(std::string name, float value)
BackendOption(std::string name, const char *value)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
BackendOption(std::string, DisallowedType)
const BackendId & GetBackendId() const noexcept
BackendOption(std::string name, std::string value)