ArmNN
 22.02
OptimizerOptions Struct Reference

ArmNN performs an optimization on each model/network before it gets loaded for execution. More...

#include <INetwork.hpp>

Public Member Functions

 OptimizerOptions ()
 
 OptimizerOptions (bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16, bool importEnabled, ModelOptions modelOptions={})
 
 OptimizerOptions (bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16=false, ShapeInferenceMethod shapeInferenceMethod=armnn::ShapeInferenceMethod::ValidateOnly, bool importEnabled=false, ModelOptions modelOptions={})
 
const std::string ToString () const
 

Public Attributes

bool m_ReduceFp32ToFp16
 Reduces all Fp32 operators in the model to Fp16 for faster processing. More...
 
bool m_Debug
 
bool m_ReduceFp32ToBf16
 Reduces all Fp32 operators in the model to Bf16 for faster processing. More...
 
ShapeInferenceMethod m_shapeInferenceMethod
 
bool m_ImportEnabled
 
ModelOptions m_ModelOptions
 
bool m_ProfilingEnabled
 

Detailed Description

ArmNN performs an optimization on each model/network before it gets loaded for execution.

OptimizerOptions provides a set of features that allows the user to customize this optimization on a per model basis.

Examples:
CustomMemoryAllocatorSample.cpp.

Definition at line 137 of file INetwork.hpp.

Constructor & Destructor Documentation

◆ OptimizerOptions() [1/3]

OptimizerOptions ( )
inline

Definition at line 139 of file INetwork.hpp.

140  : m_ReduceFp32ToFp16(false)
141  , m_Debug(false)
142  , m_ReduceFp32ToBf16(false)
144  , m_ImportEnabled(false)
145  , m_ModelOptions()
146  , m_ProfilingEnabled(false)
147  {}
ModelOptions m_ModelOptions
Definition: INetwork.hpp:233
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:227
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:224
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:214
Validate all output shapes.

◆ OptimizerOptions() [2/3]

OptimizerOptions ( bool  reduceFp32ToFp16,
bool  debug,
bool  reduceFp32ToBf16,
bool  importEnabled,
ModelOptions  modelOptions = {} 
)
inline

Definition at line 149 of file INetwork.hpp.

References armnn::ValidateOnly.

150  {})
151  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
152  , m_Debug(debug)
153  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
155  , m_ImportEnabled(importEnabled)
156  , m_ModelOptions(modelOptions)
157  , m_ProfilingEnabled(false)
158  {
160  {
161  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
162  }
163  }
ModelOptions m_ModelOptions
Definition: INetwork.hpp:233
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:227
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:224
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:214
Validate all output shapes.

◆ OptimizerOptions() [3/3]

OptimizerOptions ( bool  reduceFp32ToFp16,
bool  debug,
bool  reduceFp32ToBf16 = false,
ShapeInferenceMethod  shapeInferenceMethod = armnn::ShapeInferenceMethod::ValidateOnly,
bool  importEnabled = false,
ModelOptions  modelOptions = {} 
)
inline

Definition at line 165 of file INetwork.hpp.

167  {})
168  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
169  , m_Debug(debug)
170  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
171  , m_shapeInferenceMethod(shapeInferenceMethod)
172  , m_ImportEnabled(importEnabled)
173  , m_ModelOptions(modelOptions)
174  , m_ProfilingEnabled(false)
175  {
177  {
178  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
179  }
180  }
ModelOptions m_ModelOptions
Definition: INetwork.hpp:233
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:227
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:224
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:214

Member Function Documentation

◆ ToString()

const std::string ToString ( ) const
inline

Definition at line 182 of file INetwork.hpp.

References BackendOptions::BackendOption::GetName(), BackendOptions::BackendOption::GetValue(), BackendOptions::Var::ToString(), and armnn::ValidateOnly.

Referenced by armnn::Optimize().

183  {
184  std::stringstream stream;
185  stream << "OptimizerOptions: \n";
186  stream << "\tReduceFp32ToFp16: " << m_ReduceFp32ToFp16 << "\n";
187  stream << "\tReduceFp32ToBf16: " << m_ReduceFp32ToBf16 << "\n";
188  stream << "\tDebug: " << m_Debug << "\n";
189  stream << "\tShapeInferenceMethod: " <<
190  (m_shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly ? "ValidateOnly" : "InferAndValidate") << "\n";
191  stream << "\tImportEnabled: " << m_ImportEnabled << "\n";
192  stream << "\tProfilingEnabled: " << m_ProfilingEnabled << "\n";
193 
194  stream << "\tModelOptions: \n";
195  for (auto optionsGroup : m_ModelOptions)
196  {
197  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
198  {
199  const armnn::BackendOptions::BackendOption option = optionsGroup.GetOption(i);
200  stream << "\t\tBackend: " << optionsGroup.GetBackendId() << "\n"
201  << "\t\t\tOption: " << option.GetName() << "\n"
202  << "\t\t\tValue: " << std::string(option.GetValue().ToString()) << "\n";
203  }
204  }
205 
206  return stream.str();
207  }
ModelOptions m_ModelOptions
Definition: INetwork.hpp:233
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:227
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:224
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:214
Validate all output shapes.

Member Data Documentation

◆ m_Debug

◆ m_ImportEnabled

bool m_ImportEnabled
Examples:
CustomMemoryAllocatorSample.cpp.

Definition at line 230 of file INetwork.hpp.

Referenced by armnn::Optimize(), and TEST_SUITE().

◆ m_ModelOptions

◆ m_ProfilingEnabled

◆ m_ReduceFp32ToBf16

bool m_ReduceFp32ToBf16

Reduces all Fp32 operators in the model to Bf16 for faster processing.

This feature works best if all operators of the model are in Fp32. ArmNN will add conversion layers between layers that weren't in Fp32 in the first place or if the operator is not supported in Bf16. The overhead of these conversions can lead to a slower overall performance if too many conversions are required.

Definition at line 224 of file INetwork.hpp.

Referenced by InferenceModel< IParser, TDataType >::InferenceModel(), armnn::Optimize(), and ExecuteNetworkParams::ValidateParams().

◆ m_ReduceFp32ToFp16

bool m_ReduceFp32ToFp16

Reduces all Fp32 operators in the model to Fp16 for faster processing.

This feature works best if all operators of the model are in Fp32. ArmNN will add conversion layers between layers that weren't in Fp32 in the first place or if the operator is not supported in Fp16. The overhead of these conversions can lead to a slower overall performance if too many conversions are required.

Definition at line 214 of file INetwork.hpp.

Referenced by InferenceModel< IParser, TDataType >::InferenceModel(), armnn::Optimize(), TEST_SUITE(), and ExecuteNetworkParams::ValidateParams().

◆ m_shapeInferenceMethod


The documentation for this struct was generated from the following file: