ArmNN
 20.05
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 183 of file Deserializer.cpp.

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

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

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

References Deserializer::LoadGraphFromBinary().

692 {
693  ResetParser();
694  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
695  return CreateNetworkFromGraph(graph);
696 }
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 698 of file Deserializer.cpp.

References Deserializer::LoadGraphFromBinary().

699 {
700  ResetParser();
701  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
702  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
703  return CreateNetworkFromGraph(graph);
704 }
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 246 of file Deserializer.cpp.

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

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

◆ GetBindingLayerInfo()

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

Definition at line 379 of file Deserializer.cpp.

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

380 {
381  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
382 
383  if (layerType == Layer::Layer_InputLayer)
384  {
385  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
386  }
387  else if ( layerType == Layer::Layer_OutputLayer )
388  {
389  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
390  }
391  return 0;
392 }

◆ GetInputs()

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

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

623 {
624  CHECK_LAYERS(graphPtr, 0, layerIndex);
625  auto layer = GetBaseLayer(graphPtr, layerIndex);
626  const auto& numInputs = layer->inputSlots()->size();
627 
628  TensorRawPtrVector result(numInputs);
629 
630  for (unsigned int i=0; i<numInputs; ++i)
631  {
632  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
633  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
634  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
635  }
636  return result;
637 }
#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 372 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().

373 {
374  auto layer = GetBaseLayer(graph, index);
375  assert(layer);
376  return layer->layerName()->str();
377 }
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)

◆ GetLstmDescriptor()

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

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

2486 {
2487  armnn::LstmDescriptor desc;
2488 
2489  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2490  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2491  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2492  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2493  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2494  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2495  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2496 
2497  return desc;
2498 }
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 766 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

768 {
769  IgnoreUnused(layerIndex);
770  for (auto inputBinding : m_InputBindings)
771  {
772  if (inputBinding.first == name)
773  {
774  return inputBinding.second;
775  }
776  }
777  throw ParseException(
778  boost::str(
779  boost::format("No input binding found for layer:%1% / %2%") %
780  name %
781  CHECK_LOCATION().AsString()));
782 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192

◆ 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 784 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, 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(), and armnnDeserializer::ToTensorInfo().

786 {
787  IgnoreUnused(layerIndex);
788  for (auto outputBinding : m_OutputBindings)
789  {
790  if (outputBinding.first == name)
791  {
792  return outputBinding.second;
793  }
794  }
795  throw ParseException(
796  boost::str(
797  boost::format("No output binding found for layer:%1% / %2%") %
798  name %
799  CHECK_LOCATION().AsString()));
800 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192

◆ GetNormalizationDescriptor()

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

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

2182 {
2183  IgnoreUnused(layerIndex);
2185 
2186  switch (normalizationDescriptor->normChannelType())
2187  {
2188  case NormalizationAlgorithmChannel_Across:
2189  {
2191  break;
2192  }
2193  case NormalizationAlgorithmChannel_Within:
2194  {
2196  break;
2197  }
2198  default:
2199  {
2200  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2201  }
2202  }
2203 
2204  switch (normalizationDescriptor->normMethodType())
2205  {
2206  case NormalizationAlgorithmMethod_LocalBrightness:
2207  {
2209  break;
2210  }
2211  case NormalizationAlgorithmMethod_LocalContrast:
2212  {
2214  break;
2215  }
2216  default:
2217  {
2218  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2219  }
2220  }
2221 
2222  switch (normalizationDescriptor->dataLayout())
2223  {
2224  case DataLayout_NCHW:
2225  {
2227  break;
2228  }
2229  case DataLayout_NHWC:
2230  {
2232  break;
2233  }
2234  default:
2235  {
2236  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2237  }
2238  }
2239 
2240  desc.m_Alpha = normalizationDescriptor->alpha();
2241  desc.m_Beta = normalizationDescriptor->beta();
2242  desc.m_K = normalizationDescriptor->k();
2243  desc.m_NormSize = normalizationDescriptor->normSize();
2244 
2245  return desc;
2246 }
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 639 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().

641 {
642  CHECK_LAYERS(graphPtr, 0, layerIndex);
643  auto layer = GetBaseLayer(graphPtr, layerIndex);
644  const auto& numOutputs = layer->outputSlots()->size();
645 
646  TensorRawPtrVector result(numOutputs);
647 
648  for (unsigned int i=0; i<numOutputs; ++i)
649  {
650  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
651  }
652  return result;
653 }
#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 1828 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().

1830 {
1831  IgnoreUnused(layerIndex);
1833 
1834  switch (pooling2dDesc->poolType())
1835  {
1836  case PoolingAlgorithm_Average:
1837  {
1839  break;
1840  }
1841  case PoolingAlgorithm_Max:
1842  {
1844  break;
1845  }
1846  default:
1847  {
1848  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
1849  }
1850  }
1851 
1852  switch (pooling2dDesc->outputShapeRounding())
1853  {
1854  case OutputShapeRounding_Floor:
1855  {
1857  break;
1858  }
1859  case OutputShapeRounding_Ceiling:
1860  {
1862  break;
1863  }
1864  default:
1865  {
1866  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
1867  }
1868  }
1869 
1870  switch (pooling2dDesc->paddingMethod())
1871  {
1872  case PaddingMethod_Exclude:
1873  {
1875  break;
1876  }
1877  case PaddingMethod_IgnoreValue:
1878  {
1880  break;
1881  }
1882  default:
1883  {
1884  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
1885  }
1886  }
1887 
1888  switch (pooling2dDesc->dataLayout())
1889  {
1890  case DataLayout_NCHW:
1891  {
1893  break;
1894  }
1895  case DataLayout_NHWC:
1896  {
1898  break;
1899  }
1900  default:
1901  {
1902  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
1903  }
1904  }
1905 
1906  desc.m_PadRight = pooling2dDesc->padRight();
1907  desc.m_PadLeft = pooling2dDesc->padLeft();
1908  desc.m_PadBottom = pooling2dDesc->padBottom();
1909  desc.m_PadTop = pooling2dDesc->padTop();
1910  desc.m_StrideX = pooling2dDesc->strideX();
1911  desc.m_StrideY = pooling2dDesc->strideY();
1912  desc.m_PoolWidth = pooling2dDesc->poolWidth();
1913  desc.m_PoolHeight = pooling2dDesc->poolHeight();
1914 
1915  return desc;
1916 }
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 2616 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().

2617 {
2619 
2620  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
2621  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
2622  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
2623  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
2624 
2625  desc.m_CellClip = qLstmDescriptor->cellClip();
2626  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
2627 
2628  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
2629  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
2630  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
2631  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
2632 
2633  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
2634  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
2635 
2636  return desc;
2637 }
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 706 of file Deserializer.cpp.

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

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

707 {
708  if (binaryContent == nullptr)
709  {
710  throw InvalidArgumentException(boost::str(boost::format("Invalid (null) binary content %1%") %
711  CHECK_LOCATION().AsString()));
712  }
713  flatbuffers::Verifier verifier(binaryContent, len);
714  if (verifier.VerifyBuffer<SerializedGraph>() == false)
715  {
716  throw ParseException(
717  boost::str(boost::format("Buffer doesn't conform to the expected Armnn "
718  "flatbuffers format. size:%1% %2%") %
719  len %
720  CHECK_LOCATION().AsString()));
721  }
722  return GetSerializedGraph(binaryContent);
723 }
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192

◆ OutputShapeOfReshape()

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

Definition at line 1958 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(), SoftmaxDescriptor::m_Beta, SpaceToBatchNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, ResizeDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToDepthDescriptor::m_DataLayout, 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().

1960 {
1961  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
1962  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
1963 
1964  if (stretchDim != targetDimsIn.end())
1965  {
1966  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
1967  {
1968  throw ParseException(boost::str(
1969  boost::format("At most one component of shape can be -1 %1%") % CHECK_LOCATION().AsString()));
1970  }
1971 
1972  auto targetNumElements =
1973  boost::numeric_cast<unsigned int>(
1974  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
1975 
1976  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
1977  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
1978  }
1979 
1980  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
1981 
1982  armnn::TensorInfo reshapeInfo = inputTensorInfo;
1983  reshapeInfo.SetShape(outputShape);
1984 
1985  return reshapeInfo;
1986 }
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:90
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
unsigned int GetNumElements() const
Definition: Tensor.hpp:93

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