ArmNN
 20.08
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 182 of file Deserializer.cpp.

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

183 : m_Network(nullptr, nullptr),
184 //May require LayerType_Max to be included
185 m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer)
186 {
187  // register supported layers
188  m_ParserFunctions[Layer_AbsLayer] = &Deserializer::ParseAbs;
189  m_ParserFunctions[Layer_ActivationLayer] = &Deserializer::ParseActivation;
190  m_ParserFunctions[Layer_AdditionLayer] = &Deserializer::ParseAdd;
191  m_ParserFunctions[Layer_ArgMinMaxLayer] = &Deserializer::ParseArgMinMax;
192  m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &Deserializer::ParseBatchToSpaceNd;
193  m_ParserFunctions[Layer_BatchNormalizationLayer] = &Deserializer::ParseBatchNormalization;
194  m_ParserFunctions[Layer_ComparisonLayer] = &Deserializer::ParseComparison;
195  m_ParserFunctions[Layer_ConcatLayer] = &Deserializer::ParseConcat;
196  m_ParserFunctions[Layer_ConstantLayer] = &Deserializer::ParseConstant;
197  m_ParserFunctions[Layer_Convolution2dLayer] = &Deserializer::ParseConvolution2d;
198  m_ParserFunctions[Layer_DepthToSpaceLayer] = &Deserializer::ParseDepthToSpace;
199  m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &Deserializer::ParseDepthwiseConvolution2d;
200  m_ParserFunctions[Layer_DequantizeLayer] = &Deserializer::ParseDequantize;
201  m_ParserFunctions[Layer_DetectionPostProcessLayer] = &Deserializer::ParseDetectionPostProcess;
202  m_ParserFunctions[Layer_DivisionLayer] = &Deserializer::ParseDivision;
203  m_ParserFunctions[Layer_ElementwiseUnaryLayer] = &Deserializer::ParseElementwiseUnary;
204  m_ParserFunctions[Layer_EqualLayer] = &Deserializer::ParseEqual;
205  m_ParserFunctions[Layer_FullyConnectedLayer] = &Deserializer::ParseFullyConnected;
206  m_ParserFunctions[Layer_FillLayer] = &Deserializer::ParseFill;
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_RankLayer] = &Deserializer::ParseRank;
229  m_ParserFunctions[Layer_ReshapeLayer] = &Deserializer::ParseReshape;
230  m_ParserFunctions[Layer_ResizeBilinearLayer] = &Deserializer::ParseResizeBilinear;
231  m_ParserFunctions[Layer_ResizeLayer] = &Deserializer::ParseResize;
232  m_ParserFunctions[Layer_RsqrtLayer] = &Deserializer::ParseRsqrt;
233  m_ParserFunctions[Layer_SliceLayer] = &Deserializer::ParseSlice;
234  m_ParserFunctions[Layer_SoftmaxLayer] = &Deserializer::ParseSoftmax;
235  m_ParserFunctions[Layer_SpaceToBatchNdLayer] = &Deserializer::ParseSpaceToBatchNd;
236  m_ParserFunctions[Layer_SpaceToDepthLayer] = &Deserializer::ParseSpaceToDepth;
237  m_ParserFunctions[Layer_SplitterLayer] = &Deserializer::ParseSplitter;
238  m_ParserFunctions[Layer_StackLayer] = &Deserializer::ParseStack;
239  m_ParserFunctions[Layer_StandInLayer] = &Deserializer::ParseStandIn;
240  m_ParserFunctions[Layer_StridedSliceLayer] = &Deserializer::ParseStridedSlice;
241  m_ParserFunctions[Layer_SubtractionLayer] = &Deserializer::ParseSubtraction;
242  m_ParserFunctions[Layer_SwitchLayer] = &Deserializer::ParseSwitch;
243  m_ParserFunctions[Layer_TransposeConvolution2dLayer] = &Deserializer::ParseTransposeConvolution2d;
244  m_ParserFunctions[Layer_TransposeLayer] = &Deserializer::ParseTranspose;
245 }

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

References Deserializer::LoadGraphFromBinary().

707 {
708  ResetParser();
709  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
710  return CreateNetworkFromGraph(graph);
711 }
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 713 of file Deserializer.cpp.

References Deserializer::LoadGraphFromBinary().

714 {
715  ResetParser();
716  std::vector<uint8_t> content((std::istreambuf_iterator<char>(binaryContent)), std::istreambuf_iterator<char>());
717  GraphPtr graph = LoadGraphFromBinary(content.data(), content.size());
718  return CreateNetworkFromGraph(graph);
719 }
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 247 of file Deserializer.cpp.

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

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

◆ GetBindingLayerInfo()

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

Definition at line 384 of file Deserializer.cpp.

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

385 {
386  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
387 
388  if (layerType == Layer::Layer_InputLayer)
389  {
390  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
391  }
392  else if ( layerType == Layer::Layer_OutputLayer )
393  {
394  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
395  }
396  return 0;
397 }

◆ 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 377 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().

378 {
379  auto layer = GetBaseLayer(graph, index);
380  assert(layer);
381  return layer->layerName()->str();
382 }
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)

◆ GetLstmDescriptor()

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

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

2549 {
2550  armnn::LstmDescriptor desc;
2551 
2552  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
2553  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
2554  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
2555  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
2556  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
2557  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
2558  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
2559 
2560  return desc;
2561 }
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 781 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

783 {
784  IgnoreUnused(layerIndex);
785  for (auto inputBinding : m_InputBindings)
786  {
787  if (inputBinding.first == name)
788  {
789  return inputBinding.second;
790  }
791  }
792  throw ParseException(
793  boost::str(
794  boost::format("No input binding found for layer:%1% / %2%") %
795  name %
796  CHECK_LOCATION().AsString()));
797 }
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 799 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().

801 {
802  IgnoreUnused(layerIndex);
803  for (auto outputBinding : m_OutputBindings)
804  {
805  if (outputBinding.first == name)
806  {
807  return outputBinding.second;
808  }
809  }
810  throw ParseException(
811  boost::str(
812  boost::format("No output binding found for layer:%1% / %2%") %
813  name %
814  CHECK_LOCATION().AsString()));
815 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ GetNormalizationDescriptor()

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

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

2242 {
2243  IgnoreUnused(layerIndex);
2245 
2246  switch (normalizationDescriptor->normChannelType())
2247  {
2248  case NormalizationAlgorithmChannel_Across:
2249  {
2251  break;
2252  }
2253  case NormalizationAlgorithmChannel_Within:
2254  {
2256  break;
2257  }
2258  default:
2259  {
2260  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2261  }
2262  }
2263 
2264  switch (normalizationDescriptor->normMethodType())
2265  {
2266  case NormalizationAlgorithmMethod_LocalBrightness:
2267  {
2269  break;
2270  }
2271  case NormalizationAlgorithmMethod_LocalContrast:
2272  {
2274  break;
2275  }
2276  default:
2277  {
2278  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2279  }
2280  }
2281 
2282  switch (normalizationDescriptor->dataLayout())
2283  {
2284  case DataLayout_NCHW:
2285  {
2287  break;
2288  }
2289  case DataLayout_NHWC:
2290  {
2292  break;
2293  }
2294  default:
2295  {
2296  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2297  }
2298  }
2299 
2300  desc.m_Alpha = normalizationDescriptor->alpha();
2301  desc.m_Beta = normalizationDescriptor->beta();
2302  desc.m_K = normalizationDescriptor->k();
2303  desc.m_NormSize = normalizationDescriptor->normSize();
2304 
2305  return desc;
2306 }
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 1864 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().

1866 {
1867  IgnoreUnused(layerIndex);
1869 
1870  switch (pooling2dDesc->poolType())
1871  {
1872  case PoolingAlgorithm_Average:
1873  {
1875  break;
1876  }
1877  case PoolingAlgorithm_Max:
1878  {
1880  break;
1881  }
1882  default:
1883  {
1884  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
1885  }
1886  }
1887 
1888  switch (pooling2dDesc->outputShapeRounding())
1889  {
1890  case OutputShapeRounding_Floor:
1891  {
1893  break;
1894  }
1895  case OutputShapeRounding_Ceiling:
1896  {
1898  break;
1899  }
1900  default:
1901  {
1902  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
1903  }
1904  }
1905 
1906  switch (pooling2dDesc->paddingMethod())
1907  {
1908  case PaddingMethod_Exclude:
1909  {
1911  break;
1912  }
1913  case PaddingMethod_IgnoreValue:
1914  {
1916  break;
1917  }
1918  default:
1919  {
1920  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
1921  }
1922  }
1923 
1924  switch (pooling2dDesc->dataLayout())
1925  {
1926  case DataLayout_NCHW:
1927  {
1929  break;
1930  }
1931  case DataLayout_NHWC:
1932  {
1934  break;
1935  }
1936  default:
1937  {
1938  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
1939  }
1940  }
1941 
1942  desc.m_PadRight = pooling2dDesc->padRight();
1943  desc.m_PadLeft = pooling2dDesc->padLeft();
1944  desc.m_PadBottom = pooling2dDesc->padBottom();
1945  desc.m_PadTop = pooling2dDesc->padTop();
1946  desc.m_StrideX = pooling2dDesc->strideX();
1947  desc.m_StrideY = pooling2dDesc->strideY();
1948  desc.m_PoolWidth = pooling2dDesc->poolWidth();
1949  desc.m_PoolHeight = pooling2dDesc->poolHeight();
1950 
1951  return desc;
1952 }
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 2679 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().

2680 {
2682 
2683  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
2684  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
2685  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
2686  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
2687 
2688  desc.m_CellClip = qLstmDescriptor->cellClip();
2689  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
2690 
2691  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
2692  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
2693  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
2694  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
2695 
2696  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
2697  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
2698 
2699  return desc;
2700 }
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 721 of file Deserializer.cpp.

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

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

722 {
723  if (binaryContent == nullptr)
724  {
725  throw InvalidArgumentException(boost::str(boost::format("Invalid (null) binary content %1%") %
726  CHECK_LOCATION().AsString()));
727  }
728  flatbuffers::Verifier verifier(binaryContent, len);
729  if (verifier.VerifyBuffer<SerializedGraph>() == false)
730  {
731  throw ParseException(
732  boost::str(boost::format("Buffer doesn't conform to the expected Armnn "
733  "flatbuffers format. size:%1% %2%") %
734  len %
735  CHECK_LOCATION().AsString()));
736  }
737  return GetSerializedGraph(binaryContent);
738 }
#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 1994 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().

1996 {
1997  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
1998  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
1999 
2000  if (stretchDim != targetDimsIn.end())
2001  {
2002  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2003  {
2004  throw ParseException(boost::str(
2005  boost::format("At most one component of shape can be -1 %1%") % CHECK_LOCATION().AsString()));
2006  }
2007 
2008  auto targetNumElements =
2009  boost::numeric_cast<unsigned int>(
2010  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2011 
2012  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2013  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2014  }
2015 
2016  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2017 
2018  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2019  reshapeInfo.SetShape(outputShape);
2020 
2021  return reshapeInfo;
2022 }
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
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:197
unsigned int GetNumElements() const
Definition: Tensor.hpp:192

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