ArmNN
 20.05
DynamicQuantizationVisitor Class Reference

Visitor class to establish min/max ranges based on the type of the layer. More...

#include <DynamicQuantizationVisitor.hpp>

Inheritance diagram for DynamicQuantizationVisitor:
LayerVisitorBase< VisitorThrowingPolicy > ILayerVisitor

Public Member Functions

 DynamicQuantizationVisitor (RangeTracker &rangeTracker, Graph &graph)
 
 ~DynamicQuantizationVisitor ()=default
 
void VisitAbsLayer (const IConnectableLayer *layer, const char *name=nullptr) override
 Functions to set the Range on a per-layer-type basis. More...
 
void VisitAdditionLayer (const IConnectableLayer *layer, const char *name=nullptr) override
 Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitArgMinMaxLayer (const IConnectableLayer *layer, const ArgMinMaxDescriptor &desc, const char *name=nullptr) override
 Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitNormalizationLayer (const IConnectableLayer *layer, const NormalizationDescriptor &desc, const char *name=nullptr) override
 Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitBatchNormalizationLayer (const IConnectableLayer *layer, const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr) override
 Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConvolution2dLayer (const IConnectableLayer *layer, const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
 Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDepthwiseConvolution2dLayer (const IConnectableLayer *layer, const DepthwiseConvolution2dDescriptor &desc, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
 Function that a 2D depthwise convolution layer with biases should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitActivationLayer (const IConnectableLayer *layer, const ActivationDescriptor &activationDescriptor, const char *name=nullptr) override
 Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitFullyConnectedLayer (const IConnectableLayer *layer, const FullyConnectedDescriptor &desc, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name) override
 Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPermuteLayer (const IConnectableLayer *layer, const PermuteDescriptor &permuteDescriptor, const char *name) override
 Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSpaceToBatchNdLayer (const IConnectableLayer *layer, const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr) override
 Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPooling2dLayer (const IConnectableLayer *layer, const Pooling2dDescriptor &pooling2dDescriptor, const char *name) override
 Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSoftmaxLayer (const IConnectableLayer *layer, const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr) override
 Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConcatLayer (const IConnectableLayer *layer, const ConcatDescriptor &originsDescriptor, const char *name=nullptr) override
 Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConstantLayer (const IConnectableLayer *layer, const ConstTensor &input, const char *name=nullptr) override
 Function a layer with no inputs and a single output, which always corresponds to the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitReshapeLayer (const IConnectableLayer *layer, const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr) override
 Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSplitterLayer (const IConnectableLayer *layer, const SplitterDescriptor &splitterDescriptor, const char *name=nullptr) override
 Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitResizeBilinearLayer (const IConnectableLayer *layer, const ResizeBilinearDescriptor &resizeDesc, const char *name=nullptr) override
 Function that a resize bilinear layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitStridedSliceLayer (const IConnectableLayer *layer, const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr) override
 Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitBatchToSpaceNdLayer (const IConnectableLayer *layer, const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr) override
 Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitInputLayer (const IConnectableLayer *layer, LayerBindingId id, const char *name=nullptr) override
 Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitOutputLayer (const IConnectableLayer *layer, LayerBindingId id, const char *name=nullptr) override
 Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void FinishVisit () override
 
void VisitNonCalibratedLayers ()
 
const std::vector< armnn::LayerBindingId > & GetOutputLayers ()
 
- Public Member Functions inherited from LayerVisitorBase< VisitorThrowingPolicy >
void VisitAbsLayer (const IConnectableLayer *, const char *) override
 Function an absolute layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitActivationLayer (const IConnectableLayer *, const ActivationDescriptor &, const char *) override
 Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitAdditionLayer (const IConnectableLayer *, const char *) override
 Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitArgMinMaxLayer (const IConnectableLayer *, const ArgMinMaxDescriptor &, const char *) override
 Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitBatchNormalizationLayer (const IConnectableLayer *, const BatchNormalizationDescriptor &, const ConstTensor &, const ConstTensor &, const ConstTensor &, const ConstTensor &, const char *) override
 Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitBatchToSpaceNdLayer (const IConnectableLayer *, const BatchToSpaceNdDescriptor &, const char *) override
 Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitComparisonLayer (const IConnectableLayer *, const ComparisonDescriptor &, const char *) override
 Function a Comparison layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConcatLayer (const IConnectableLayer *, const ConcatDescriptor &, const char *) override
 Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConstantLayer (const IConnectableLayer *, const ConstTensor &, const char *) override
 Function a layer with no inputs and a single output, which always corresponds to the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitConvolution2dLayer (const IConnectableLayer *, const Convolution2dDescriptor &, const ConstTensor &, const Optional< ConstTensor > &, const char *) override
 Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDepthToSpaceLayer (const IConnectableLayer *, const DepthToSpaceDescriptor &, const char *) override
 Function a depth to space layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDepthwiseConvolution2dLayer (const IConnectableLayer *, const DepthwiseConvolution2dDescriptor &, const ConstTensor &, const Optional< ConstTensor > &, const char *) override
 Function that a 2D depthwise convolution layer with biases should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDequantizeLayer (const IConnectableLayer *, const char *) override
 Function that a Dequantize layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDetectionPostProcessLayer (const IConnectableLayer *, const DetectionPostProcessDescriptor &, const ConstTensor &, const char *) override
 Function that a Detection PostProcess layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitDivisionLayer (const IConnectableLayer *, const char *) override
 Function a division layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitElementwiseUnaryLayer (const IConnectableLayer *, const ElementwiseUnaryDescriptor &, const char *) override
 Function a ElementwiseUnary layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitEqualLayer (const IConnectableLayer *, const char *) override
 Function an Equal layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitFloorLayer (const IConnectableLayer *, const char *) override
 Function a floor layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitFullyConnectedLayer (const IConnectableLayer *, const FullyConnectedDescriptor &, const ConstTensor &, const Optional< ConstTensor > &, const char *) override
 Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitGatherLayer (const IConnectableLayer *, const char *) override
 Function a Gather layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitGreaterLayer (const IConnectableLayer *, const char *) override
 Function a Greater layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitInputLayer (const IConnectableLayer *, LayerBindingId, const char *) override
 Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitInstanceNormalizationLayer (const IConnectableLayer *, const InstanceNormalizationDescriptor &, const char *) override
 Function that an instance normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitL2NormalizationLayer (const IConnectableLayer *, const L2NormalizationDescriptor &, const char *) override
 Function that an L2 normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitLogSoftmaxLayer (const IConnectableLayer *, const LogSoftmaxDescriptor &, const char *) override
 Function that a log softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitLstmLayer (const IConnectableLayer *, const LstmDescriptor &, const LstmInputParams &, const char *) override
 Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMaximumLayer (const IConnectableLayer *, const char *) override
 Function a Maximum layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMeanLayer (const IConnectableLayer *, const MeanDescriptor &, const char *) override
 Function a Mean layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMergeLayer (const IConnectableLayer *, const char *) override
 Function that a merge layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMergerLayer (const IConnectableLayer *, const MergerDescriptor &, const char *) override
 Function that a merger layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMinimumLayer (const IConnectableLayer *, const char *) override
 Function a Minimum layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitMultiplicationLayer (const IConnectableLayer *, const char *) override
 Function that a multiplication layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitNormalizationLayer (const IConnectableLayer *, const NormalizationDescriptor &, const char *) override
 Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitOutputLayer (const IConnectableLayer *, LayerBindingId, const char *) override
 Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPadLayer (const IConnectableLayer *, const PadDescriptor &, const char *) override
 Function a pad layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPermuteLayer (const IConnectableLayer *, const PermuteDescriptor &, const char *) override
 Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPooling2dLayer (const IConnectableLayer *, const Pooling2dDescriptor &, const char *) override
 Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitPreluLayer (const IConnectableLayer *, const char *) override
 Function that a PReLU activation layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitQuantizeLayer (const IConnectableLayer *, const char *) override
 Function a quantize layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitQLstmLayer (const IConnectableLayer *, const QLstmDescriptor &, const LstmInputParams &, const char *) override
 Function a QLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitQuantizedLstmLayer (const IConnectableLayer *, const QuantizedLstmInputParams &, const char *) override
 Function a QuantizedLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitReshapeLayer (const IConnectableLayer *, const ReshapeDescriptor &, const char *) override
 Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitResizeBilinearLayer (const IConnectableLayer *, const ResizeBilinearDescriptor &, const char *) override
 Function that a resize bilinear layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitResizeLayer (const IConnectableLayer *, const ResizeDescriptor &, const char *) override
 Function that a resize layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitRsqrtLayer (const IConnectableLayer *, const char *) override
 Function a Reciprocal of square root layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSliceLayer (const IConnectableLayer *, const SliceDescriptor &, const char *) override
 Function that a slice layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSoftmaxLayer (const IConnectableLayer *, const SoftmaxDescriptor &, const char *) override
 Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSpaceToBatchNdLayer (const IConnectableLayer *, const SpaceToBatchNdDescriptor &, const char *) override
 Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSpaceToDepthLayer (const IConnectableLayer *, const SpaceToDepthDescriptor &, const char *) override
 Function a space to depth layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSplitterLayer (const IConnectableLayer *, const ViewsDescriptor &, const char *) override
 Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitStackLayer (const IConnectableLayer *, const StackDescriptor &, const char *) override
 Function a stack layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitStandInLayer (const IConnectableLayer *, const StandInDescriptor &, const char *) override
 Function a StandInLayer should call back to when its Accept(ILaterVisitor&) function is invoked. More...
 
void VisitStridedSliceLayer (const IConnectableLayer *, const StridedSliceDescriptor &, const char *) override
 Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSubtractionLayer (const IConnectableLayer *, const char *) override
 Function a subtraction layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitSwitchLayer (const IConnectableLayer *, const char *) override
 Function a switch layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitTransposeConvolution2dLayer (const IConnectableLayer *, const TransposeConvolution2dDescriptor &, const ConstTensor &, const Optional< ConstTensor > &, const char *) override
 Function that a 2D transpose convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
void VisitTransposeLayer (const IConnectableLayer *, const TransposeDescriptor &, const char *) override
 Function that a transpose layer should call back to when its Accept(ILayerVisitor&) function is invoked. More...
 
- Public Member Functions inherited from ILayerVisitor
virtual void StartVisit ()
 

Additional Inherited Members

- Protected Member Functions inherited from LayerVisitorBase< VisitorThrowingPolicy >
 LayerVisitorBase ()
 
virtual ~LayerVisitorBase ()
 
- Protected Member Functions inherited from ILayerVisitor
 ILayerVisitor ()
 
virtual ~ILayerVisitor ()
 

Detailed Description

Visitor class to establish min/max ranges based on the type of the layer.

Definition at line 19 of file DynamicQuantizationVisitor.hpp.

Constructor & Destructor Documentation

◆ DynamicQuantizationVisitor()

◆ ~DynamicQuantizationVisitor()

Member Function Documentation

◆ FinishVisit()

void FinishVisit ( )
overridevirtual

Reimplemented from ILayerVisitor.

Definition at line 51 of file DynamicQuantizationVisitor.cpp.

References OutputSlot::Connect(), OutputSlot::Disconnect(), Graph::EraseLayer(), and armnn::InsertDebugLayerAfter().

52 {
53  for (const IConnectableLayer* layer : m_LayersToCalibrate)
54  {
55  std::vector<DebugLayer*> newDebugLayers = InsertDebugLayerAfter(
56  m_Graph, *PolymorphicDowncast<Layer*>(const_cast<IConnectableLayer*>(layer)));
57  // record them so we can take them out again efficiently afterward
58  m_DebugLayers.insert(std::end(m_DebugLayers), std::begin(newDebugLayers), std::end(newDebugLayers));
59  }
60 }
std::vector< DebugLayer * > InsertDebugLayerAfter(Graph &graph, Layer &layer)

◆ GetOutputLayers()

const std::vector< LayerBindingId > & GetOutputLayers ( )

Definition at line 360 of file DynamicQuantizationVisitor.cpp.

361 {
362  return m_OutputLayers;
363 }

◆ VisitAbsLayer()

void VisitAbsLayer ( const IConnectableLayer layer,
const char *  name = nullptr 
)
overridevirtual

Functions to set the Range on a per-layer-type basis.

Implements ILayerVisitor.

Definition at line 95 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

97 {
98  IgnoreUnused(name);
99  SetRange(layer, 0, -20.f, 20.f);
100  AddToCalibratedLayers(layer);
101 }
void IgnoreUnused(Ts &&...)

◆ VisitActivationLayer()

void VisitActivationLayer ( const IConnectableLayer layer,
const ActivationDescriptor activationDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
activationDescriptor- ActivationDescriptor to configure the activation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 169 of file DynamicQuantizationVisitor.cpp.

References armnn::Abs, armnn::BoundedReLu, armnn::IgnoreUnused(), armnn::LeakyReLu, armnn::Linear, ActivationDescriptor::m_A, ActivationDescriptor::m_Function, armnn::ReLu, armnn::SoftReLu, and armnn::TanH.

172 {
173  IgnoreUnused(name, activationDescriptor);
174  switch (activationDescriptor.m_Function)
175  {
176  // Range is 0, 15 for Abs, Linear, ReLu and Soft ReLu
181  SetRange(layer, 0, 0.f, 15.f);
182  break;
184  SetRange(layer, 0, 0.f, activationDescriptor.m_A);
185  break;
187  SetRange(layer, 0, -1.f, 1.f);
188  break;
190  SetRange(layer, 0, -5.f, 15.f);
191  break;
192  default:
193  SetRange(layer, 0, -15.f, 15.f);
194  break;
195  }
196  AddToCalibratedLayers(layer);
197 }
void IgnoreUnused(Ts &&...)
min(a, max(b, input)) ReLu1 & ReLu6.

◆ VisitAdditionLayer()

void VisitAdditionLayer ( const IConnectableLayer layer,
const char *  name = nullptr 
)
overridevirtual

Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 87 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

89 {
90  IgnoreUnused(name);
91  SetRange(layer, 0, -20.f, 20.f);
92  AddToCalibratedLayers(layer);
93 }
void IgnoreUnused(Ts &&...)

◆ VisitArgMinMaxLayer()

void VisitArgMinMaxLayer ( const IConnectableLayer layer,
const ArgMinMaxDescriptor argMinMaxDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
argMinMaxDescriptor- ArgMinMaxDescriptor to configure the activation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 103 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

106 {
107  IgnoreUnused(name);
108  IgnoreUnused(desc);
109  SetRange(layer, 0, -20.f, 20.f);
110  AddToCalibratedLayers(layer);
111 }
void IgnoreUnused(Ts &&...)

◆ VisitBatchNormalizationLayer()

void VisitBatchNormalizationLayer ( const IConnectableLayer layer,
const BatchNormalizationDescriptor desc,
const ConstTensor mean,
const ConstTensor variance,
const ConstTensor beta,
const ConstTensor gamma,
const char *  name = nullptr 
)
overridevirtual

Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
mean- Pre-calculated mean for each channel.
variance- Pre-calculated variance for each channel.
beta- Per-channel additive factor.
gamma- Per-channel multiplicative factor.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 113 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

120 {
121  IgnoreUnused(desc);
122  IgnoreUnused(mean);
123  IgnoreUnused(variance);
124  IgnoreUnused(beta);
125  IgnoreUnused(gamma);
126  IgnoreUnused(name);
127  SetRange(layer, 0, -15.0f, 15.0f);
128  AddToCalibratedLayers(layer);
129 }
void IgnoreUnused(Ts &&...)

◆ VisitBatchToSpaceNdLayer()

void VisitBatchToSpaceNdLayer ( const IConnectableLayer layer,
const BatchToSpaceNdDescriptor batchToSpaceNdDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
batchToSpaceNdDescriptor- Description of the layer.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 335 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

338 {
339  IgnoreUnused(batchToSpaceNdDescriptor);
340  IgnoreUnused(name);
341  AddToNonCalibratedLayers(layer);
342 }
void IgnoreUnused(Ts &&...)

◆ VisitConcatLayer()

void VisitConcatLayer ( const IConnectableLayer layer,
const ConcatDescriptor concatDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
concatDescriptor- ConcatDescriptor (synonym for OriginsDescriptor) to configure the concatenation process. Number of Views must be equal to the number of inputs, and their order must match - e.g. first view corresponds to the first input, second view to the second input, etc....
name- Optional name for the layer.

Reimplemented from ILayerVisitor.

Definition at line 278 of file DynamicQuantizationVisitor.cpp.

References IOutputSlot::CalculateIndexOnOwner(), IInputSlot::GetConnection(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetNumInputSlots(), IOutputSlot::GetOwningLayerGuid(), RangeTracker::GetRange(), and armnn::IgnoreUnused().

281 {
282  IgnoreUnused(name);
283  IgnoreUnused(originsDescriptor);
284  float min = std::numeric_limits<float>::max();
285  float max = std::numeric_limits<float>::lowest();
286  for (unsigned int i = 0; i < layer->GetNumInputSlots(); ++i)
287  {
288  const IOutputSlot* outputSlot = layer->GetInputSlot(i).GetConnection();
289  LayerGuid layerId = outputSlot->GetOwningLayerGuid();
290  unsigned int slotIndex = outputSlot->CalculateIndexOnOwner();
291  RangeTracker::MinMaxRange range = m_RangeTracker.GetRange(layerId, slotIndex);
292  min = std::min(min, range.first);
293  max = std::max(max, range.second);
294  }
295  SetRange(layer, 0, min, max);
296  AddToCalibratedLayers(layer);
297 }
void IgnoreUnused(Ts &&...)
std::pair< float, float > MinMaxRange
MinMaxRange GetRange(LayerGuid guid, unsigned int idx) const
Retrieve the Range for a particular output slot on a particular layer.
profiling::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:236

◆ VisitConstantLayer()

void VisitConstantLayer ( const IConnectableLayer layer,
const ConstTensor input,
const char *  name = nullptr 
)
overridevirtual

Function a layer with no inputs and a single output, which always corresponds to the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
input- Tensor to be provided as the only output of the layer. The layer will maintain its own copy of the tensor data, meaning the memory referenced by input can be freed or reused after this function is called.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 250 of file DynamicQuantizationVisitor.cpp.

References armnn::Float32, BaseTensor< MemoryType >::GetDataType(), BaseTensor< MemoryType >::GetMemoryArea(), BaseTensor< MemoryType >::GetNumElements(), and armnn::IgnoreUnused().

253 {
254  IgnoreUnused(name);
255 
256  if (input.GetDataType() != DataType::Float32)
257  {
258  throw InvalidArgumentException("Quantization is supported only for FP32 tensors");
259  }
260 
261  // Work out the range based on the input constants
262  unsigned int inputNumElements = input.GetNumElements();
263  const float* inputData = reinterpret_cast<const float*>(input.GetMemoryArea());
264 
265  float min = std::numeric_limits<float>::max();
266  float max = std::numeric_limits<float>::lowest();
267 
268  for (unsigned int i = 0; i < inputNumElements; i++)
269  {
270  const float inputValue = inputData[i];
271 
272  min = std::min(min, inputValue);
273  max = std::max(max, inputValue);
274  }
275  SetRange(layer, 0, min, max);
276 }
void IgnoreUnused(Ts &&...)

◆ VisitConvolution2dLayer()

void VisitConvolution2dLayer ( const IConnectableLayer layer,
const Convolution2dDescriptor convolution2dDescriptor,
const ConstTensor weights,
const Optional< ConstTensor > &  biases,
const char *  name = nullptr 
)
overridevirtual

Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
convolution2dDescriptor- Description of the 2D convolution layer.
weights- Tensor for the weights data.
biases- Optional tensor for the bias data. If specified, must match the output tensor shape.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 141 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

146 {
147  IgnoreUnused(convolution2dDescriptor);
148  IgnoreUnused(weights);
149  IgnoreUnused(biases);
150  IgnoreUnused(name);
151  SetRange(layer, 0, -15.0f, 15.0f);
152  AddToCalibratedLayers(layer);
153 }
void IgnoreUnused(Ts &&...)

◆ VisitDepthwiseConvolution2dLayer()

void VisitDepthwiseConvolution2dLayer ( const IConnectableLayer layer,
const DepthwiseConvolution2dDescriptor convolution2dDescriptor,
const ConstTensor weights,
const Optional< ConstTensor > &  biases,
const char *  name = nullptr 
)
overridevirtual

Function that a 2D depthwise convolution layer with biases should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
convolution2dDescriptor- Description of the 2D depthwise convolution layer.
weights- Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width].
biases- Optional tensor for the bias data. If specified, must match the output tensor shape.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 155 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

160 {
161  IgnoreUnused(desc);
162  IgnoreUnused(weights);
163  IgnoreUnused(biases);
164  IgnoreUnused(name);
165  SetRange(layer, 0, -15.0f, 15.0f);
166  AddToCalibratedLayers(layer);
167 }
void IgnoreUnused(Ts &&...)

◆ VisitFullyConnectedLayer()

void VisitFullyConnectedLayer ( const IConnectableLayer layer,
const FullyConnectedDescriptor fullyConnectedDescriptor,
const ConstTensor weights,
const Optional< ConstTensor > &  biases,
const char *  name 
)
overridevirtual

Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
fullyConnectedDescriptor- Description of the fully connected layer.
weights- Tensor for the weights data.
biases- Optional tensor for the bias data.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 199 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

204 {
205  IgnoreUnused(desc);
206  IgnoreUnused(weights);
207  IgnoreUnused(biases);
208  IgnoreUnused(name);
209  SetRange(layer, 0, -15.0f, 15.0f);
210  AddToCalibratedLayers(layer);
211 }
void IgnoreUnused(Ts &&...)

◆ VisitInputLayer()

void VisitInputLayer ( const IConnectableLayer layer,
LayerBindingId  id,
const char *  name = nullptr 
)
overridevirtual

Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
id- User generated id to uniquely identify a particular input. The same id needs to be specified when passing the inputs to the IRuntime::EnqueueWorkload() function.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 344 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

345 {
346  IgnoreUnused(id);
347  IgnoreUnused(name);
348  SetRange(layer, 0, -0.0f, 0.0f);
349  AddToCalibratedLayers(layer);
350 }
void IgnoreUnused(Ts &&...)

◆ VisitNonCalibratedLayers()

void VisitNonCalibratedLayers ( )

Definition at line 79 of file DynamicQuantizationVisitor.cpp.

79  {
80  RemoveDebugLayers();
81  for (const IConnectableLayer* layer : m_LayersNotToCalibrate)
82  {
83  ForwardParentParameters(layer);
84  }
85 }

◆ VisitNormalizationLayer()

void VisitNormalizationLayer ( const IConnectableLayer layer,
const NormalizationDescriptor normalizationDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
normalizationDescriptor- NormalizationDescriptor to configure the normalization.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 131 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

134 {
135  IgnoreUnused(desc);
136  IgnoreUnused(name);
137  SetRange(layer, 0, -15.0f, 15.0f);
138  AddToCalibratedLayers(layer);
139 }
void IgnoreUnused(Ts &&...)

◆ VisitOutputLayer()

void VisitOutputLayer ( const IConnectableLayer layer,
LayerBindingId  id,
const char *  name = nullptr 
)
overridevirtual

Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
id- User generated id to uniquely identify a particular output. The same id needs to be specified when passing the outputs to the IRuntime::EnqueueWorkload() function.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 352 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

353 {
354  IgnoreUnused(id);
355  IgnoreUnused(name);
356  AddToNonCalibratedLayers(layer);
357  m_OutputLayers.push_back(id);
358 }
void IgnoreUnused(Ts &&...)

◆ VisitPermuteLayer()

void VisitPermuteLayer ( const IConnectableLayer layer,
const PermuteDescriptor permuteDescriptor,
const char *  name 
)
overridevirtual

Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
permuteDescriptor- PermuteDescriptor to configure the permute.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 213 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

216 {
217  IgnoreUnused(permuteDescriptor);
218  IgnoreUnused(name);
219  AddToNonCalibratedLayers(layer);
220 }
void IgnoreUnused(Ts &&...)

◆ VisitPooling2dLayer()

void VisitPooling2dLayer ( const IConnectableLayer layer,
const Pooling2dDescriptor pooling2dDescriptor,
const char *  name 
)
overridevirtual

Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
pooling2dDescriptor- Pooling2dDescriptor to configure the pooling.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 231 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

234 {
235  IgnoreUnused(pooling2dDescriptor);
236  IgnoreUnused(name);
237  AddToNonCalibratedLayers(layer);
238 }
void IgnoreUnused(Ts &&...)

◆ VisitReshapeLayer()

void VisitReshapeLayer ( const IConnectableLayer layer,
const ReshapeDescriptor reshapeDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
reshapeDescriptor- Parameters for the reshape operation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 299 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

302 {
303  IgnoreUnused(reshapeDescriptor);
304  IgnoreUnused(name);
305  AddToNonCalibratedLayers(layer);
306 }
void IgnoreUnused(Ts &&...)

◆ VisitResizeBilinearLayer()

void VisitResizeBilinearLayer ( const IConnectableLayer layer,
const ResizeBilinearDescriptor resizeDesc,
const char *  name = nullptr 
)
overridevirtual

Function that a resize bilinear layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
resizeDesc- Parameters for the resize operation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 317 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

320 {
321  IgnoreUnused(resizeDesc);
322  IgnoreUnused(name);
323  AddToNonCalibratedLayers(layer);
324 }
void IgnoreUnused(Ts &&...)

◆ VisitSoftmaxLayer()

void VisitSoftmaxLayer ( const IConnectableLayer layer,
const SoftmaxDescriptor softmaxDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
softmaxDescriptor- SoftmaxDescriptor to configure the softmax.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 240 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

243 {
244  IgnoreUnused(softmaxDescriptor);
245  IgnoreUnused(name);
246  SetRange(layer, 0, 0.f, 1.f);
247  AddToCalibratedLayers(layer);
248 }
void IgnoreUnused(Ts &&...)

◆ VisitSpaceToBatchNdLayer()

void VisitSpaceToBatchNdLayer ( const IConnectableLayer layer,
const SpaceToBatchNdDescriptor spaceToBatchNdDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
spaceToBatchNdDescriptor- Parameters for the space to batch operation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 222 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

225 {
226  IgnoreUnused(spaceToBatchNdDescriptor);
227  IgnoreUnused(name);
228  AddToNonCalibratedLayers(layer);
229 }
void IgnoreUnused(Ts &&...)

◆ VisitSplitterLayer()

void VisitSplitterLayer ( const IConnectableLayer layer,
const SplitterDescriptor splitterDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
splitterDescriptor- ViewsDescriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc....
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 308 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

311 {
312  IgnoreUnused(splitterDescriptor);
313  IgnoreUnused(name);
314  AddToNonCalibratedLayers(layer);
315 }
void IgnoreUnused(Ts &&...)

◆ VisitStridedSliceLayer()

void VisitStridedSliceLayer ( const IConnectableLayer layer,
const StridedSliceDescriptor stridedSliceDescriptor,
const char *  name = nullptr 
)
overridevirtual

Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
stridedSliceDescriptor- Parameters for the strided slice operation.
name- Optional name for the layer.

Implements ILayerVisitor.

Definition at line 326 of file DynamicQuantizationVisitor.cpp.

References armnn::IgnoreUnused().

329 {
330  IgnoreUnused(stridedSliceDescriptor);
331  IgnoreUnused(name);
332  AddToNonCalibratedLayers(layer);
333 }
void IgnoreUnused(Ts &&...)

The documentation for this class was generated from the following files: