23.05
|
Go to the documentation of this file.
72 virtual const char*
GetName()
const = 0;
93 virtual std::vector<TensorShape>
InferOutputShapes(
const std::vector<TensorShape>& inputShapes)
const = 0;
124 using ConstantTensors = std::vector<std::reference_wrapper<std::shared_ptr<ConstTensorHandle>>>;
156 OptimizerOptions(
bool reduceFp32ToFp16,
bool debug,
bool reduceFp32ToBf16,
bool importEnabled,
157 ModelOptions modelOptions = {},
bool exportEnabled =
false,
bool debugToFile =
false)
174 bool importEnabled = false,
ModelOptions modelOptions = {},
bool exportEnabled =
false,
175 bool debugToFile =
false,
bool allowExpandedDims =
false)
191 std::stringstream stream;
192 stream <<
"OptimizerOptions: \n";
195 stream <<
"\tDebug: " <<
m_Debug <<
"\n";
197 stream <<
"\tShapeInferenceMethod: " <<
199 ?
"ValidateOnly" :
"InferAndValidate") <<
"\n";
205 stream <<
"\tModelOptions: \n";
208 for (
size_t i=0; i < optionsGroup.GetOptionCount(); i++)
211 stream <<
"\t\tBackend: " << optionsGroup.GetBackendId() <<
"\n"
212 <<
"\t\t\tOption: " << option.
GetName() <<
"\n"
272 ModelOptions modelOptions = {},
bool exportEnabled =
false,
bool debugToFile =
false);
276 bool importEnabled =
false,
ModelOptions modelOptions = {},
bool exportEnabled =
false,
277 bool debugToFile =
false,
bool allowExpandedDims =
false);
321 std::unique_ptr<armnn::OptimizerOptionsOpaqueImpl> p_OptimizerOptionsImpl;
356 const char* name =
nullptr);
368 const char* name =
nullptr);
378 const char* name =
nullptr);
385 const char* name =
nullptr);
392 const char* name =
nullptr);
399 const char* name =
nullptr);
406 const char* name =
nullptr);
420 const char* name =
nullptr);
427 const char* name =
nullptr);
434 const char* name =
nullptr);
441 const char* name =
nullptr);
466 const char* name =
nullptr);
473 const char* name =
nullptr);
480 const char* name =
nullptr);
487 const char* name =
nullptr);
494 const char* name =
nullptr);
505 const char* name =
nullptr);
512 const char* name =
nullptr);
519 const char* name =
nullptr);
534 const char* name =
nullptr);
544 const char* name =
nullptr);
575 const char* name =
nullptr);
587 const char* name =
nullptr);
594 const char* name =
nullptr);
601 const char* name =
nullptr);
609 const char* name =
nullptr);
616 const char* name =
nullptr);
626 const char* name =
nullptr);
633 const char* name =
nullptr);
645 const char* name =
nullptr);
652 const char* name =
nullptr);
673 const char* name =
nullptr);
706 const char* name =
nullptr);
718 const char* name =
nullptr);
731 const char* name =
nullptr);
757 const char* name =
nullptr);
764 const char* name =
nullptr);
771 const char* name =
nullptr);
780 const char* name =
nullptr);
787 const char* name =
nullptr);
796 const char* name =
nullptr);
803 const char* name =
nullptr);
812 const char* name =
nullptr);
819 const char* name =
nullptr);
826 const char* name =
nullptr);
837 const std::vector<BackendId>& backendPreferences,
840 Optional<std::vector<std::string>&> messages);
842 const std::vector<BackendId>& backendPreferences,
845 Optional<std::vector<std::string>&> messages);
852 namespace experimental
854 class AsyncNetworkImpl;
858 struct BackendSettings;
859 struct OptimizationResult;
860 class OptimizedNetworkImpl;
870 arm::pipe::ProfilingGuid
GetGuid()
const;
884 const std::shared_ptr<IProfiler>&
GetProfiler()
const;
895 const std::vector<BackendId>& backendPreferences,
898 Optional<std::vector<std::string>&> messages);
900 const std::vector<BackendId>& backendPreferences,
903 Optional<std::vector<std::string>&> messages);
920 const std::vector<BackendId>& backendPreferences,
935 const std::vector<BackendId>& backendPreferences,
942 const std::vector<BackendId>& backendPreferences,
949 const std::vector<BackendId>& backendPreferences,
virtual void ExecuteStrategy(IStrategy &strategy) const =0
Apply a visitor to this layer.
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D convolution layer to the network.
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D depthwise convolution layer to the network.
friend Graph & GetGraphForTesting(IOptimizedNetwork *optNetPtr)
bool GetDebugEnabled() const
virtual const IConnectableLayer & GetOwningIConnectableLayer() const =0
const std::shared_ptr< IProfiler > & GetProfiler() const
virtual std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const =0
Infer the shape of the output(s) based on the provided input shape(s)
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Adds a floor layer to the network.
A GatherDescriptor for the GatherLayer.
A NormalizationDescriptor for the NormalizationLayer.
A TransposeDescriptor for the TransposeLayer.
bool GetDebugToFileEnabled() const
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
Adds a layer with no inputs and a single output, which always corresponds to the passed in constant t...
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a 2D transpose convolution layer to the network.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
A PadDescriptor for the PadLayer.
A SoftmaxDescriptor for the SoftmaxLayer.
std::unique_ptr< NetworkImpl > pNetworkImpl
friend IOptimizedNetworkPtr Optimize(const INetwork &inNetwork, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options, Optional< std::vector< std::string > & > messages)
Create an optimized version of the network.
bool m_AllowExpandedDims
When calculating tensor sizes, dimensions of size == 1 will be ignored.
A StackDescriptor for the StackLayer.
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
Adds a 3D pooling layer to the network.
A SliceDescriptor for the SliceLayer.
friend IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options, Optional< std::vector< std::string > & > messages)
Accept legacy OptimizerOptions.
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Adds a division layer to the network.
Status SerializeToDot(std::ostream &stream) const
bool m_ExportEnabled
Enable Export.
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
static INetwork * CreateRaw(const NetworkOptions &networkOptions={})
friend TensorInfo GetInputTensorInfo(const INetwork *network)
~IOutputSlot()
Not user deletable.
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a QLstm layer to the network.
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Adds a log softmax layer to the network.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
An ActivationDescriptor for the ActivationLayer.
@ ValidateOnly
Validate all output shapes.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
An LstmDescriptor for the LstmLayer.
A FullyConnectedDescriptor for the FullyConnectedLayer.
ModelOptions m_ModelOptions
Enable Model Options.
armnn::ShapeInferenceMethod GetShapeInferenceMethod() const
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Adds a Detection PostProcess layer to the network.
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Adds a subtraction layer to the network.
A BatchMatMulDescriptor for the BatchMatMul operator.
A ResizeDescriptor for the ResizeLayer.
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Adds a slice layer to the network.
A StridedSliceDescriptor for the StridedSliceLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
A Pooling3dDescriptor for the Pooling3dLayer.
A ReduceDescriptor for the REDUCE operators.
friend class experimental::AsyncNetworkImpl
Struct for the users to pass backend specific options.
friend class TestConnectionPreservation
bool GetAllowExpandedDims() const
std::vector< BackendOptions > ModelOptions
A ComparisonDescriptor for the ComparisonLayer.
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
A StandInDescriptor for the StandIn layer.
IConnectableLayer * AddElementwiseBinaryLayer(const ElementwiseBinaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseBinary layer to the network.
#define ARMNN_DEPRECATED_MSG_REMOVAL_DATE(message, removed_in_release)
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Add a quantize layer to the network.
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Add a Minimum layer to the network.
A ViewsDescriptor for the SplitterLayer.
A PreCompiledDescriptor for the PreCompiledLayer.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
void SetShapeInferenceMethod(armnn::ShapeInferenceMethod ShapeInferenceMethodType)
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a 2D pooling layer to the network.
ShapeInferenceMethod
The ShapeInferenceMethod modify how the output shapes are treated.
void SetImportEnabled(bool ImportState)
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &descriptor, const char *name=nullptr)
Add a BatchMatMul layer to the network.
size_t GetNumOutputs() const
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options=OptimizerOptionsOpaque(), Optional< std::vector< std::string > & > messages=EmptyOptional())
Create an optimized version of the network.
virtual bool IsTensorInfoSet() const =0
void SetAllowExpandedDims(bool ExpandedDimsAllowed)
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Adds a reduce layer to the network.
virtual int Connect(IInputSlot &destination)=0
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Adds a Dequantize layer to the network.
static void Destroy(INetwork *network)
Copyright (c) 2021 ARM Limited and Contributors.
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Add a Maximum layer to the network.
std::function< void(const void *)> CompiledBlobDeleter
bool GetReduceFp32ToFp16() const
IConnectableLayer * AddStackLayer(const StackDescriptor &descriptor, const char *name=nullptr)
Adds a stack layer to the network.
virtual void Disconnect(IInputSlot &slot)=0
INetwork(NetworkOptions networkOptions={})
std::string GetName() const
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Adds a Precompiled layer to the network.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Adds a multiplication layer to the network.
~OptimizerOptionsOpaque()
std::vector< BackendOptions > NetworkOptions
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Adds a normalization layer to the network.
bool m_ProfilingEnabled
Enable profiling dump of the optimizer phase.
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Adds a space to batch layer to the network.
A FillDescriptor for the FillLayer.
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
Adds a 3D convolution layer to the network.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Adds an L2 normalization layer to the network.
virtual const TensorInfo & GetTensorInfo() const =0
void SetReduceFp32ToFp16(bool ReduceFp32ToFp16State)
virtual unsigned int GetNumConnections() const =0
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Adds a transpose layer to the network.
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Add a stand-in layer for a type unknown to the Arm NN framework.
virtual unsigned int CalculateIndexOnOwner() const =0
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Adds an addition layer to the network.
bool GetProfilingEnabled() const
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Adds a fully pad layer to the network.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
A MeanDescriptor for the MeanLayer.
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Adds an instance normalization layer to the network.
bool m_DebugToFile
Pass debug data to separate output files for easier troubleshooting.
void SetDebugEnabled(bool DebugState)
Device specific knowledge to be passed to the optimizer.
arm::pipe::ProfilingGuid GetGuid() const
static void Destroy(IOptimizedNetwork *network)
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Adds a merge layer to the network.
std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr
virtual const IInputSlot * GetConnection(unsigned int index) const =0
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
A L2NormalizationDescriptor for the L2NormalizationLayer.
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Adds a permute layer to the network.
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
A ChannelShuffleDescriptor for the ChannelShuffle operator.
An output connection slot for a layer.
A Convolution3dDescriptor for the Convolution3dLayer.
const std::string ToString() const
~IConnectableLayer()
Objects are not deletable via the handle.
A Convolution2dDescriptor for the Convolution2dLayer.
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Add a Comparison layer to the network.
IOptimizedNetwork(const IOptimizedNetwork &other, const ModelOptions &modelOptions)
Creates a copy of the IOptimizedNetwork.
IConnectableLayer * AddCastLayer(const char *name=nullptr)
Adds a cast layer to the network.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
void SetDebugToFileEnabled(bool DebugFileState)
A QLstmDescriptor for the QLstmLayer.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
bool m_ReduceFp32ToBf16
@Note This feature has been replaced by enabling Fast Math in compute library backend options.
void ExecuteStrategy(IStrategy &strategy) const
ShapeInferenceMethod m_shapeInferenceMethod
Infer output size when not available.
OptimizerOptionsOpaque & operator=(OptimizerOptionsOpaque other)
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Adds an activation layer to the network.
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
Add GatherNd layer to the network.
size_t GetNumInputs() const
bool GetImportEnabled() const
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &descriptor, const char *name=nullptr)
Add a ChannelShuffle layer to the network.
IConnectableLayer * AddGatherLayer(const GatherDescriptor &descriptor, const char *name=nullptr)
Add Gather layer to the network.
static INetworkPtr Create(const NetworkOptions &networkOptions={})
virtual void SetBackendId(const BackendId &id)=0
Set the backend of the IConnectableLayer.
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Adds a depth to space layer to the network.
Base class for all descriptors.
An OriginsDescriptor for the ConcatLayer.
bool GetExportEnabled() const
A ReshapeDescriptor for the ReshapeLayer.
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Adds a PReLU layer to the network.
const std::string ToString() const
virtual LayerGuid GetOwningLayerGuid() const =0
A PermuteDescriptor for the PermuteLayer.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Adds a space to depth layer to the network.
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Adds a switch layer to the network.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Add a Mean layer to the network.
friend void VisitLayersTopologically(const INetwork *inputNetwork, IStrategy &strategy)
void ExecuteStrategy(IStrategy &strategy) const
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Adds a shape layer to the network.
A Pooling2dDescriptor for the Pooling2dLayer.
friend ModelOptions & GetModelOptionsForTesting(IOptimizedNetwork *optNetPtr)
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Adds a resize layer to the network.
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Adds a concatenation layer to the network.
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Adds a batch to space ND layer to the network.
Main network class which provides the interface for building up a neural network.
void AddModelOption(armnn::BackendOptions)
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Add an Fill layer to the network.
bool GetReduceFp32ToBf16() const
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams ¶ms, const char *name=nullptr)
Add a QuantizedLstm layer to the network.
virtual const char * GetName() const =0
Returns the name of the layer.
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseUnary layer to the network.
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Adds a strided slice layer to the network.
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Adds a rank layer to the network.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
An ArgMinMaxDescriptor for ArgMinMaxLayer.
Private implementation of INetwork.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
IConnectableLayer * AddUnidirectionalSequenceLstmLayer(const UnidirectionalSequenceLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a UnidirectionalSequenceLstm layer to the network.
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
arm::pipe::ProfilingGuid LayerGuid
Define LayerGuid type.
std::vector< std::reference_wrapper< const std::shared_ptr< ConstTensorHandle > >> ImmutableConstantTensors
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
Adds a batch normalization layer to the network.
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Adds an input layer to the network.
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Adds an ArgMinMax layer to the network.
A ElementwiseBinaryDescriptor for the ElementwiseBinaryLayer.
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &descriptor, const char *name=nullptr)
Adds a Logical Binary layer to the network.
virtual void BackendSelectionHint(Optional< BackendId > backend)=0
Provide a hint for the optimizer as to which backend to prefer for this layer.
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)
Add a Lstm layer to the network.
void SetExportEnabled(bool ExportState)
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Adds a splitter layer to the network.
bool m_Debug
Add debug data for easier troubleshooting.
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Adds a softmax layer to the network.
void SetProfilingEnabled(bool ProfilingState)
virtual const BaseDescriptor & GetParameters() const =0
If the layer has a descriptor return it.
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Adds an output layer to the network.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
Adds a fully connected layer to the network.
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Adds a reshape layer to the network.
virtual ConstantTensors GetConstantTensorsByRef()=0
armnn::ModelOptions GetModelOptions() const
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
bool m_ImportEnabled
Enable Import.