ArmNN
 22.08
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={}, bool exportEnabled=false)
 
 OptimizerOptions (bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16=false, ShapeInferenceMethod shapeInferenceMethod=armnn::ShapeInferenceMethod::ValidateOnly, bool importEnabled=false, ModelOptions modelOptions={}, bool exportEnabled=false)
 
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
 
bool m_ExportEnabled
 

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 127 of file INetwork.hpp.

Constructor & Destructor Documentation

◆ OptimizerOptions() [1/3]

OptimizerOptions ( )
inline

Definition at line 129 of file INetwork.hpp.

130  : m_ReduceFp32ToFp16(false)
131  , m_Debug(false)
132  , m_ReduceFp32ToBf16(false)
134  , m_ImportEnabled(false)
135  , m_ModelOptions()
136  , m_ProfilingEnabled(false)
137  , m_ExportEnabled(false)
138  {}
ModelOptions m_ModelOptions
Definition: INetwork.hpp:227
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:221
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:218
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:208
Validate all output shapes.

◆ OptimizerOptions() [2/3]

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

Definition at line 140 of file INetwork.hpp.

References armnn::ValidateOnly.

141  {}, bool exportEnabled = false)
142  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
143  , m_Debug(debug)
144  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
146  , m_ImportEnabled(importEnabled)
147  , m_ModelOptions(modelOptions)
148  , m_ProfilingEnabled(false)
149  , m_ExportEnabled(exportEnabled)
150  {
152  {
153  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
154  }
155  }
ModelOptions m_ModelOptions
Definition: INetwork.hpp:227
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:221
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:218
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:208
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 = {},
bool  exportEnabled = false 
)
inline

Definition at line 157 of file INetwork.hpp.

159  {}, bool exportEnabled = false)
160  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
161  , m_Debug(debug)
162  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
163  , m_shapeInferenceMethod(shapeInferenceMethod)
164  , m_ImportEnabled(importEnabled)
165  , m_ModelOptions(modelOptions)
166  , m_ProfilingEnabled(false)
167  , m_ExportEnabled(exportEnabled)
168  {
170  {
171  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
172  }
173  }
ModelOptions m_ModelOptions
Definition: INetwork.hpp:227
ShapeInferenceMethod m_shapeInferenceMethod
Definition: INetwork.hpp:221
bool m_ReduceFp32ToBf16
Reduces all Fp32 operators in the model to Bf16 for faster processing.
Definition: INetwork.hpp:218
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:208

Member Function Documentation

◆ ToString()

const std::string ToString ( ) const
inline

Definition at line 175 of file INetwork.hpp.

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

Referenced by armnn::Optimize().

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

Member Data Documentation

◆ m_Debug

◆ m_ExportEnabled

bool m_ExportEnabled

Definition at line 233 of file INetwork.hpp.

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

◆ m_ImportEnabled

bool m_ImportEnabled
Examples:
CustomMemoryAllocatorSample.cpp.

Definition at line 224 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 218 of file INetwork.hpp.

Referenced by InferenceModel< IParser, TDataType >::InferenceModel(), armnn::Optimize(), ArmNNExecutor::PrintNetworkInfo(), 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 208 of file INetwork.hpp.

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

◆ m_shapeInferenceMethod


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