ArmNN
 21.02
IDeserializer::DeserializerImpl Class Reference

#include <Deserializer.hpp>

Public Member Functions

armnn::INetworkPtr CreateNetworkFromBinary (const std::vector< uint8_t > &binaryContent)
 Create an input network from binary file contents. More...
 
armnn::INetworkPtr CreateNetworkFromBinary (std::istream &binaryContent)
 Create an input network from a binary input stream. More...
 
BindingPointInfo GetNetworkInputBindingInfo (unsigned int layerId, const std::string &name) const
 Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name. More...
 
BindingPointInfo GetNetworkOutputBindingInfo (unsigned int layerId, const std::string &name) const
 Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name. More...
 
 DeserializerImpl ()
 
 ~DeserializerImpl ()=default
 
 DeserializerImpl (const DeserializerImpl &)=delete
 
DeserializerImploperator= (const DeserializerImpl &)=delete
 

Static Public Member Functions

static GraphPtr LoadGraphFromBinary (const uint8_t *binaryContent, size_t len)
 
static TensorRawPtrVector GetInputs (const GraphPtr &graph, unsigned int layerIndex)
 
static TensorRawPtrVector GetOutputs (const GraphPtr &graph, unsigned int layerIndex)
 
static LayerBaseRawPtr GetBaseLayer (const GraphPtr &graphPtr, unsigned int layerIndex)
 
static int32_t GetBindingLayerInfo (const GraphPtr &graphPtr, unsigned int layerIndex)
 
static std::string GetLayerName (const GraphPtr &graph, unsigned int index)
 
static armnn::Pooling2dDescriptor GetPoolingDescriptor (PoolingDescriptor pooling2dDescriptor, unsigned int layerIndex)
 
static armnn::NormalizationDescriptor GetNormalizationDescriptor (NormalizationDescriptorPtr normalizationDescriptor, unsigned int layerIndex)
 
static armnn::LstmDescriptor GetLstmDescriptor (LstmDescriptorPtr lstmDescriptor)
 
static armnn::LstmInputParams GetLstmInputParams (LstmDescriptorPtr lstmDescriptor, LstmInputParamsPtr lstmInputParams)
 
static armnn::QLstmDescriptor GetQLstmDescriptor (QLstmDescriptorPtr qLstmDescriptorPtr)
 
static armnn::TensorInfo OutputShapeOfReshape (const armnn::TensorInfo &inputTensorInfo, const std::vector< uint32_t > &targetDimsIn)
 

Detailed Description

Definition at line 32 of file Deserializer.hpp.

Constructor & Destructor Documentation

◆ DeserializerImpl() [1/2]

Definition at line 206 of file Deserializer.cpp.

References armnnSerializer::Layer_AbsLayer, armnnSerializer::Layer_ActivationLayer, armnnSerializer::Layer_AdditionLayer, armnnSerializer::Layer_ArgMinMaxLayer, armnnSerializer::Layer_BatchNormalizationLayer, armnnSerializer::Layer_BatchToSpaceNdLayer, armnnSerializer::Layer_ComparisonLayer, armnnSerializer::Layer_ConcatLayer, armnnSerializer::Layer_ConstantLayer, armnnSerializer::Layer_Convolution2dLayer, armnnSerializer::Layer_DepthToSpaceLayer, armnnSerializer::Layer_DepthwiseConvolution2dLayer, armnnSerializer::Layer_DequantizeLayer, armnnSerializer::Layer_DetectionPostProcessLayer, armnnSerializer::Layer_DivisionLayer, armnnSerializer::Layer_ElementwiseUnaryLayer, armnnSerializer::Layer_EqualLayer, armnnSerializer::Layer_FillLayer, armnnSerializer::Layer_FloorLayer, armnnSerializer::Layer_FullyConnectedLayer, armnnSerializer::Layer_GatherLayer, armnnSerializer::Layer_GreaterLayer, armnnSerializer::Layer_InstanceNormalizationLayer, armnnSerializer::Layer_L2NormalizationLayer, armnnSerializer::Layer_LogicalBinaryLayer, armnnSerializer::Layer_LogSoftmaxLayer, armnnSerializer::Layer_LstmLayer, armnnSerializer::Layer_MaximumLayer, armnnSerializer::Layer_MeanLayer, armnnSerializer::Layer_MergeLayer, armnnSerializer::Layer_MergerLayer, armnnSerializer::Layer_MinimumLayer, armnnSerializer::Layer_MultiplicationLayer, armnnSerializer::Layer_NormalizationLayer, armnnSerializer::Layer_PadLayer, armnnSerializer::Layer_PermuteLayer, armnnSerializer::Layer_Pooling2dLayer, armnnSerializer::Layer_PreluLayer, armnnSerializer::Layer_QLstmLayer, armnnSerializer::Layer_QuantizedLstmLayer, armnnSerializer::Layer_QuantizeLayer, armnnSerializer::Layer_RankLayer, armnnSerializer::Layer_ReduceLayer, armnnSerializer::Layer_ReshapeLayer, armnnSerializer::Layer_ResizeBilinearLayer, armnnSerializer::Layer_ResizeLayer, armnnSerializer::Layer_RsqrtLayer, armnnSerializer::Layer_SliceLayer, armnnSerializer::Layer_SoftmaxLayer, armnnSerializer::Layer_SpaceToBatchNdLayer, armnnSerializer::Layer_SpaceToDepthLayer, armnnSerializer::Layer_SplitterLayer, armnnSerializer::Layer_StackLayer, armnnSerializer::Layer_StandInLayer, armnnSerializer::Layer_StridedSliceLayer, armnnSerializer::Layer_SubtractionLayer, armnnSerializer::Layer_SwitchLayer, armnnSerializer::Layer_TransposeConvolution2dLayer, and armnnSerializer::Layer_TransposeLayer.

207 : m_Network(nullptr, nullptr),
208 //May require LayerType_Max to be included
209 m_ParserFunctions(Layer_MAX+1, &IDeserializer::DeserializerImpl::ParseUnsupportedLayer)
210 {
211  // register supported layers
212  m_ParserFunctions[Layer_AbsLayer] = &DeserializerImpl::ParseAbs;
213  m_ParserFunctions[Layer_ActivationLayer] = &DeserializerImpl::ParseActivation;
214  m_ParserFunctions[Layer_AdditionLayer] = &DeserializerImpl::ParseAdd;
215  m_ParserFunctions[Layer_ArgMinMaxLayer] = &DeserializerImpl::ParseArgMinMax;
216  m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &DeserializerImpl::ParseBatchToSpaceNd;
217  m_ParserFunctions[Layer_BatchNormalizationLayer] = &DeserializerImpl::ParseBatchNormalization;
218  m_ParserFunctions[Layer_ComparisonLayer] = &DeserializerImpl::ParseComparison;
219  m_ParserFunctions[Layer_ConcatLayer] = &DeserializerImpl::ParseConcat;
220  m_ParserFunctions[Layer_ConstantLayer] = &DeserializerImpl::ParseConstant;
221  m_ParserFunctions[Layer_Convolution2dLayer] = &DeserializerImpl::ParseConvolution2d;
222  m_ParserFunctions[Layer_DepthToSpaceLayer] = &DeserializerImpl::ParseDepthToSpace;
223  m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &DeserializerImpl::ParseDepthwiseConvolution2d;
224  m_ParserFunctions[Layer_DequantizeLayer] = &DeserializerImpl::ParseDequantize;
225  m_ParserFunctions[Layer_DetectionPostProcessLayer] = &DeserializerImpl::ParseDetectionPostProcess;
226  m_ParserFunctions[Layer_DivisionLayer] = &DeserializerImpl::ParseDivision;
227  m_ParserFunctions[Layer_ElementwiseUnaryLayer] = &DeserializerImpl::ParseElementwiseUnary;
228  m_ParserFunctions[Layer_EqualLayer] = &DeserializerImpl::ParseEqual;
229  m_ParserFunctions[Layer_FullyConnectedLayer] = &DeserializerImpl::ParseFullyConnected;
230  m_ParserFunctions[Layer_FillLayer] = &DeserializerImpl::ParseFill;
231  m_ParserFunctions[Layer_FloorLayer] = &DeserializerImpl::ParseFloor;
232  m_ParserFunctions[Layer_GatherLayer] = &DeserializerImpl::ParseGather;
233  m_ParserFunctions[Layer_GreaterLayer] = &DeserializerImpl::ParseGreater;
234  m_ParserFunctions[Layer_InstanceNormalizationLayer] = &DeserializerImpl::ParseInstanceNormalization;
235  m_ParserFunctions[Layer_L2NormalizationLayer] = &DeserializerImpl::ParseL2Normalization;
236  m_ParserFunctions[Layer_LogicalBinaryLayer] = &DeserializerImpl::ParseLogicalBinary;
237  m_ParserFunctions[Layer_LogSoftmaxLayer] = &DeserializerImpl::ParseLogSoftmax;
238  m_ParserFunctions[Layer_LstmLayer] = &DeserializerImpl::ParseLstm;
239  m_ParserFunctions[Layer_MaximumLayer] = &DeserializerImpl::ParseMaximum;
240  m_ParserFunctions[Layer_MeanLayer] = &DeserializerImpl::ParseMean;
241  m_ParserFunctions[Layer_MinimumLayer] = &DeserializerImpl::ParseMinimum;
242  m_ParserFunctions[Layer_MergeLayer] = &DeserializerImpl::ParseMerge;
243  m_ParserFunctions[Layer_MergerLayer] = &DeserializerImpl::ParseConcat;
244  m_ParserFunctions[Layer_MultiplicationLayer] = &DeserializerImpl::ParseMultiplication;
245  m_ParserFunctions[Layer_NormalizationLayer] = &DeserializerImpl::ParseNormalization;
246  m_ParserFunctions[Layer_PadLayer] = &DeserializerImpl::ParsePad;
247  m_ParserFunctions[Layer_PermuteLayer] = &DeserializerImpl::ParsePermute;
248  m_ParserFunctions[Layer_Pooling2dLayer] = &DeserializerImpl::ParsePooling2d;
249  m_ParserFunctions[Layer_PreluLayer] = &DeserializerImpl::ParsePrelu;
250  m_ParserFunctions[Layer_QLstmLayer] = &DeserializerImpl::ParseQLstm;
251  m_ParserFunctions[Layer_QuantizeLayer] = &DeserializerImpl::ParseQuantize;
252  m_ParserFunctions[Layer_QuantizedLstmLayer] = &DeserializerImpl::ParseQuantizedLstm;
253  m_ParserFunctions[Layer_RankLayer] = &DeserializerImpl::ParseRank;
254  m_ParserFunctions[Layer_ReduceLayer] = &DeserializerImpl::ParseReduce;
255  m_ParserFunctions[Layer_ReshapeLayer] = &DeserializerImpl::ParseReshape;
256  m_ParserFunctions[Layer_ResizeBilinearLayer] = &DeserializerImpl::ParseResizeBilinear;
257  m_ParserFunctions[Layer_ResizeLayer] = &DeserializerImpl::ParseResize;
258  m_ParserFunctions[Layer_RsqrtLayer] = &DeserializerImpl::ParseRsqrt;
259  m_ParserFunctions[Layer_SliceLayer] = &DeserializerImpl::ParseSlice;
260  m_ParserFunctions[Layer_SoftmaxLayer] = &DeserializerImpl::ParseSoftmax;
261  m_ParserFunctions[Layer_SpaceToBatchNdLayer] = &DeserializerImpl::ParseSpaceToBatchNd;
262  m_ParserFunctions[Layer_SpaceToDepthLayer] = &DeserializerImpl::ParseSpaceToDepth;
263  m_ParserFunctions[Layer_SplitterLayer] = &DeserializerImpl::ParseSplitter;
264  m_ParserFunctions[Layer_StackLayer] = &DeserializerImpl::ParseStack;
265  m_ParserFunctions[Layer_StandInLayer] = &DeserializerImpl::ParseStandIn;
266  m_ParserFunctions[Layer_StridedSliceLayer] = &DeserializerImpl::ParseStridedSlice;
267  m_ParserFunctions[Layer_SubtractionLayer] = &DeserializerImpl::ParseSubtraction;
268  m_ParserFunctions[Layer_SwitchLayer] = &DeserializerImpl::ParseSwitch;
269  m_ParserFunctions[Layer_TransposeConvolution2dLayer] = &DeserializerImpl::ParseTransposeConvolution2d;
270  m_ParserFunctions[Layer_TransposeLayer] = &DeserializerImpl::ParseTranspose;
271 }

◆ ~DeserializerImpl()

~DeserializerImpl ( )
default

◆ DeserializerImpl() [2/2]

DeserializerImpl ( const DeserializerImpl )
delete

Member Function Documentation

◆ CreateNetworkFromBinary() [1/2]

INetworkPtr CreateNetworkFromBinary ( const std::vector< uint8_t > &  binaryContent)

Create an input network from binary file contents.

Definition at line 764 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

765 {
766  ResetParser();
767  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
768  return CreateNetworkFromGraph(graph);
769 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
const armnnSerializer::SerializedGraph * GraphPtr

◆ CreateNetworkFromBinary() [2/2]

armnn::INetworkPtr CreateNetworkFromBinary ( std::istream &  binaryContent)

Create an input network from a binary input stream.

Definition at line 771 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

772 {
773  ResetParser();
774  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
775  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
776  return CreateNetworkFromGraph(graph);
777 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
const armnnSerializer::SerializedGraph * GraphPtr

◆ GetBaseLayer()

LayerBaseRawPtr GetBaseLayer ( const GraphPtr graphPtr,
unsigned int  layerIndex 
)
static

Definition at line 273 of file Deserializer.cpp.

References armnnSerializer::Layer_AbsLayer, armnnSerializer::Layer_ActivationLayer, armnnSerializer::Layer_AdditionLayer, armnnSerializer::Layer_ArgMinMaxLayer, armnnSerializer::Layer_BatchNormalizationLayer, armnnSerializer::Layer_BatchToSpaceNdLayer, armnnSerializer::Layer_ComparisonLayer, armnnSerializer::Layer_ConcatLayer, armnnSerializer::Layer_ConstantLayer, armnnSerializer::Layer_Convolution2dLayer, armnnSerializer::Layer_DepthToSpaceLayer, armnnSerializer::Layer_DepthwiseConvolution2dLayer, armnnSerializer::Layer_DequantizeLayer, armnnSerializer::Layer_DetectionPostProcessLayer, armnnSerializer::Layer_DivisionLayer, armnnSerializer::Layer_ElementwiseUnaryLayer, armnnSerializer::Layer_EqualLayer, armnnSerializer::Layer_FillLayer, armnnSerializer::Layer_FloorLayer, armnnSerializer::Layer_FullyConnectedLayer, armnnSerializer::Layer_GatherLayer, armnnSerializer::Layer_GreaterLayer, armnnSerializer::Layer_InputLayer, armnnSerializer::Layer_InstanceNormalizationLayer, armnnSerializer::Layer_L2NormalizationLayer, armnnSerializer::Layer_LogicalBinaryLayer, armnnSerializer::Layer_LogSoftmaxLayer, armnnSerializer::Layer_LstmLayer, armnnSerializer::Layer_MaximumLayer, armnnSerializer::Layer_MeanLayer, armnnSerializer::Layer_MergeLayer, armnnSerializer::Layer_MergerLayer, armnnSerializer::Layer_MinimumLayer, armnnSerializer::Layer_MultiplicationLayer, armnnSerializer::Layer_NONE, armnnSerializer::Layer_NormalizationLayer, armnnSerializer::Layer_OutputLayer, armnnSerializer::Layer_PadLayer, armnnSerializer::Layer_PermuteLayer, armnnSerializer::Layer_Pooling2dLayer, armnnSerializer::Layer_PreluLayer, armnnSerializer::Layer_QLstmLayer, armnnSerializer::Layer_QuantizedLstmLayer, armnnSerializer::Layer_QuantizeLayer, armnnSerializer::Layer_RankLayer, armnnSerializer::Layer_ReduceLayer, armnnSerializer::Layer_ReshapeLayer, armnnSerializer::Layer_ResizeBilinearLayer, armnnSerializer::Layer_ResizeLayer, armnnSerializer::Layer_RsqrtLayer, armnnSerializer::Layer_SliceLayer, armnnSerializer::Layer_SoftmaxLayer, armnnSerializer::Layer_SpaceToBatchNdLayer, armnnSerializer::Layer_SpaceToDepthLayer, armnnSerializer::Layer_SplitterLayer, armnnSerializer::Layer_StackLayer, armnnSerializer::Layer_StandInLayer, armnnSerializer::Layer_StridedSliceLayer, armnnSerializer::Layer_SubtractionLayer, armnnSerializer::Layer_SwitchLayer, armnnSerializer::Layer_TransposeConvolution2dLayer, and armnnSerializer::Layer_TransposeLayer.

Referenced by IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), and IDeserializer::DeserializerImpl::GetOutputs().

274 {
275  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
276 
277  switch(layerType)
278  {
280  return graphPtr->layers()->Get(layerIndex)->layer_as_AbsLayer()->base();
282  return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base();
284  return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base();
286  return graphPtr->layers()->Get(layerIndex)->layer_as_ArgMinMaxLayer()->base();
288  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchToSpaceNdLayer()->base();
290  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchNormalizationLayer()->base();
292  return graphPtr->layers()->Get(layerIndex)->layer_as_ComparisonLayer()->base();
294  return graphPtr->layers()->Get(layerIndex)->layer_as_ConcatLayer()->base();
296  return graphPtr->layers()->Get(layerIndex)->layer_as_ConstantLayer()->base();
298  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
300  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthToSpaceLayer()->base();
302  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthwiseConvolution2dLayer()->base();
304  return graphPtr->layers()->Get(layerIndex)->layer_as_DequantizeLayer()->base();
306  return graphPtr->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer()->base();
308  return graphPtr->layers()->Get(layerIndex)->layer_as_DivisionLayer()->base();
310  return graphPtr->layers()->Get(layerIndex)->layer_as_EqualLayer()->base();
312  return graphPtr->layers()->Get(layerIndex)->layer_as_ElementwiseUnaryLayer()->base();
314  return graphPtr->layers()->Get(layerIndex)->layer_as_FullyConnectedLayer()->base();
316  return graphPtr->layers()->Get(layerIndex)->layer_as_FillLayer()->base();
318  return graphPtr->layers()->Get(layerIndex)->layer_as_FloorLayer()->base();
320  return graphPtr->layers()->Get(layerIndex)->layer_as_GatherLayer()->base();
322  return graphPtr->layers()->Get(layerIndex)->layer_as_GreaterLayer()->base();
324  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base();
326  return graphPtr->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer()->base();
328  return graphPtr->layers()->Get(layerIndex)->layer_as_L2NormalizationLayer()->base();
330  return graphPtr->layers()->Get(layerIndex)->layer_as_LogicalBinaryLayer()->base();
332  return graphPtr->layers()->Get(layerIndex)->layer_as_LogSoftmaxLayer()->base();
334  return graphPtr->layers()->Get(layerIndex)->layer_as_LstmLayer()->base();
336  return graphPtr->layers()->Get(layerIndex)->layer_as_MeanLayer()->base();
338  return graphPtr->layers()->Get(layerIndex)->layer_as_MinimumLayer()->base();
340  return graphPtr->layers()->Get(layerIndex)->layer_as_MaximumLayer()->base();
342  return graphPtr->layers()->Get(layerIndex)->layer_as_MergeLayer()->base();
344  return graphPtr->layers()->Get(layerIndex)->layer_as_MergerLayer()->base();
346  return graphPtr->layers()->Get(layerIndex)->layer_as_MultiplicationLayer()->base();
348  return graphPtr->layers()->Get(layerIndex)->layer_as_NormalizationLayer()->base();
350  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->base();
352  return graphPtr->layers()->Get(layerIndex)->layer_as_PadLayer()->base();
354  return graphPtr->layers()->Get(layerIndex)->layer_as_PermuteLayer()->base();
356  return graphPtr->layers()->Get(layerIndex)->layer_as_Pooling2dLayer()->base();
358  return graphPtr->layers()->Get(layerIndex)->layer_as_PreluLayer()->base();
360  return graphPtr->layers()->Get(layerIndex)->layer_as_QLstmLayer()->base();
362  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizeLayer()->base();
364  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizedLstmLayer()->base();
366  return graphPtr->layers()->Get(layerIndex)->layer_as_RankLayer()->base();
368  return graphPtr->layers()->Get(layerIndex)->layer_as_ReduceLayer()->base();
370  return graphPtr->layers()->Get(layerIndex)->layer_as_ReshapeLayer()->base();
372  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeBilinearLayer()->base();
374  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeLayer()->base();
376  return graphPtr->layers()->Get(layerIndex)->layer_as_RsqrtLayer()->base();
378  return graphPtr->layers()->Get(layerIndex)->layer_as_SliceLayer()->base();
380  return graphPtr->layers()->Get(layerIndex)->layer_as_SoftmaxLayer()->base();
382  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToBatchNdLayer()->base();
384  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToDepthLayer()->base();
386  return graphPtr->layers()->Get(layerIndex)->layer_as_SplitterLayer()->base();
388  return graphPtr->layers()->Get(layerIndex)->layer_as_StackLayer()->base();
390  return graphPtr->layers()->Get(layerIndex)->layer_as_StandInLayer()->base();
392  return graphPtr->layers()->Get(layerIndex)->layer_as_StridedSliceLayer()->base();
394  return graphPtr->layers()->Get(layerIndex)->layer_as_SubtractionLayer()->base();
396  return graphPtr->layers()->Get(layerIndex)->layer_as_SwitchLayer()->base();
398  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeConvolution2dLayer()->base();
400  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeLayer()->base();
401  case Layer::Layer_NONE:
402  default:
403  throw ParseException(fmt::format("Layer type {} not recognized", layerType));
404  }
405 }

◆ GetBindingLayerInfo()

int32_t GetBindingLayerInfo ( const GraphPtr graphPtr,
unsigned int  layerIndex 
)
static

Definition at line 414 of file Deserializer.cpp.

References armnnSerializer::Layer_InputLayer, and armnnSerializer::Layer_OutputLayer.

Referenced by IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo().

415 {
416  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
417 
418  if (layerType == Layer::Layer_InputLayer)
419  {
420  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
421  }
422  else if ( layerType == Layer::Layer_OutputLayer )
423  {
424  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
425  }
426  return 0;
427 }

◆ GetInputs()

TensorRawPtrVector GetInputs ( const GraphPtr graph,
unsigned int  layerIndex 
)
static

Definition at line 713 of file Deserializer.cpp.

References CHECK_LAYERS, CHECKED_NON_NEGATIVE, and IDeserializer::DeserializerImpl::GetBaseLayer().

Referenced by IDeserializer::DeserializerImpl::GetLstmDescriptor(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), IDeserializer::DeserializerImpl::GetNormalizationDescriptor(), armnnDeserializer::GetOriginsDescriptor(), IDeserializer::DeserializerImpl::GetPoolingDescriptor(), IDeserializer::DeserializerImpl::GetQLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

714 {
715  CHECK_LAYERS(graphPtr, 0, layerIndex);
716  auto layer = GetBaseLayer(graphPtr, layerIndex);
717  const auto& numInputs = layer->inputSlots()->size();
718 
719  TensorRawPtrVector result(numInputs);
720 
721  for (unsigned int i=0; i<numInputs; ++i)
722  {
723  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
724  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
725  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
726  }
727  return result;
728 }
#define CHECK_LAYERS(GRAPH, LAYERS_INDEX, LAYER_INDEX)
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)
std::vector< TensorRawPtr > TensorRawPtrVector
#define CHECKED_NON_NEGATIVE(VALUE)

◆ GetLayerName()

◆ GetLstmDescriptor()

armnn::LstmDescriptor GetLstmDescriptor ( LstmDescriptorPtr  lstmDescriptor)
static

Definition at line 2657 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetLayerNormWeights, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputLayerNormWeights, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, LstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputLayerNormWeights, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), and armnnDeserializer::ToTensorInfo().

2658 {
2659  armnn::LstmDescriptor desc;
2660 
2661  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2662  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2663  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2664  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2665  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2666  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2667  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2668 
2669  return desc;
2670 }
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
An LstmDescriptor for the LstmLayer.
bool m_PeepholeEnabled
Enable/disable peephole.
uint32_t m_ActivationFunc
The activation function to use.
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
bool m_LayerNormEnabled
Enable/disable layer normalization.

◆ GetLstmInputParams()

static armnn::LstmInputParams GetLstmInputParams ( LstmDescriptorPtr  lstmDescriptor,
LstmInputParamsPtr  lstmInputParams 
)
static

◆ GetNetworkInputBindingInfo()

BindingPointInfo GetNetworkInputBindingInfo ( unsigned int  layerId,
const std::string &  name 
) const

Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name.

Definition at line 838 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

840 {
841  IgnoreUnused(layerIndex);
842  for (auto inputBinding : m_InputBindings)
843  {
844  if (inputBinding.first == name)
845  {
846  return inputBinding.second;
847  }
848  }
849  throw ParseException(fmt::format("No input binding found for layer:{0} / {1}",
850  name,
851  CHECK_LOCATION().AsString()));
852 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ GetNetworkOutputBindingInfo()

BindingPointInfo GetNetworkOutputBindingInfo ( unsigned int  layerId,
const std::string &  name 
) const

Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name.

Definition at line 854 of file Deserializer.cpp.

References armnn::Abs, anchors(), ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_GRAPH, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnn::Equal, IDeserializer::DeserializerImpl::GetBaseLayer(), IDeserializer::DeserializerImpl::GetBindingLayerInfo(), IDeserializer::DeserializerImpl::GetInputs(), IConnectableLayer::GetInputSlot(), IDeserializer::DeserializerImpl::GetLayerName(), IConnectableLayer::GetNumInputSlots(), IConnectableLayer::GetNumOutputSlots(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::Greater, armnn::IgnoreUnused(), armnnSerializer::Layer_InputLayer, armnnSerializer::Layer_OutputLayer, ActivationDescriptor::m_A, ArgMinMaxDescriptor::m_Axis, ActivationDescriptor::m_B, SoftmaxDescriptor::m_Beta, InstanceNormalizationDescriptor::m_Beta, Convolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_BiasEnabled, BatchToSpaceNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, BatchToSpaceNdDescriptor::m_Crops, Convolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DataLayout, L2NormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_DataLayout, InstanceNormalizationDescriptor::m_DataLayout, BatchToSpaceNdDescriptor::m_DataLayout, SpaceToDepthDescriptor::m_DataLayout, DetectionPostProcessDescriptor::m_DetectionsPerClass, Convolution2dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationX, Convolution2dDescriptor::m_DilationY, DepthwiseConvolution2dDescriptor::m_DilationY, L2NormalizationDescriptor::m_Eps, BatchNormalizationDescriptor::m_Eps, InstanceNormalizationDescriptor::m_Eps, ActivationDescriptor::m_Function, ArgMinMaxDescriptor::m_Function, InstanceNormalizationDescriptor::m_Gamma, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, LogicalBinaryDescriptor::m_Operation, Convolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_PadTop, DetectionPostProcessDescriptor::m_ScaleH, DetectionPostProcessDescriptor::m_ScaleW, DetectionPostProcessDescriptor::m_ScaleX, DetectionPostProcessDescriptor::m_ScaleY, Convolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, DepthwiseConvolution2dDescriptor::m_StrideY, DetectionPostProcessDescriptor::m_UseRegularNms, armnn::numeric_cast(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToActivationFunction(), armnnDeserializer::ToArgMinMaxFunction(), armnnDeserializer::ToConstTensor(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToLogicalBinaryOperation(), and armnnDeserializer::ToTensorInfo().

856 {
857  IgnoreUnused(layerIndex);
858  for (auto outputBinding : m_OutputBindings)
859  {
860  if (outputBinding.first == name)
861  {
862  return outputBinding.second;
863  }
864  }
865  throw ParseException(fmt::format("No output binding found for layer:{0} / {1}",
866  name,
867  CHECK_LOCATION().AsString()));
868 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ GetNormalizationDescriptor()

armnn::NormalizationDescriptor GetNormalizationDescriptor ( NormalizationDescriptorPtr  normalizationDescriptor,
unsigned int  layerIndex 
)
static

Definition at line 2348 of file Deserializer.cpp.

References armnn::Across, ARMNN_ASSERT_MSG, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnnSerializer::DataLayout_NCHW, armnnSerializer::DataLayout_NHWC, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::IgnoreUnused(), armnn::LocalBrightness, armnn::LocalContrast, NormalizationDescriptor::m_Alpha, GatherDescriptor::m_Axis, MeanDescriptor::m_Axis, SliceDescriptor::m_Begin, NormalizationDescriptor::m_Beta, NormalizationDescriptor::m_DataLayout, NormalizationDescriptor::m_K, MeanDescriptor::m_KeepDims, NormalizationDescriptor::m_NormChannelType, NormalizationDescriptor::m_NormMethodType, NormalizationDescriptor::m_NormSize, SliceDescriptor::m_Size, armnn::NCHW, armnn::NHWC, armnnSerializer::NormalizationAlgorithmChannel_Across, armnnSerializer::NormalizationAlgorithmChannel_Within, armnnSerializer::NormalizationAlgorithmMethod_LocalBrightness, armnnSerializer::NormalizationAlgorithmMethod_LocalContrast, armnn::Rsqrt, IOutputSlot::SetTensorInfo(), ViewsDescriptor::SetViewOriginCoord(), ViewsDescriptor::SetViewSize(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToTensorInfo(), and armnn::Within.

2351 {
2352  IgnoreUnused(layerIndex);
2354 
2355  switch (normalizationDescriptor->normChannelType())
2356  {
2358  {
2360  break;
2361  }
2363  {
2365  break;
2366  }
2367  default:
2368  {
2369  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2370  }
2371  }
2372 
2373  switch (normalizationDescriptor->normMethodType())
2374  {
2376  {
2378  break;
2379  }
2381  {
2383  break;
2384  }
2385  default:
2386  {
2387  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2388  }
2389  }
2390 
2391  switch (normalizationDescriptor->dataLayout())
2392  {
2393  case DataLayout_NCHW:
2394  {
2396  break;
2397  }
2398  case DataLayout_NHWC:
2399  {
2401  break;
2402  }
2403  default:
2404  {
2405  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2406  }
2407  }
2408 
2409  desc.m_Alpha = normalizationDescriptor->alpha();
2410  desc.m_Beta = normalizationDescriptor->beta();
2411  desc.m_K = normalizationDescriptor->k();
2412  desc.m_NormSize = normalizationDescriptor->normSize();
2413 
2414  return desc;
2415 }
float m_K
Kappa value used for the across channel normalization equation.
float m_Alpha
Alpha value for the normalization equation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void IgnoreUnused(Ts &&...)
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
Jarret 2009: Local Contrast Normalization.
Krichevsky 2012: Local Brightness Normalization.
A NormalizationDescriptor for the NormalizationLayer.
float m_Beta
Beta value for the normalization equation.
uint32_t m_NormSize
Depth radius value.

◆ GetOutputs()

TensorRawPtrVector GetOutputs ( const GraphPtr graph,
unsigned int  layerIndex 
)
static

Definition at line 730 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, and IDeserializer::DeserializerImpl::GetBaseLayer().

Referenced by IDeserializer::DeserializerImpl::GetLstmDescriptor(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), IDeserializer::DeserializerImpl::GetNormalizationDescriptor(), armnnDeserializer::GetOriginsDescriptor(), IDeserializer::DeserializerImpl::GetPoolingDescriptor(), IDeserializer::DeserializerImpl::GetQLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

731 {
732  CHECK_LAYERS(graphPtr, 0, layerIndex);
733  auto layer = GetBaseLayer(graphPtr, layerIndex);
734  const auto& numOutputs = layer->outputSlots()->size();
735 
736  TensorRawPtrVector result(numOutputs);
737 
738  for (unsigned int i=0; i<numOutputs; ++i)
739  {
740  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
741  }
742  return result;
743 }
#define CHECK_LAYERS(GRAPH, LAYERS_INDEX, LAYER_INDEX)
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)
std::vector< TensorRawPtr > TensorRawPtrVector

◆ GetPoolingDescriptor()

armnn::Pooling2dDescriptor GetPoolingDescriptor ( PoolingDescriptor  pooling2dDescriptor,
unsigned int  layerIndex 
)
static

Definition at line 1941 of file Deserializer.cpp.

References ARMNN_ASSERT_MSG, armnn::Average, armnn::Ceiling, CHECK_LAYERS, CHECK_VALID_SIZE, armnnSerializer::DataLayout_NCHW, armnnSerializer::DataLayout_NHWC, armnn::Exclude, armnn::Floor, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::IgnoreUnused(), armnn::IgnoreValue, Pooling2dDescriptor::m_DataLayout, Pooling2dDescriptor::m_OutputShapeRounding, Pooling2dDescriptor::m_PadBottom, Pooling2dDescriptor::m_PaddingMethod, Pooling2dDescriptor::m_PadLeft, Pooling2dDescriptor::m_PadRight, Pooling2dDescriptor::m_PadTop, Pooling2dDescriptor::m_PoolHeight, Pooling2dDescriptor::m_PoolType, Pooling2dDescriptor::m_PoolWidth, Pooling2dDescriptor::m_StrideX, Pooling2dDescriptor::m_StrideY, armnn::Max, armnn::NCHW, armnn::NHWC, armnnSerializer::OutputShapeRounding_Ceiling, armnnSerializer::OutputShapeRounding_Floor, armnnSerializer::PaddingMethod_Exclude, armnnSerializer::PaddingMethod_IgnoreValue, armnnSerializer::PoolingAlgorithm_Average, armnnSerializer::PoolingAlgorithm_Max, IOutputSlot::SetTensorInfo(), and armnnDeserializer::ToTensorInfo().

1943 {
1944  IgnoreUnused(layerIndex);
1946 
1947  switch (pooling2dDesc->poolType())
1948  {
1950  {
1952  break;
1953  }
1954  case PoolingAlgorithm_Max:
1955  {
1957  break;
1958  }
1959  default:
1960  {
1961  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
1962  }
1963  }
1964 
1965  switch (pooling2dDesc->outputShapeRounding())
1966  {
1968  {
1970  break;
1971  }
1973  {
1975  break;
1976  }
1977  default:
1978  {
1979  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
1980  }
1981  }
1982 
1983  switch (pooling2dDesc->paddingMethod())
1984  {
1985  case PaddingMethod_Exclude:
1986  {
1988  break;
1989  }
1991  {
1993  break;
1994  }
1995  default:
1996  {
1997  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
1998  }
1999  }
2000 
2001  switch (pooling2dDesc->dataLayout())
2002  {
2003  case DataLayout_NCHW:
2004  {
2006  break;
2007  }
2008  case DataLayout_NHWC:
2009  {
2011  break;
2012  }
2013  default:
2014  {
2015  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2016  }
2017  }
2018 
2019  desc.m_PadRight = pooling2dDesc->padRight();
2020  desc.m_PadLeft = pooling2dDesc->padLeft();
2021  desc.m_PadBottom = pooling2dDesc->padBottom();
2022  desc.m_PadTop = pooling2dDesc->padTop();
2023  desc.m_StrideX = pooling2dDesc->strideX();
2024  desc.m_StrideY = pooling2dDesc->strideY();
2025  desc.m_PoolWidth = pooling2dDesc->poolWidth();
2026  desc.m_PoolHeight = pooling2dDesc->poolHeight();
2027 
2028  return desc;
2029 }
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_PoolWidth
Pooling width value.
The padding fields don&#39;t count and are ignored.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_PadTop
Padding top value in the height dimension.
void IgnoreUnused(Ts &&...)
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadRight
Padding right value in the width dimension.
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
The padding fields count, but are ignored.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
A Pooling2dDescriptor for the Pooling2dLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.

◆ GetQLstmDescriptor()

armnn::QLstmDescriptor GetQLstmDescriptor ( QLstmDescriptorPtr  qLstmDescriptorPtr)
static

Definition at line 2788 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), TransposeConvolution2dDescriptor::m_BiasEnabled, QuantizedLstmInputParams::m_CellBias, LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CellIntermediateScale, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, TransposeConvolution2dDescriptor::m_DataLayout, QuantizedLstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetGateBias, QLstmDescriptor::m_ForgetIntermediateScale, LstmInputParams::m_ForgetLayerNormWeights, QLstmDescriptor::m_HiddenStateScale, QLstmDescriptor::m_HiddenStateZeroPoint, QuantizedLstmInputParams::m_InputGateBias, LstmInputParams::m_InputGateBias, QLstmDescriptor::m_InputIntermediateScale, LstmInputParams::m_InputLayerNormWeights, QuantizedLstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, LstmInputParams::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, StandInDescriptor::m_NumInputs, StandInDescriptor::m_NumOutputs, QuantizedLstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_OutputIntermediateScale, LstmInputParams::m_OutputLayerNormWeights, TransposeConvolution2dDescriptor::m_PadBottom, TransposeConvolution2dDescriptor::m_PadLeft, TransposeConvolution2dDescriptor::m_PadRight, TransposeConvolution2dDescriptor::m_PadTop, QLstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, QLstmDescriptor::m_ProjectionClip, QLstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, QuantizedLstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, LstmInputParams::m_RecurrentToOutputWeights, TransposeConvolution2dDescriptor::m_StrideX, TransposeConvolution2dDescriptor::m_StrideY, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), armnnDeserializer::ToDataLayout(), and armnnDeserializer::ToTensorInfo().

2789 {
2791 
2792  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
2793  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
2794  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
2795  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
2796 
2797  desc.m_CellClip = qLstmDescriptor->cellClip();
2798  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
2799 
2800  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
2801  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
2802  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
2803  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
2804 
2805  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
2806  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
2807 
2808  return desc;
2809 }
bool m_PeepholeEnabled
Enable/disable peephole.
float m_HiddenStateScale
Hidden State quantization scale.
float m_OutputIntermediateScale
Output intermediate quantization scale.
bool m_LayerNormEnabled
Enable/disable layer normalization.
float m_ProjectionClip
Clipping threshold value for the projection.
float m_InputIntermediateScale
Input intermediate quantization scale.
A QLstmDescriptor for the QLstmLayer.
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
float m_CellClip
Clipping threshold value for the cell state.
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_CellIntermediateScale
Cell intermediate quantization scale.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
int32_t m_HiddenStateZeroPoint
Hidden State zero point.

◆ LoadGraphFromBinary()

GraphPtr LoadGraphFromBinary ( const uint8_t *  binaryContent,
size_t  len 
)
static

Definition at line 779 of file Deserializer.cpp.

References ARMNN_ASSERT, CHECK_LOCATION, IOutputSlot::Connect(), armnnSerializer::GetSerializedGraph(), armnnSerializer::Layer_InputLayer, and armnnSerializer::Layer_OutputLayer.

Referenced by IDeserializer::DeserializerImpl::CreateNetworkFromBinary().

780 {
781  if (binaryContent == nullptr)
782  {
783  throw InvalidArgumentException(fmt::format("Invalid (null) binary content {}",
784  CHECK_LOCATION().AsString()));
785  }
786  flatbuffers::Verifier verifier(binaryContent, len);
787  if (verifier.VerifyBuffer<SerializedGraph>() == false)
788  {
789  throw ParseException(fmt::format("Buffer doesn't conform to the expected Armnn "
790  "flatbuffers format. size:{0} {1}",
791  len,
792  CHECK_LOCATION().AsString()));
793  }
794  return GetSerializedGraph(binaryContent);
795 }
const armnnSerializer::SerializedGraph * GetSerializedGraph(const void *buf)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ operator=()

DeserializerImpl& operator= ( const DeserializerImpl )
delete

◆ OutputShapeOfReshape()

armnn::TensorInfo OutputShapeOfReshape ( const armnn::TensorInfo inputTensorInfo,
const std::vector< uint32_t > &  targetDimsIn 
)
static

Definition at line 2073 of file Deserializer.cpp.

References armnn::Bilinear, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnnDeserializer::CheckShape(), IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), TensorInfo::GetNumElements(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), ResizeDescriptor::m_AlignCorners, SoftmaxDescriptor::m_Beta, SpaceToBatchNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, ResizeDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToDepthDescriptor::m_DataLayout, ResizeDescriptor::m_HalfPixelCenters, ReduceDescriptor::m_KeepDims, ResizeDescriptor::m_Method, SpaceToBatchNdDescriptor::m_PadList, ReduceDescriptor::m_ReduceOperation, ResizeDescriptor::m_TargetHeight, ReshapeDescriptor::m_TargetShape, ResizeDescriptor::m_TargetWidth, ReduceDescriptor::m_vAxis, armnn::numeric_cast(), TensorInfo::SetShape(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToReduceOperation(), armnnDeserializer::ToResizeMethod(), and armnnDeserializer::ToTensorInfo().

2075 {
2076  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
2077  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
2078 
2079  if (stretchDim != targetDimsIn.end())
2080  {
2081  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2082  {
2083  throw ParseException(fmt::format("At most one component of shape can be -1 {}",
2084  CHECK_LOCATION().AsString()));
2085  }
2086 
2087  auto targetNumElements =
2088  armnn::numeric_cast<unsigned int>(
2089  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2090 
2091  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2092  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2093  }
2094 
2095  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2096 
2097  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2098  reshapeInfo.SetShape(outputShape);
2099 
2100  return reshapeInfo;
2101 }
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
unsigned int GetNumElements() const
Definition: Tensor.hpp:192

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