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

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

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

771 {
772  ResetParser();
773  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
774  return CreateNetworkFromGraph(graph);
775 }
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 777 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

778 {
779  ResetParser();
780  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
781  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
782  return CreateNetworkFromGraph(graph);
783 }
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 274 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_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().

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

◆ GetBindingLayerInfo()

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

Definition at line 417 of file Deserializer.cpp.

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

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

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

◆ GetInputs()

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

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

720 {
721  CHECK_LAYERS(graphPtr, 0, layerIndex);
722  auto layer = GetBaseLayer(graphPtr, layerIndex);
723  const auto& numInputs = layer->inputSlots()->size();
724 
725  TensorRawPtrVector result(numInputs);
726 
727  for (unsigned int i=0; i<numInputs; ++i)
728  {
729  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
730  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
731  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
732  }
733  return result;
734 }
#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 2705 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().

2706 {
2707  armnn::LstmDescriptor desc;
2708 
2709  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2710  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2711  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2712  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2713  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2714  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2715  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2716 
2717  return desc;
2718 }
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 844 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

846 {
847  IgnoreUnused(layerIndex);
848  for (auto inputBinding : m_InputBindings)
849  {
850  if (inputBinding.first == name)
851  {
852  return inputBinding.second;
853  }
854  }
855  throw ParseException(fmt::format("No input binding found for layer:{0} / {1}",
856  name,
857  CHECK_LOCATION().AsString()));
858 }
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 860 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().

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

◆ GetNormalizationDescriptor()

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

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

2399 {
2400  IgnoreUnused(layerIndex);
2402 
2403  switch (normalizationDescriptor->normChannelType())
2404  {
2406  {
2408  break;
2409  }
2411  {
2413  break;
2414  }
2415  default:
2416  {
2417  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2418  }
2419  }
2420 
2421  switch (normalizationDescriptor->normMethodType())
2422  {
2424  {
2426  break;
2427  }
2429  {
2431  break;
2432  }
2433  default:
2434  {
2435  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2436  }
2437  }
2438 
2439  switch (normalizationDescriptor->dataLayout())
2440  {
2441  case DataLayout_NCHW:
2442  {
2444  break;
2445  }
2446  case DataLayout_NHWC:
2447  {
2449  break;
2450  }
2451  default:
2452  {
2453  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2454  }
2455  }
2456 
2457  desc.m_Alpha = normalizationDescriptor->alpha();
2458  desc.m_Beta = normalizationDescriptor->beta();
2459  desc.m_K = normalizationDescriptor->k();
2460  desc.m_NormSize = normalizationDescriptor->normSize();
2461 
2462  return desc;
2463 }
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 736 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().

737 {
738  CHECK_LAYERS(graphPtr, 0, layerIndex);
739  auto layer = GetBaseLayer(graphPtr, layerIndex);
740  const auto& numOutputs = layer->outputSlots()->size();
741 
742  TensorRawPtrVector result(numOutputs);
743 
744  for (unsigned int i=0; i<numOutputs; ++i)
745  {
746  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
747  }
748  return result;
749 }
#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 1984 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().

1986 {
1987  IgnoreUnused(layerIndex);
1989 
1990  switch (pooling2dDesc->poolType())
1991  {
1993  {
1995  break;
1996  }
1997  case PoolingAlgorithm_Max:
1998  {
2000  break;
2001  }
2002  case PoolingAlgorithm_L2:
2003  {
2005  break;
2006  }
2007  default:
2008  {
2009  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
2010  }
2011  }
2012 
2013  switch (pooling2dDesc->outputShapeRounding())
2014  {
2016  {
2018  break;
2019  }
2021  {
2023  break;
2024  }
2025  default:
2026  {
2027  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
2028  }
2029  }
2030 
2031  switch (pooling2dDesc->paddingMethod())
2032  {
2033  case PaddingMethod_Exclude:
2034  {
2036  break;
2037  }
2039  {
2041  break;
2042  }
2043  default:
2044  {
2045  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
2046  }
2047  }
2048 
2049  switch (pooling2dDesc->dataLayout())
2050  {
2051  case DataLayout_NCHW:
2052  {
2054  break;
2055  }
2056  case DataLayout_NHWC:
2057  {
2059  break;
2060  }
2061  default:
2062  {
2063  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2064  }
2065  }
2066 
2067  desc.m_PadRight = pooling2dDesc->padRight();
2068  desc.m_PadLeft = pooling2dDesc->padLeft();
2069  desc.m_PadBottom = pooling2dDesc->padBottom();
2070  desc.m_PadTop = pooling2dDesc->padTop();
2071  desc.m_StrideX = pooling2dDesc->strideX();
2072  desc.m_StrideY = pooling2dDesc->strideY();
2073  desc.m_PoolWidth = pooling2dDesc->poolWidth();
2074  desc.m_PoolHeight = pooling2dDesc->poolHeight();
2075 
2076  return desc;
2077 }
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 2836 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().

2837 {
2839 
2840  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
2841  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
2842  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
2843  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
2844 
2845  desc.m_CellClip = qLstmDescriptor->cellClip();
2846  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
2847 
2848  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
2849  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
2850  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
2851  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
2852 
2853  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
2854  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
2855 
2856  return desc;
2857 }
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 785 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().

786 {
787  if (binaryContent == nullptr)
788  {
789  throw InvalidArgumentException(fmt::format("Invalid (null) binary content {}",
790  CHECK_LOCATION().AsString()));
791  }
792  flatbuffers::Verifier verifier(binaryContent, len);
793  if (verifier.VerifyBuffer<SerializedGraph>() == false)
794  {
795  throw ParseException(fmt::format("Buffer doesn't conform to the expected Armnn "
796  "flatbuffers format. size:{0} {1}",
797  len,
798  CHECK_LOCATION().AsString()));
799  }
800  return GetSerializedGraph(binaryContent);
801 }
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 2121 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().

2123 {
2124  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
2125  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
2126 
2127  if (stretchDim != targetDimsIn.end())
2128  {
2129  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2130  {
2131  throw ParseException(fmt::format("At most one component of shape can be -1 {}",
2132  CHECK_LOCATION().AsString()));
2133  }
2134 
2135  auto targetNumElements =
2136  armnn::numeric_cast<unsigned int>(
2137  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2138 
2139  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2140  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2141  }
2142 
2143  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2144 
2145  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2146  reshapeInfo.SetShape(outputShape);
2147 
2148  return reshapeInfo;
2149 }
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: