ArmNN
 21.11
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::UnidirectionalSequenceLstmDescriptor GetUnidirectionalSequenceLstmDescriptor (UnidirectionalSequenceLstmDescriptorPtr descriptor)
 
static armnn::TensorInfo OutputShapeOfReshape (const armnn::TensorInfo &inputTensorInfo, const std::vector< uint32_t > &targetDimsIn)
 

Detailed Description

Definition at line 33 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_CastLayer, armnnSerializer::Layer_ChannelShuffleLayer, armnnSerializer::Layer_ComparisonLayer, armnnSerializer::Layer_ConcatLayer, armnnSerializer::Layer_ConstantLayer, armnnSerializer::Layer_Convolution2dLayer, armnnSerializer::Layer_Convolution3dLayer, 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_ShapeLayer, 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, armnnSerializer::Layer_TransposeLayer, and armnnSerializer::Layer_UnidirectionalSequenceLstmLayer.

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_CastLayer] = &DeserializerImpl::ParseCast;
219  m_ParserFunctions[Layer_ChannelShuffleLayer] = &DeserializerImpl::ParseChannelShuffle;
220  m_ParserFunctions[Layer_ComparisonLayer] = &DeserializerImpl::ParseComparison;
221  m_ParserFunctions[Layer_ConcatLayer] = &DeserializerImpl::ParseConcat;
222  m_ParserFunctions[Layer_ConstantLayer] = &DeserializerImpl::ParseConstant;
223  m_ParserFunctions[Layer_Convolution2dLayer] = &DeserializerImpl::ParseConvolution2d;
224  m_ParserFunctions[Layer_Convolution3dLayer] = &DeserializerImpl::ParseConvolution3d;
225  m_ParserFunctions[Layer_DepthToSpaceLayer] = &DeserializerImpl::ParseDepthToSpace;
226  m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &DeserializerImpl::ParseDepthwiseConvolution2d;
227  m_ParserFunctions[Layer_DequantizeLayer] = &DeserializerImpl::ParseDequantize;
228  m_ParserFunctions[Layer_DetectionPostProcessLayer] = &DeserializerImpl::ParseDetectionPostProcess;
229  m_ParserFunctions[Layer_DivisionLayer] = &DeserializerImpl::ParseDivision;
230  m_ParserFunctions[Layer_ElementwiseUnaryLayer] = &DeserializerImpl::ParseElementwiseUnary;
231  m_ParserFunctions[Layer_EqualLayer] = &DeserializerImpl::ParseEqual;
232  m_ParserFunctions[Layer_FullyConnectedLayer] = &DeserializerImpl::ParseFullyConnected;
233  m_ParserFunctions[Layer_FillLayer] = &DeserializerImpl::ParseFill;
234  m_ParserFunctions[Layer_FloorLayer] = &DeserializerImpl::ParseFloor;
235  m_ParserFunctions[Layer_GatherLayer] = &DeserializerImpl::ParseGather;
236  m_ParserFunctions[Layer_GreaterLayer] = &DeserializerImpl::ParseGreater;
237  m_ParserFunctions[Layer_InstanceNormalizationLayer] = &DeserializerImpl::ParseInstanceNormalization;
238  m_ParserFunctions[Layer_L2NormalizationLayer] = &DeserializerImpl::ParseL2Normalization;
239  m_ParserFunctions[Layer_LogicalBinaryLayer] = &DeserializerImpl::ParseLogicalBinary;
240  m_ParserFunctions[Layer_LogSoftmaxLayer] = &DeserializerImpl::ParseLogSoftmax;
241  m_ParserFunctions[Layer_LstmLayer] = &DeserializerImpl::ParseLstm;
242  m_ParserFunctions[Layer_MaximumLayer] = &DeserializerImpl::ParseMaximum;
243  m_ParserFunctions[Layer_MeanLayer] = &DeserializerImpl::ParseMean;
244  m_ParserFunctions[Layer_MinimumLayer] = &DeserializerImpl::ParseMinimum;
245  m_ParserFunctions[Layer_MergeLayer] = &DeserializerImpl::ParseMerge;
246  m_ParserFunctions[Layer_MergerLayer] = &DeserializerImpl::ParseConcat;
247  m_ParserFunctions[Layer_MultiplicationLayer] = &DeserializerImpl::ParseMultiplication;
248  m_ParserFunctions[Layer_NormalizationLayer] = &DeserializerImpl::ParseNormalization;
249  m_ParserFunctions[Layer_PadLayer] = &DeserializerImpl::ParsePad;
250  m_ParserFunctions[Layer_PermuteLayer] = &DeserializerImpl::ParsePermute;
251  m_ParserFunctions[Layer_Pooling2dLayer] = &DeserializerImpl::ParsePooling2d;
252  m_ParserFunctions[Layer_PreluLayer] = &DeserializerImpl::ParsePrelu;
253  m_ParserFunctions[Layer_QLstmLayer] = &DeserializerImpl::ParseQLstm;
254  m_ParserFunctions[Layer_QuantizeLayer] = &DeserializerImpl::ParseQuantize;
255  m_ParserFunctions[Layer_QuantizedLstmLayer] = &DeserializerImpl::ParseQuantizedLstm;
256  m_ParserFunctions[Layer_RankLayer] = &DeserializerImpl::ParseRank;
257  m_ParserFunctions[Layer_ReduceLayer] = &DeserializerImpl::ParseReduce;
258  m_ParserFunctions[Layer_ReshapeLayer] = &DeserializerImpl::ParseReshape;
259  m_ParserFunctions[Layer_ResizeBilinearLayer] = &DeserializerImpl::ParseResizeBilinear;
260  m_ParserFunctions[Layer_ResizeLayer] = &DeserializerImpl::ParseResize;
261  m_ParserFunctions[Layer_RsqrtLayer] = &DeserializerImpl::ParseRsqrt;
262  m_ParserFunctions[Layer_ShapeLayer] = &DeserializerImpl::ParseShape;
263  m_ParserFunctions[Layer_SliceLayer] = &DeserializerImpl::ParseSlice;
264  m_ParserFunctions[Layer_SoftmaxLayer] = &DeserializerImpl::ParseSoftmax;
265  m_ParserFunctions[Layer_SpaceToBatchNdLayer] = &DeserializerImpl::ParseSpaceToBatchNd;
266  m_ParserFunctions[Layer_SpaceToDepthLayer] = &DeserializerImpl::ParseSpaceToDepth;
267  m_ParserFunctions[Layer_SplitterLayer] = &DeserializerImpl::ParseSplitter;
268  m_ParserFunctions[Layer_StackLayer] = &DeserializerImpl::ParseStack;
269  m_ParserFunctions[Layer_StandInLayer] = &DeserializerImpl::ParseStandIn;
270  m_ParserFunctions[Layer_StridedSliceLayer] = &DeserializerImpl::ParseStridedSlice;
271  m_ParserFunctions[Layer_SubtractionLayer] = &DeserializerImpl::ParseSubtraction;
272  m_ParserFunctions[Layer_SwitchLayer] = &DeserializerImpl::ParseSwitch;
273  m_ParserFunctions[Layer_TransposeConvolution2dLayer] = &DeserializerImpl::ParseTransposeConvolution2d;
274  m_ParserFunctions[Layer_TransposeLayer] = &DeserializerImpl::ParseTranspose;
275  m_ParserFunctions[Layer_UnidirectionalSequenceLstmLayer] = &DeserializerImpl::ParseUnidirectionalSequenceLstm;
276 }

◆ ~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 806 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

807 {
808  ResetParser();
809  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
810  return CreateNetworkFromGraph(graph);
811 }
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 813 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

814 {
815  ResetParser();
816  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
817  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
818  return CreateNetworkFromGraph(graph);
819 }
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 278 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_CastLayer, armnnSerializer::Layer_ChannelShuffleLayer, armnnSerializer::Layer_ComparisonLayer, armnnSerializer::Layer_ConcatLayer, armnnSerializer::Layer_ConstantLayer, armnnSerializer::Layer_Convolution2dLayer, armnnSerializer::Layer_Convolution3dLayer, 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_ShapeLayer, 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, armnnSerializer::Layer_TransposeLayer, and armnnSerializer::Layer_UnidirectionalSequenceLstmLayer.

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

279 {
280  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
281 
282  switch(layerType)
283  {
285  return graphPtr->layers()->Get(layerIndex)->layer_as_AbsLayer()->base();
287  return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base();
289  return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base();
291  return graphPtr->layers()->Get(layerIndex)->layer_as_ArgMinMaxLayer()->base();
293  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchToSpaceNdLayer()->base();
295  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchNormalizationLayer()->base();
297  return graphPtr->layers()->Get(layerIndex)->layer_as_CastLayer()->base();
299  return graphPtr->layers()->Get(layerIndex)->layer_as_ChannelShuffleLayer()->base();
301  return graphPtr->layers()->Get(layerIndex)->layer_as_ComparisonLayer()->base();
303  return graphPtr->layers()->Get(layerIndex)->layer_as_ConcatLayer()->base();
305  return graphPtr->layers()->Get(layerIndex)->layer_as_ConstantLayer()->base();
307  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
309  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution3dLayer()->base();
311  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthToSpaceLayer()->base();
313  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthwiseConvolution2dLayer()->base();
315  return graphPtr->layers()->Get(layerIndex)->layer_as_DequantizeLayer()->base();
317  return graphPtr->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer()->base();
319  return graphPtr->layers()->Get(layerIndex)->layer_as_DivisionLayer()->base();
321  return graphPtr->layers()->Get(layerIndex)->layer_as_EqualLayer()->base();
323  return graphPtr->layers()->Get(layerIndex)->layer_as_ElementwiseUnaryLayer()->base();
325  return graphPtr->layers()->Get(layerIndex)->layer_as_FullyConnectedLayer()->base();
327  return graphPtr->layers()->Get(layerIndex)->layer_as_FillLayer()->base();
329  return graphPtr->layers()->Get(layerIndex)->layer_as_FloorLayer()->base();
331  return graphPtr->layers()->Get(layerIndex)->layer_as_GatherLayer()->base();
333  return graphPtr->layers()->Get(layerIndex)->layer_as_GreaterLayer()->base();
335  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base();
337  return graphPtr->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer()->base();
339  return graphPtr->layers()->Get(layerIndex)->layer_as_L2NormalizationLayer()->base();
341  return graphPtr->layers()->Get(layerIndex)->layer_as_LogicalBinaryLayer()->base();
343  return graphPtr->layers()->Get(layerIndex)->layer_as_LogSoftmaxLayer()->base();
345  return graphPtr->layers()->Get(layerIndex)->layer_as_LstmLayer()->base();
347  return graphPtr->layers()->Get(layerIndex)->layer_as_MeanLayer()->base();
349  return graphPtr->layers()->Get(layerIndex)->layer_as_MinimumLayer()->base();
351  return graphPtr->layers()->Get(layerIndex)->layer_as_MaximumLayer()->base();
353  return graphPtr->layers()->Get(layerIndex)->layer_as_MergeLayer()->base();
355  return graphPtr->layers()->Get(layerIndex)->layer_as_MergerLayer()->base();
357  return graphPtr->layers()->Get(layerIndex)->layer_as_MultiplicationLayer()->base();
359  return graphPtr->layers()->Get(layerIndex)->layer_as_NormalizationLayer()->base();
361  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->base();
363  return graphPtr->layers()->Get(layerIndex)->layer_as_PadLayer()->base();
365  return graphPtr->layers()->Get(layerIndex)->layer_as_PermuteLayer()->base();
367  return graphPtr->layers()->Get(layerIndex)->layer_as_Pooling2dLayer()->base();
369  return graphPtr->layers()->Get(layerIndex)->layer_as_PreluLayer()->base();
371  return graphPtr->layers()->Get(layerIndex)->layer_as_QLstmLayer()->base();
373  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizeLayer()->base();
375  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizedLstmLayer()->base();
377  return graphPtr->layers()->Get(layerIndex)->layer_as_RankLayer()->base();
379  return graphPtr->layers()->Get(layerIndex)->layer_as_ReduceLayer()->base();
381  return graphPtr->layers()->Get(layerIndex)->layer_as_ReshapeLayer()->base();
383  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeBilinearLayer()->base();
385  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeLayer()->base();
387  return graphPtr->layers()->Get(layerIndex)->layer_as_RsqrtLayer()->base();
389  return graphPtr->layers()->Get(layerIndex)->layer_as_ShapeLayer()->base();
391  return graphPtr->layers()->Get(layerIndex)->layer_as_SliceLayer()->base();
393  return graphPtr->layers()->Get(layerIndex)->layer_as_SoftmaxLayer()->base();
395  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToBatchNdLayer()->base();
397  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToDepthLayer()->base();
399  return graphPtr->layers()->Get(layerIndex)->layer_as_SplitterLayer()->base();
401  return graphPtr->layers()->Get(layerIndex)->layer_as_StackLayer()->base();
403  return graphPtr->layers()->Get(layerIndex)->layer_as_StandInLayer()->base();
405  return graphPtr->layers()->Get(layerIndex)->layer_as_StridedSliceLayer()->base();
407  return graphPtr->layers()->Get(layerIndex)->layer_as_SubtractionLayer()->base();
409  return graphPtr->layers()->Get(layerIndex)->layer_as_SwitchLayer()->base();
411  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeConvolution2dLayer()->base();
413  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeLayer()->base();
415  return graphPtr->layers()->Get(layerIndex)->layer_as_UnidirectionalSequenceLstmLayer()->base();
416  case Layer::Layer_NONE:
417  default:
418  throw ParseException(fmt::format("Layer type {} not recognized", layerType));
419  }
420 }

◆ GetBindingLayerInfo()

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

Definition at line 429 of file Deserializer.cpp.

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

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

430 {
431  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
432 
433  if (layerType == Layer::Layer_InputLayer)
434  {
435  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
436  }
437  else if ( layerType == Layer::Layer_OutputLayer )
438  {
439  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
440  }
441  return 0;
442 }

◆ GetInputs()

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

Definition at line 755 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(), IDeserializer::DeserializerImpl::GetUnidirectionalSequenceLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

756 {
757  CHECK_LAYERS(graphPtr, 0, layerIndex);
758  auto layer = GetBaseLayer(graphPtr, layerIndex);
759  const auto& numInputs = layer->inputSlots()->size();
760 
761  TensorRawPtrVector result(numInputs);
762 
763  for (unsigned int i=0; i<numInputs; ++i)
764  {
765  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
766  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
767  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
768  }
769  return result;
770 }
#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 2878 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().

2879 {
2880  armnn::LstmDescriptor desc;
2881 
2882  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2883  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2884  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2885  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2886  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2887  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2888  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2889 
2890  return desc;
2891 }
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 880 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

882 {
883  IgnoreUnused(layerIndex);
884  for (auto inputBinding : m_InputBindings)
885  {
886  if (inputBinding.first == name)
887  {
888  return inputBinding.second;
889  }
890  }
891  throw ParseException(fmt::format("No input binding found for layer:{0} / {1}",
892  name,
893  CHECK_LOCATION().AsString()));
894 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209

◆ 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 896 of file Deserializer.cpp.

References armnn::Abs, ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_GRAPH, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnn::Equal, IDeserializer::DeserializerImpl::GetBaseLayer(), IDeserializer::DeserializerImpl::GetBindingLayerInfo(), armnn::GetDataTypeSize(), IDeserializer::DeserializerImpl::GetInputs(), IConnectableLayer::GetInputSlot(), IDeserializer::DeserializerImpl::GetLayerName(), TensorInfo::GetNumBytes(), Convolution3dDescriptor::GetNumInputs(), 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, Convolution3dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_BiasEnabled, BatchToSpaceNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, BatchToSpaceNdDescriptor::m_Crops, Convolution2dDescriptor::m_DataLayout, Convolution3dDescriptor::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, Convolution3dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationX, Convolution2dDescriptor::m_DilationY, Convolution3dDescriptor::m_DilationY, DepthwiseConvolution2dDescriptor::m_DilationY, Convolution3dDescriptor::m_DilationZ, 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, Convolution3dDescriptor::m_PadBack, Convolution2dDescriptor::m_PadBottom, Convolution3dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadBottom, Convolution3dDescriptor::m_PadFront, Convolution2dDescriptor::m_PadLeft, Convolution3dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution3dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution3dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_PadTop, DetectionPostProcessDescriptor::m_ScaleH, DetectionPostProcessDescriptor::m_ScaleW, DetectionPostProcessDescriptor::m_ScaleX, DetectionPostProcessDescriptor::m_ScaleY, Convolution2dDescriptor::m_StrideX, Convolution3dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, Convolution3dDescriptor::m_StrideY, DepthwiseConvolution2dDescriptor::m_StrideY, Convolution3dDescriptor::m_StrideZ, DetectionPostProcessDescriptor::m_UseRegularNms, FillDescriptor::m_Value, armnn::numeric_cast(), armnnUtils::Permute(), armnnUtils::Permuted(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToActivationFunction(), armnnDeserializer::ToArgMinMaxFunction(), armnnDeserializer::ToConstTensor(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToLogicalBinaryOperation(), and armnnDeserializer::ToTensorInfo().

898 {
899  IgnoreUnused(layerIndex);
900  for (auto outputBinding : m_OutputBindings)
901  {
902  if (outputBinding.first == name)
903  {
904  return outputBinding.second;
905  }
906  }
907  throw ParseException(fmt::format("No output binding found for layer:{0} / {1}",
908  name,
909  CHECK_LOCATION().AsString()));
910 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209

◆ GetNormalizationDescriptor()

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

Definition at line 2569 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.

2572 {
2573  IgnoreUnused(layerIndex);
2575 
2576  switch (normalizationDescriptor->normChannelType())
2577  {
2579  {
2581  break;
2582  }
2584  {
2586  break;
2587  }
2588  default:
2589  {
2590  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2591  }
2592  }
2593 
2594  switch (normalizationDescriptor->normMethodType())
2595  {
2597  {
2599  break;
2600  }
2602  {
2604  break;
2605  }
2606  default:
2607  {
2608  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2609  }
2610  }
2611 
2612  switch (normalizationDescriptor->dataLayout())
2613  {
2614  case DataLayout_NCHW:
2615  {
2617  break;
2618  }
2619  case DataLayout_NHWC:
2620  {
2622  break;
2623  }
2624  default:
2625  {
2626  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2627  }
2628  }
2629 
2630  desc.m_Alpha = normalizationDescriptor->alpha();
2631  desc.m_Beta = normalizationDescriptor->beta();
2632  desc.m_K = normalizationDescriptor->k();
2633  desc.m_NormSize = normalizationDescriptor->normSize();
2634 
2635  return desc;
2636 }
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 772 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(), IDeserializer::DeserializerImpl::GetUnidirectionalSequenceLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

773 {
774  CHECK_LAYERS(graphPtr, 0, layerIndex);
775  auto layer = GetBaseLayer(graphPtr, layerIndex);
776  const auto& numOutputs = layer->outputSlots()->size();
777 
778  TensorRawPtrVector result(numOutputs);
779 
780  for (unsigned int i=0; i<numOutputs; ++i)
781  {
782  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
783  }
784  return result;
785 }
#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 2133 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, armnn::L2, 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_L2, armnnSerializer::PoolingAlgorithm_Max, IOutputSlot::SetTensorInfo(), and armnnDeserializer::ToTensorInfo().

2135 {
2136  IgnoreUnused(layerIndex);
2138 
2139  switch (pooling2dDesc->poolType())
2140  {
2142  {
2144  break;
2145  }
2146  case PoolingAlgorithm_Max:
2147  {
2149  break;
2150  }
2151  case PoolingAlgorithm_L2:
2152  {
2154  break;
2155  }
2156  default:
2157  {
2158  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
2159  }
2160  }
2161 
2162  switch (pooling2dDesc->outputShapeRounding())
2163  {
2165  {
2167  break;
2168  }
2170  {
2172  break;
2173  }
2174  default:
2175  {
2176  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
2177  }
2178  }
2179 
2180  switch (pooling2dDesc->paddingMethod())
2181  {
2182  case PaddingMethod_Exclude:
2183  {
2185  break;
2186  }
2188  {
2190  break;
2191  }
2192  default:
2193  {
2194  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
2195  }
2196  }
2197 
2198  switch (pooling2dDesc->dataLayout())
2199  {
2200  case DataLayout_NCHW:
2201  {
2203  break;
2204  }
2205  case DataLayout_NHWC:
2206  {
2208  break;
2209  }
2210  default:
2211  {
2212  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2213  }
2214  }
2215 
2216  desc.m_PadRight = pooling2dDesc->padRight();
2217  desc.m_PadLeft = pooling2dDesc->padLeft();
2218  desc.m_PadBottom = pooling2dDesc->padBottom();
2219  desc.m_PadTop = pooling2dDesc->padTop();
2220  desc.m_StrideX = pooling2dDesc->strideX();
2221  desc.m_StrideY = pooling2dDesc->strideY();
2222  desc.m_PoolWidth = pooling2dDesc->poolWidth();
2223  desc.m_PoolHeight = pooling2dDesc->poolHeight();
2224 
2225  return desc;
2226 }
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 3009 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().

3010 {
3012 
3013  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
3014  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
3015  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
3016  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
3017 
3018  desc.m_CellClip = qLstmDescriptor->cellClip();
3019  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
3020 
3021  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
3022  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
3023  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
3024  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
3025 
3026  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
3027  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
3028 
3029  return desc;
3030 }
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.

◆ GetUnidirectionalSequenceLstmDescriptor()

armnn::UnidirectionalSequenceLstmDescriptor GetUnidirectionalSequenceLstmDescriptor ( UnidirectionalSequenceLstmDescriptorPtr  descriptor)
static

Definition at line 3441 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, LstmDescriptor::m_TimeMajor, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), and armnnDeserializer::ToTensorInfo().

3443 {
3445 
3446  desc.m_ActivationFunc = descriptor->activationFunc();
3447  desc.m_ClippingThresCell = descriptor->clippingThresCell();
3448  desc.m_ClippingThresProj = descriptor->clippingThresProj();
3449  desc.m_CifgEnabled = descriptor->cifgEnabled();
3450  desc.m_PeepholeEnabled = descriptor->peepholeEnabled();
3451  desc.m_ProjectionEnabled = descriptor->projectionEnabled();
3452  desc.m_LayerNormEnabled = descriptor->layerNormEnabled();
3453  desc.m_TimeMajor = descriptor->timeMajor();
3454 
3455  return desc;
3456 }
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
bool m_TimeMajor
Enable/disable time major.
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.

◆ LoadGraphFromBinary()

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

Definition at line 821 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().

822 {
823  if (binaryContent == nullptr)
824  {
825  throw InvalidArgumentException(fmt::format("Invalid (null) binary content {}",
826  CHECK_LOCATION().AsString()));
827  }
828  flatbuffers::Verifier verifier(binaryContent, len);
829  if (verifier.VerifyBuffer<SerializedGraph>() == false)
830  {
831  throw ParseException(fmt::format("Buffer doesn't conform to the expected Armnn "
832  "flatbuffers format. size:{0} {1}",
833  len,
834  CHECK_LOCATION().AsString()));
835  }
836  return GetSerializedGraph(binaryContent);
837 }
const armnnSerializer::SerializedGraph * GetSerializedGraph(const void *buf)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209

◆ operator=()

DeserializerImpl& operator= ( const DeserializerImpl )
delete

◆ OutputShapeOfReshape()

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

Definition at line 2270 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().

2272 {
2273  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
2274  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
2275 
2276  if (stretchDim != targetDimsIn.end())
2277  {
2278  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2279  {
2280  throw ParseException(fmt::format("At most one component of shape can be -1 {}",
2281  CHECK_LOCATION().AsString()));
2282  }
2283 
2284  auto targetNumElements =
2285  armnn::numeric_cast<unsigned int>(
2286  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2287 
2288  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2289  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2290  }
2291 
2292  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2293 
2294  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2295  reshapeInfo.SetShape(outputShape);
2296 
2297  return reshapeInfo;
2298 }
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:193
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
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:196

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