ArmNN
 24.08
NeonBackendModelContext.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 namespace
9 {
10 
11 bool ParseBool(const armnn::BackendOptions::Var& value, bool defaultValue)
12 {
13  if (value.IsBool())
14  {
15  return value.AsBool();
16  }
17  return defaultValue;
18 }
19 
20 unsigned int ParseUnsignedInt(const armnn::BackendOptions::Var& value, unsigned int defaultValue)
21 {
22  if (value.IsUnsignedInt())
23  {
24  return value.AsUnsignedInt();
25  }
26  return defaultValue;
27 }
28 
29 } // namespace anonymous
30 
31 namespace armnn
32 {
33 
35  : m_IsFastMathEnabled(false), m_NumberOfThreads(0)
36 {
37  if (!modelOptions.empty())
38  {
39  ParseOptions(modelOptions, "CpuAcc", [&](std::string name, const BackendOptions::Var& value)
40  {
41  if (name == "FastMathEnabled")
42  {
43  m_IsFastMathEnabled |= ParseBool(value, false);
44  }
45  if (name == "NumberOfThreads")
46  {
47  m_NumberOfThreads |= ParseUnsignedInt(value, 0);
48  }
49  });
50  }
51 }
52 
54 {
55  return m_IsFastMathEnabled;
56 }
57 
59 {
60  return m_NumberOfThreads;
61 }
62 
63 } // namespace armnn
armnn::NeonBackendModelContext::IsFastMathEnabled
bool IsFastMathEnabled() const
Definition: NeonBackendModelContext.cpp:53
armnn::BackendOptions::Var::IsUnsignedInt
bool IsUnsignedInt() const
Definition: BackendOptions.hpp:114
armnn::BackendOptions::Var::AsBool
bool AsBool() const
Value getters.
Definition: BackendOptions.hpp:119
armnn::BackendOptions::Var::AsUnsignedInt
unsigned int AsUnsignedInt() const
Definition: BackendOptions.hpp:121
armnn::ParseOptions
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
Definition: BackendOptions.hpp:297
armnn::BackendOptions::Var::IsBool
bool IsBool() const
Type getters.
Definition: BackendOptions.hpp:112
armnn::BackendOptions::Var
Very basic type safe variant.
Definition: BackendOptions.hpp:38
armnn::NeonBackendModelContext::NeonBackendModelContext
NeonBackendModelContext(const ModelOptions &modelOptions)
Definition: NeonBackendModelContext.cpp:34
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
NeonBackendModelContext.hpp
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::NeonBackendModelContext::GetNumberOfThreads
unsigned int GetNumberOfThreads() const
Definition: NeonBackendModelContext.cpp:58