ArmNN
 20.11
Deserializer Class Reference

#include <Deserializer.hpp>

Inheritance diagram for Deserializer:
IDeserializer

Public Types

using ConstTensorRawPtr = const armnnSerializer::ConstTensor *
 
using GraphPtr = const armnnSerializer::SerializedGraph *
 
using TensorRawPtr = const armnnSerializer::TensorInfo *
 
using PoolingDescriptor = const armnnSerializer::Pooling2dDescriptor *
 
using NormalizationDescriptorPtr = const armnnSerializer::NormalizationDescriptor *
 
using LstmDescriptorPtr = const armnnSerializer::LstmDescriptor *
 
using LstmInputParamsPtr = const armnnSerializer::LstmInputParams *
 
using QLstmDescriptorPtr = const armnnSerializer::QLstmDescriptor *
 
using QunatizedLstmInputParamsPtr = const armnnSerializer::QuantizedLstmInputParams *
 
using TensorRawPtrVector = std::vector< TensorRawPtr >
 
using LayerRawPtr = const armnnSerializer::LayerBase *
 
using LayerBaseRawPtr = const armnnSerializer::LayerBase *
 
using LayerBaseRawPtrVector = std::vector< LayerBaseRawPtr >
 

Public Member Functions

armnn::INetworkPtr CreateNetworkFromBinary (const std::vector< uint8_t > &binaryContent) override
 Create an input network from binary file contents. More...
 
armnn::INetworkPtr CreateNetworkFromBinary (std::istream &binaryContent) override
 Create an input network from a binary input stream. More...
 
BindingPointInfo GetNetworkInputBindingInfo (unsigned int layerId, const std::string &name) const override
 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 override
 Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name. More...
 
 Deserializer ()
 
 ~Deserializer ()
 

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)
 
- Static Public Member Functions inherited from IDeserializer
static IDeserializerCreateRaw ()
 
static IDeserializerPtr Create ()
 
static void Destroy (IDeserializer *parser)
 

Additional Inherited Members

- Protected Member Functions inherited from IDeserializer
virtual ~IDeserializer ()
 

Detailed Description

Definition at line 16 of file Deserializer.hpp.

Member Typedef Documentation

◆ ConstTensorRawPtr

using ConstTensorRawPtr = const armnnSerializer::ConstTensor *

Definition at line 20 of file Deserializer.hpp.

◆ GraphPtr

using GraphPtr = const armnnSerializer::SerializedGraph *

Definition at line 21 of file Deserializer.hpp.

◆ LayerBaseRawPtr

using LayerBaseRawPtr = const armnnSerializer::LayerBase *

Definition at line 31 of file Deserializer.hpp.

◆ LayerBaseRawPtrVector

using LayerBaseRawPtrVector = std::vector<LayerBaseRawPtr>

Definition at line 32 of file Deserializer.hpp.

◆ LayerRawPtr

using LayerRawPtr = const armnnSerializer::LayerBase *

Definition at line 30 of file Deserializer.hpp.

◆ LstmDescriptorPtr

using LstmDescriptorPtr = const armnnSerializer::LstmDescriptor *

Definition at line 25 of file Deserializer.hpp.

◆ LstmInputParamsPtr

using LstmInputParamsPtr = const armnnSerializer::LstmInputParams *

Definition at line 26 of file Deserializer.hpp.

◆ NormalizationDescriptorPtr

using NormalizationDescriptorPtr = const armnnSerializer::NormalizationDescriptor *

Definition at line 24 of file Deserializer.hpp.

◆ PoolingDescriptor

using PoolingDescriptor = const armnnSerializer::Pooling2dDescriptor *

Definition at line 23 of file Deserializer.hpp.

◆ QLstmDescriptorPtr

using QLstmDescriptorPtr = const armnnSerializer::QLstmDescriptor *

Definition at line 27 of file Deserializer.hpp.

◆ QunatizedLstmInputParamsPtr

using QunatizedLstmInputParamsPtr = const armnnSerializer::QuantizedLstmInputParams *

Definition at line 28 of file Deserializer.hpp.

◆ TensorRawPtr

using TensorRawPtr = const armnnSerializer::TensorInfo *

Definition at line 22 of file Deserializer.hpp.

◆ TensorRawPtrVector

using TensorRawPtrVector = std::vector<TensorRawPtr>

Definition at line 29 of file Deserializer.hpp.

Constructor & Destructor Documentation

◆ Deserializer()

Definition at line 167 of file Deserializer.cpp.

Referenced by IDeserializer::CreateRaw(), and Deserializer::~Deserializer().

168 : m_Network(nullptr, nullptr),
169 //May require LayerType_Max to be included
170 m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer)
171 {
172  // register supported layers
173  m_ParserFunctions[Layer_AbsLayer] = &Deserializer::ParseAbs;
174  m_ParserFunctions[Layer_ActivationLayer] = &Deserializer::ParseActivation;
175  m_ParserFunctions[Layer_AdditionLayer] = &Deserializer::ParseAdd;
176  m_ParserFunctions[Layer_ArgMinMaxLayer] = &Deserializer::ParseArgMinMax;
177  m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &Deserializer::ParseBatchToSpaceNd;
178  m_ParserFunctions[Layer_BatchNormalizationLayer] = &Deserializer::ParseBatchNormalization;
179  m_ParserFunctions[Layer_ComparisonLayer] = &Deserializer::ParseComparison;
180  m_ParserFunctions[Layer_ConcatLayer] = &Deserializer::ParseConcat;
181  m_ParserFunctions[Layer_ConstantLayer] = &Deserializer::ParseConstant;
182  m_ParserFunctions[Layer_Convolution2dLayer] = &Deserializer::ParseConvolution2d;
183  m_ParserFunctions[Layer_DepthToSpaceLayer] = &Deserializer::ParseDepthToSpace;
184  m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &Deserializer::ParseDepthwiseConvolution2d;
185  m_ParserFunctions[Layer_DequantizeLayer] = &Deserializer::ParseDequantize;
186  m_ParserFunctions[Layer_DetectionPostProcessLayer] = &Deserializer::ParseDetectionPostProcess;
187  m_ParserFunctions[Layer_DivisionLayer] = &Deserializer::ParseDivision;
188  m_ParserFunctions[Layer_ElementwiseUnaryLayer] = &Deserializer::ParseElementwiseUnary;
189  m_ParserFunctions[Layer_EqualLayer] = &Deserializer::ParseEqual;
190  m_ParserFunctions[Layer_FullyConnectedLayer] = &Deserializer::ParseFullyConnected;
191  m_ParserFunctions[Layer_FillLayer] = &Deserializer::ParseFill;
192  m_ParserFunctions[Layer_FloorLayer] = &Deserializer::ParseFloor;
193  m_ParserFunctions[Layer_GatherLayer] = &Deserializer::ParseGather;
194  m_ParserFunctions[Layer_GreaterLayer] = &Deserializer::ParseGreater;
195  m_ParserFunctions[Layer_InstanceNormalizationLayer] = &Deserializer::ParseInstanceNormalization;
196  m_ParserFunctions[Layer_L2NormalizationLayer] = &Deserializer::ParseL2Normalization;
197  m_ParserFunctions[Layer_LogicalBinaryLayer] = &Deserializer::ParseLogicalBinary;
198  m_ParserFunctions[Layer_LogSoftmaxLayer] = &Deserializer::ParseLogSoftmax;
199  m_ParserFunctions[Layer_LstmLayer] = &Deserializer::ParseLstm;
200  m_ParserFunctions[Layer_MaximumLayer] = &Deserializer::ParseMaximum;
201  m_ParserFunctions[Layer_MeanLayer] = &Deserializer::ParseMean;
202  m_ParserFunctions[Layer_MinimumLayer] = &Deserializer::ParseMinimum;
203  m_ParserFunctions[Layer_MergeLayer] = &Deserializer::ParseMerge;
204  m_ParserFunctions[Layer_MergerLayer] = &Deserializer::ParseConcat;
205  m_ParserFunctions[Layer_MultiplicationLayer] = &Deserializer::ParseMultiplication;
206  m_ParserFunctions[Layer_NormalizationLayer] = &Deserializer::ParseNormalization;
207  m_ParserFunctions[Layer_PadLayer] = &Deserializer::ParsePad;
208  m_ParserFunctions[Layer_PermuteLayer] = &Deserializer::ParsePermute;
209  m_ParserFunctions[Layer_Pooling2dLayer] = &Deserializer::ParsePooling2d;
210  m_ParserFunctions[Layer_PreluLayer] = &Deserializer::ParsePrelu;
211  m_ParserFunctions[Layer_QLstmLayer] = &Deserializer::ParseQLstm;
212  m_ParserFunctions[Layer_QuantizeLayer] = &Deserializer::ParseQuantize;
213  m_ParserFunctions[Layer_QuantizedLstmLayer] = &Deserializer::ParseQuantizedLstm;
214  m_ParserFunctions[Layer_RankLayer] = &Deserializer::ParseRank;
215  m_ParserFunctions[Layer_ReshapeLayer] = &Deserializer::ParseReshape;
216  m_ParserFunctions[Layer_ResizeBilinearLayer] = &Deserializer::ParseResizeBilinear;
217  m_ParserFunctions[Layer_ResizeLayer] = &Deserializer::ParseResize;
218  m_ParserFunctions[Layer_RsqrtLayer] = &Deserializer::ParseRsqrt;
219  m_ParserFunctions[Layer_SliceLayer] = &Deserializer::ParseSlice;
220  m_ParserFunctions[Layer_SoftmaxLayer] = &Deserializer::ParseSoftmax;
221  m_ParserFunctions[Layer_SpaceToBatchNdLayer] = &Deserializer::ParseSpaceToBatchNd;
222  m_ParserFunctions[Layer_SpaceToDepthLayer] = &Deserializer::ParseSpaceToDepth;
223  m_ParserFunctions[Layer_SplitterLayer] = &Deserializer::ParseSplitter;
224  m_ParserFunctions[Layer_StackLayer] = &Deserializer::ParseStack;
225  m_ParserFunctions[Layer_StandInLayer] = &Deserializer::ParseStandIn;
226  m_ParserFunctions[Layer_StridedSliceLayer] = &Deserializer::ParseStridedSlice;
227  m_ParserFunctions[Layer_SubtractionLayer] = &Deserializer::ParseSubtraction;
228  m_ParserFunctions[Layer_SwitchLayer] = &Deserializer::ParseSwitch;
229  m_ParserFunctions[Layer_TransposeConvolution2dLayer] = &Deserializer::ParseTransposeConvolution2d;
230  m_ParserFunctions[Layer_TransposeLayer] = &Deserializer::ParseTranspose;
231 }

◆ ~Deserializer()

Member Function Documentation

◆ CreateNetworkFromBinary() [1/2]

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

Create an input network from binary file contents.

Implements IDeserializer.

Definition at line 703 of file Deserializer.cpp.

References Deserializer::LoadGraphFromBinary().

704 {
705  ResetParser();
706  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
707  return CreateNetworkFromGraph(graph);
708 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
const armnnSerializer::SerializedGraph * GraphPtr

◆ CreateNetworkFromBinary() [2/2]

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

Create an input network from a binary input stream.

Implements IDeserializer.

Definition at line 710 of file Deserializer.cpp.

References Deserializer::LoadGraphFromBinary().

711 {
712  ResetParser();
713  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
714  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
715  return CreateNetworkFromGraph(graph);
716 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
const armnnSerializer::SerializedGraph * GraphPtr

◆ GetBaseLayer()

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

Definition at line 233 of file Deserializer.cpp.

Referenced by Deserializer::GetInputs(), Deserializer::GetLayerName(), Deserializer::GetNetworkOutputBindingInfo(), Deserializer::GetOutputs(), and Deserializer::~Deserializer().

234 {
235  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
236 
237  switch(layerType)
238  {
239  case Layer::Layer_AbsLayer:
240  return graphPtr->layers()->Get(layerIndex)->layer_as_AbsLayer()->base();
241  case Layer::Layer_ActivationLayer:
242  return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base();
243  case Layer::Layer_AdditionLayer:
244  return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base();
245  case Layer::Layer_ArgMinMaxLayer:
246  return graphPtr->layers()->Get(layerIndex)->layer_as_ArgMinMaxLayer()->base();
247  case Layer::Layer_BatchToSpaceNdLayer:
248  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchToSpaceNdLayer()->base();
249  case Layer::Layer_BatchNormalizationLayer:
250  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchNormalizationLayer()->base();
251  case Layer::Layer_ComparisonLayer:
252  return graphPtr->layers()->Get(layerIndex)->layer_as_ComparisonLayer()->base();
253  case Layer::Layer_ConcatLayer:
254  return graphPtr->layers()->Get(layerIndex)->layer_as_ConcatLayer()->base();
255  case Layer::Layer_ConstantLayer:
256  return graphPtr->layers()->Get(layerIndex)->layer_as_ConstantLayer()->base();
257  case Layer::Layer_Convolution2dLayer:
258  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
259  case Layer::Layer_DepthToSpaceLayer:
260  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthToSpaceLayer()->base();
261  case Layer::Layer_DepthwiseConvolution2dLayer:
262  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthwiseConvolution2dLayer()->base();
263  case Layer::Layer_DequantizeLayer:
264  return graphPtr->layers()->Get(layerIndex)->layer_as_DequantizeLayer()->base();
265  case Layer::Layer_DetectionPostProcessLayer:
266  return graphPtr->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer()->base();
267  case Layer::Layer_DivisionLayer:
268  return graphPtr->layers()->Get(layerIndex)->layer_as_DivisionLayer()->base();
269  case Layer::Layer_EqualLayer:
270  return graphPtr->layers()->Get(layerIndex)->layer_as_EqualLayer()->base();
271  case Layer::Layer_ElementwiseUnaryLayer:
272  return graphPtr->layers()->Get(layerIndex)->layer_as_ElementwiseUnaryLayer()->base();
273  case Layer::Layer_FullyConnectedLayer:
274  return graphPtr->layers()->Get(layerIndex)->layer_as_FullyConnectedLayer()->base();
275  case Layer::Layer_FillLayer:
276  return graphPtr->layers()->Get(layerIndex)->layer_as_FillLayer()->base();
277  case Layer::Layer_FloorLayer:
278  return graphPtr->layers()->Get(layerIndex)->layer_as_FloorLayer()->base();
279  case Layer::Layer_GatherLayer:
280  return graphPtr->layers()->Get(layerIndex)->layer_as_GatherLayer()->base();
281  case Layer::Layer_GreaterLayer:
282  return graphPtr->layers()->Get(layerIndex)->layer_as_GreaterLayer()->base();
283  case Layer::Layer_InputLayer:
284  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base();
285  case Layer::Layer_InstanceNormalizationLayer:
286  return graphPtr->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer()->base();
287  case Layer::Layer_L2NormalizationLayer:
288  return graphPtr->layers()->Get(layerIndex)->layer_as_L2NormalizationLayer()->base();
289  case Layer::Layer_LogicalBinaryLayer:
290  return graphPtr->layers()->Get(layerIndex)->layer_as_LogicalBinaryLayer()->base();
291  case Layer::Layer_LogSoftmaxLayer:
292  return graphPtr->layers()->Get(layerIndex)->layer_as_LogSoftmaxLayer()->base();
293  case Layer::Layer_LstmLayer:
294  return graphPtr->layers()->Get(layerIndex)->layer_as_LstmLayer()->base();
295  case Layer::Layer_MeanLayer:
296  return graphPtr->layers()->Get(layerIndex)->layer_as_MeanLayer()->base();
297  case Layer::Layer_MinimumLayer:
298  return graphPtr->layers()->Get(layerIndex)->layer_as_MinimumLayer()->base();
299  case Layer::Layer_MaximumLayer:
300  return graphPtr->layers()->Get(layerIndex)->layer_as_MaximumLayer()->base();
301  case Layer::Layer_MergeLayer:
302  return graphPtr->layers()->Get(layerIndex)->layer_as_MergeLayer()->base();
303  case Layer::Layer_MergerLayer:
304  return graphPtr->layers()->Get(layerIndex)->layer_as_MergerLayer()->base();
305  case Layer::Layer_MultiplicationLayer:
306  return graphPtr->layers()->Get(layerIndex)->layer_as_MultiplicationLayer()->base();
307  case Layer::Layer_NormalizationLayer:
308  return graphPtr->layers()->Get(layerIndex)->layer_as_NormalizationLayer()->base();
309  case Layer::Layer_OutputLayer:
310  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->base();
311  case Layer::Layer_PadLayer:
312  return graphPtr->layers()->Get(layerIndex)->layer_as_PadLayer()->base();
313  case Layer::Layer_PermuteLayer:
314  return graphPtr->layers()->Get(layerIndex)->layer_as_PermuteLayer()->base();
315  case Layer::Layer_Pooling2dLayer:
316  return graphPtr->layers()->Get(layerIndex)->layer_as_Pooling2dLayer()->base();
317  case Layer::Layer_PreluLayer:
318  return graphPtr->layers()->Get(layerIndex)->layer_as_PreluLayer()->base();
319  case Layer::Layer_QLstmLayer:
320  return graphPtr->layers()->Get(layerIndex)->layer_as_QLstmLayer()->base();
321  case Layer::Layer_QuantizeLayer:
322  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizeLayer()->base();
323  case Layer::Layer_QuantizedLstmLayer:
324  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizedLstmLayer()->base();
325  case Layer::Layer_RankLayer:
326  return graphPtr->layers()->Get(layerIndex)->layer_as_RankLayer()->base();
327  case Layer::Layer_ReshapeLayer:
328  return graphPtr->layers()->Get(layerIndex)->layer_as_ReshapeLayer()->base();
329  case Layer::Layer_ResizeBilinearLayer:
330  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeBilinearLayer()->base();
331  case Layer::Layer_ResizeLayer:
332  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeLayer()->base();
333  case Layer::Layer_RsqrtLayer:
334  return graphPtr->layers()->Get(layerIndex)->layer_as_RsqrtLayer()->base();
335  case Layer::Layer_SliceLayer:
336  return graphPtr->layers()->Get(layerIndex)->layer_as_SliceLayer()->base();
337  case Layer::Layer_SoftmaxLayer:
338  return graphPtr->layers()->Get(layerIndex)->layer_as_SoftmaxLayer()->base();
339  case Layer::Layer_SpaceToBatchNdLayer:
340  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToBatchNdLayer()->base();
341  case Layer::Layer_SpaceToDepthLayer:
342  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToDepthLayer()->base();
343  case Layer::Layer_SplitterLayer:
344  return graphPtr->layers()->Get(layerIndex)->layer_as_SplitterLayer()->base();
345  case Layer::Layer_StackLayer:
346  return graphPtr->layers()->Get(layerIndex)->layer_as_StackLayer()->base();
347  case Layer::Layer_StandInLayer:
348  return graphPtr->layers()->Get(layerIndex)->layer_as_StandInLayer()->base();
349  case Layer::Layer_StridedSliceLayer:
350  return graphPtr->layers()->Get(layerIndex)->layer_as_StridedSliceLayer()->base();
351  case Layer::Layer_SubtractionLayer:
352  return graphPtr->layers()->Get(layerIndex)->layer_as_SubtractionLayer()->base();
353  case Layer::Layer_SwitchLayer:
354  return graphPtr->layers()->Get(layerIndex)->layer_as_SwitchLayer()->base();
355  case Layer::Layer_TransposeConvolution2dLayer:
356  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeConvolution2dLayer()->base();
357  case Layer::Layer_TransposeLayer:
358  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeLayer()->base();
359  case Layer::Layer_NONE:
360  default:
361  throw ParseException(fmt::format("Layer type {} not recognized", layerType));
362  }
363 }

◆ GetBindingLayerInfo()

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

Definition at line 372 of file Deserializer.cpp.

Referenced by Deserializer::GetNetworkOutputBindingInfo(), and Deserializer::~Deserializer().

373 {
374  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
375 
376  if (layerType == Layer::Layer_InputLayer)
377  {
378  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
379  }
380  else if ( layerType == Layer::Layer_OutputLayer )
381  {
382  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
383  }
384  return 0;
385 }

◆ GetInputs()

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

Definition at line 636 of file Deserializer.cpp.

References CHECK_LAYERS, CHECKED_NON_NEGATIVE, and Deserializer::GetBaseLayer().

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

638 {
639  CHECK_LAYERS(graphPtr, 0, layerIndex);
640  auto layer = GetBaseLayer(graphPtr, layerIndex);
641  const auto& numInputs = layer->inputSlots()->size();
642 
643  TensorRawPtrVector result(numInputs);
644 
645  for (unsigned int i=0; i<numInputs; ++i)
646  {
647  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
648  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
649  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
650  }
651  return result;
652 }
#define CHECK_LAYERS(GRAPH, LAYERS_INDEX, LAYER_INDEX)
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)
#define CHECKED_NON_NEGATIVE(VALUE)
std::vector< TensorRawPtr > TensorRawPtrVector

◆ GetLayerName()

std::string GetLayerName ( const GraphPtr graph,
unsigned int  index 
)
static

Definition at line 365 of file Deserializer.cpp.

References Deserializer::GetBaseLayer().

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

366 {
367  auto layer = GetBaseLayer(graph, index);
368  assert(layer);
369  return layer->layerName()->str();
370 }
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)

◆ GetLstmDescriptor()

armnn::LstmDescriptor GetLstmDescriptor ( Deserializer::LstmDescriptorPtr  lstmDescriptor)
static

Definition at line 2564 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_VALID_SIZE, Deserializer::GetInputs(), Deserializer::GetLayerName(), Deserializer::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().

Referenced by Deserializer::~Deserializer().

2565 {
2566  armnn::LstmDescriptor desc;
2567 
2568  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2569  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2570  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2571  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2572  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2573  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2574  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2575 
2576  return desc;
2577 }
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
overridevirtual

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

Implements IDeserializer.

Definition at line 777 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

779 {
780  IgnoreUnused(layerIndex);
781  for (auto inputBinding : m_InputBindings)
782  {
783  if (inputBinding.first == name)
784  {
785  return inputBinding.second;
786  }
787  }
788  throw ParseException(fmt::format("No input binding found for layer:{0} / {1}",
789  name,
790  CHECK_LOCATION().AsString()));
791 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ GetNetworkOutputBindingInfo()

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

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

Implements IDeserializer.

Definition at line 793 of file Deserializer.cpp.

References armnn::Abs, anchors(), ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_GRAPH, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnn::Equal, Deserializer::GetBaseLayer(), Deserializer::GetBindingLayerInfo(), Deserializer::GetInputs(), IConnectableLayer::GetInputSlot(), Deserializer::GetLayerName(), IConnectableLayer::GetNumInputSlots(), IConnectableLayer::GetNumOutputSlots(), Deserializer::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::Greater, armnn::IgnoreUnused(), 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().

795 {
796  IgnoreUnused(layerIndex);
797  for (auto outputBinding : m_OutputBindings)
798  {
799  if (outputBinding.first == name)
800  {
801  return outputBinding.second;
802  }
803  }
804  throw ParseException(fmt::format("No output binding found for layer:{0} / {1}",
805  name,
806  CHECK_LOCATION().AsString()));
807 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ GetNormalizationDescriptor()

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

Definition at line 2255 of file Deserializer.cpp.

References armnn::Across, ARMNN_ASSERT_MSG, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, Deserializer::GetInputs(), Deserializer::GetLayerName(), Deserializer::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, armnn::Rsqrt, IOutputSlot::SetTensorInfo(), ViewsDescriptor::SetViewOriginCoord(), ViewsDescriptor::SetViewSize(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToTensorInfo(), and armnn::Within.

Referenced by Deserializer::~Deserializer().

2258 {
2259  IgnoreUnused(layerIndex);
2261 
2262  switch (normalizationDescriptor->normChannelType())
2263  {
2264  case NormalizationAlgorithmChannel_Across:
2265  {
2267  break;
2268  }
2269  case NormalizationAlgorithmChannel_Within:
2270  {
2272  break;
2273  }
2274  default:
2275  {
2276  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2277  }
2278  }
2279 
2280  switch (normalizationDescriptor->normMethodType())
2281  {
2282  case NormalizationAlgorithmMethod_LocalBrightness:
2283  {
2285  break;
2286  }
2287  case NormalizationAlgorithmMethod_LocalContrast:
2288  {
2290  break;
2291  }
2292  default:
2293  {
2294  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2295  }
2296  }
2297 
2298  switch (normalizationDescriptor->dataLayout())
2299  {
2300  case DataLayout_NCHW:
2301  {
2303  break;
2304  }
2305  case DataLayout_NHWC:
2306  {
2308  break;
2309  }
2310  default:
2311  {
2312  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2313  }
2314  }
2315 
2316  desc.m_Alpha = normalizationDescriptor->alpha();
2317  desc.m_Beta = normalizationDescriptor->beta();
2318  desc.m_K = normalizationDescriptor->k();
2319  desc.m_NormSize = normalizationDescriptor->normSize();
2320 
2321  return desc;
2322 }
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()

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

Definition at line 654 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, and Deserializer::GetBaseLayer().

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

656 {
657  CHECK_LAYERS(graphPtr, 0, layerIndex);
658  auto layer = GetBaseLayer(graphPtr, layerIndex);
659  const auto& numOutputs = layer->outputSlots()->size();
660 
661  TensorRawPtrVector result(numOutputs);
662 
663  for (unsigned int i=0; i<numOutputs; ++i)
664  {
665  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
666  }
667  return result;
668 }
#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 ( Deserializer::PoolingDescriptor  pooling2dDesc,
unsigned int  layerIndex 
)
static

Definition at line 1880 of file Deserializer.cpp.

References ARMNN_ASSERT_MSG, armnn::Average, armnn::Ceiling, CHECK_LAYERS, CHECK_VALID_SIZE, armnn::Exclude, armnn::Floor, Deserializer::GetInputs(), Deserializer::GetLayerName(), Deserializer::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::IgnoreUnused(), armnn::IgnoreValue, Pooling2dDescriptor::m_DataLayout, Pooling2dDescriptor::m_OutputShapeRounding, Pooling2dDescriptor::m_PadBottom, Pooling2dDescriptor::m_PaddingMethod, Pooling2dDescriptor::m_PadLeft, Pooling2dDescriptor::m_PadRight, Pooling2dDescriptor::m_PadTop, Pooling2dDescriptor::m_PoolHeight, Pooling2dDescriptor::m_PoolType, Pooling2dDescriptor::m_PoolWidth, Pooling2dDescriptor::m_StrideX, Pooling2dDescriptor::m_StrideY, armnn::Max, armnn::NCHW, armnn::NHWC, IOutputSlot::SetTensorInfo(), and armnnDeserializer::ToTensorInfo().

Referenced by Deserializer::~Deserializer().

1882 {
1883  IgnoreUnused(layerIndex);
1885 
1886  switch (pooling2dDesc->poolType())
1887  {
1888  case PoolingAlgorithm_Average:
1889  {
1891  break;
1892  }
1893  case PoolingAlgorithm_Max:
1894  {
1896  break;
1897  }
1898  default:
1899  {
1900  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
1901  }
1902  }
1903 
1904  switch (pooling2dDesc->outputShapeRounding())
1905  {
1906  case OutputShapeRounding_Floor:
1907  {
1909  break;
1910  }
1911  case OutputShapeRounding_Ceiling:
1912  {
1914  break;
1915  }
1916  default:
1917  {
1918  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
1919  }
1920  }
1921 
1922  switch (pooling2dDesc->paddingMethod())
1923  {
1924  case PaddingMethod_Exclude:
1925  {
1927  break;
1928  }
1929  case PaddingMethod_IgnoreValue:
1930  {
1932  break;
1933  }
1934  default:
1935  {
1936  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
1937  }
1938  }
1939 
1940  switch (pooling2dDesc->dataLayout())
1941  {
1942  case DataLayout_NCHW:
1943  {
1945  break;
1946  }
1947  case DataLayout_NHWC:
1948  {
1950  break;
1951  }
1952  default:
1953  {
1954  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
1955  }
1956  }
1957 
1958  desc.m_PadRight = pooling2dDesc->padRight();
1959  desc.m_PadLeft = pooling2dDesc->padLeft();
1960  desc.m_PadBottom = pooling2dDesc->padBottom();
1961  desc.m_PadTop = pooling2dDesc->padTop();
1962  desc.m_StrideX = pooling2dDesc->strideX();
1963  desc.m_StrideY = pooling2dDesc->strideY();
1964  desc.m_PoolWidth = pooling2dDesc->poolWidth();
1965  desc.m_PoolHeight = pooling2dDesc->poolHeight();
1966 
1967  return desc;
1968 }
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 ( Deserializer::QLstmDescriptorPtr  qLstmDescriptor)
static

Definition at line 2695 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, Deserializer::GetInputs(), Deserializer::GetLayerName(), Deserializer::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().

Referenced by Deserializer::~Deserializer().

2696 {
2698 
2699  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
2700  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
2701  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
2702  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
2703 
2704  desc.m_CellClip = qLstmDescriptor->cellClip();
2705  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
2706 
2707  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
2708  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
2709  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
2710  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
2711 
2712  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
2713  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
2714 
2715  return desc;
2716 }
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()

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

Definition at line 718 of file Deserializer.cpp.

References ARMNN_ASSERT, CHECK_LOCATION, and IOutputSlot::Connect().

Referenced by Deserializer::CreateNetworkFromBinary(), and Deserializer::~Deserializer().

719 {
720  if (binaryContent == nullptr)
721  {
722  throw InvalidArgumentException(fmt::format("Invalid (null) binary content {}",
723  CHECK_LOCATION().AsString()));
724  }
725  flatbuffers::Verifier verifier(binaryContent, len);
726  if (verifier.VerifyBuffer<SerializedGraph>() == false)
727  {
728  throw ParseException(fmt::format("Buffer doesn't conform to the expected Armnn "
729  "flatbuffers format. size:{0} {1}",
730  len,
731  CHECK_LOCATION().AsString()));
732  }
733  return GetSerializedGraph(binaryContent);
734 }
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ OutputShapeOfReshape()

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

Definition at line 2010 of file Deserializer.cpp.

References armnn::Bilinear, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnnDeserializer::CheckShape(), Deserializer::GetInputs(), Deserializer::GetLayerName(), TensorInfo::GetNumElements(), Deserializer::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, ResizeDescriptor::m_Method, SpaceToBatchNdDescriptor::m_PadList, ResizeDescriptor::m_TargetHeight, ReshapeDescriptor::m_TargetShape, ResizeDescriptor::m_TargetWidth, armnn::numeric_cast(), TensorInfo::SetShape(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToResizeMethod(), and armnnDeserializer::ToTensorInfo().

Referenced by Deserializer::~Deserializer().

2012 {
2013  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
2014  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
2015 
2016  if (stretchDim != targetDimsIn.end())
2017  {
2018  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2019  {
2020  throw ParseException(fmt::format("At most one component of shape can be -1 {}",
2021  CHECK_LOCATION().AsString()));
2022  }
2023 
2024  auto targetNumElements =
2025  armnn::numeric_cast<unsigned int>(
2026  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2027 
2028  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2029  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2030  }
2031 
2032  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2033 
2034  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2035  reshapeInfo.SetShape(outputShape);
2036 
2037  return reshapeInfo;
2038 }
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: