ArmNN
 22.11
IDeserializer::DeserializerImpl Class Reference

#include <Deserializer.hpp>

Public Member Functions

armnn::INetworkPtr CreateNetworkFromBinary (const std::vector< uint8_t > &binaryContent)
 Create an input network from binary file contents. More...
 
armnn::INetworkPtr CreateNetworkFromBinary (std::istream &binaryContent)
 Create an input network from a binary input stream. More...
 
BindingPointInfo GetNetworkInputBindingInfo (unsigned int layerId, const std::string &name) const
 Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name. More...
 
BindingPointInfo GetNetworkOutputBindingInfo (unsigned int layerId, const std::string &name) const
 Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name. More...
 
 DeserializerImpl ()
 
 ~DeserializerImpl ()=default
 
 DeserializerImpl (const DeserializerImpl &)=delete
 
DeserializerImploperator= (const DeserializerImpl &)=delete
 

Static Public Member Functions

static GraphPtr LoadGraphFromBinary (const uint8_t *binaryContent, size_t len)
 
static TensorRawPtrVector GetInputs (const GraphPtr &graph, unsigned int layerIndex)
 
static TensorRawPtrVector GetOutputs (const GraphPtr &graph, unsigned int layerIndex)
 
static LayerBaseRawPtr GetBaseLayer (const GraphPtr &graphPtr, unsigned int layerIndex)
 
static int32_t GetBindingLayerInfo (const GraphPtr &graphPtr, unsigned int layerIndex)
 
static std::string GetLayerName (const GraphPtr &graph, unsigned int index)
 
static armnn::Pooling2dDescriptor GetPooling2dDescriptor (Pooling2dDescriptor pooling2dDescriptor, unsigned int layerIndex)
 
static armnn::Pooling3dDescriptor GetPooling3dDescriptor (Pooling3dDescriptor pooling3dDescriptor, unsigned int layerIndex)
 
static armnn::NormalizationDescriptor GetNormalizationDescriptor (NormalizationDescriptorPtr normalizationDescriptor, unsigned int layerIndex)
 
static armnn::LstmDescriptor GetLstmDescriptor (LstmDescriptorPtr lstmDescriptor)
 
static armnn::LstmInputParams GetLstmInputParams (LstmDescriptorPtr lstmDescriptor, LstmInputParamsPtr lstmInputParams)
 
static armnn::QLstmDescriptor GetQLstmDescriptor (QLstmDescriptorPtr qLstmDescriptorPtr)
 
static armnn::UnidirectionalSequenceLstmDescriptor GetUnidirectionalSequenceLstmDescriptor (UnidirectionalSequenceLstmDescriptorPtr descriptor)
 
static armnn::TensorInfo OutputShapeOfReshape (const armnn::TensorInfo &inputTensorInfo, const std::vector< uint32_t > &targetDimsIn)
 

Detailed Description

Definition at line 34 of file Deserializer.hpp.

Constructor & Destructor Documentation

◆ DeserializerImpl() [1/2]

Definition at line 207 of file Deserializer.cpp.

208 : m_Network(nullptr, nullptr),
209 //May require LayerType_Max to be included
210 m_ParserFunctions(Layer_MAX+1, &IDeserializer::DeserializerImpl::ParseUnsupportedLayer)
211 {
212  // register supported layers
213  m_ParserFunctions[Layer_AbsLayer] = &DeserializerImpl::ParseAbs;
214  m_ParserFunctions[Layer_ActivationLayer] = &DeserializerImpl::ParseActivation;
215  m_ParserFunctions[Layer_AdditionLayer] = &DeserializerImpl::ParseAdd;
216  m_ParserFunctions[Layer_ArgMinMaxLayer] = &DeserializerImpl::ParseArgMinMax;
217  m_ParserFunctions[Layer_BatchMatMulLayer] = &DeserializerImpl::ParseBatchMatMul;
218  m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &DeserializerImpl::ParseBatchToSpaceNd;
219  m_ParserFunctions[Layer_BatchNormalizationLayer] = &DeserializerImpl::ParseBatchNormalization;
220  m_ParserFunctions[Layer_CastLayer] = &DeserializerImpl::ParseCast;
221  m_ParserFunctions[Layer_ChannelShuffleLayer] = &DeserializerImpl::ParseChannelShuffle;
222  m_ParserFunctions[Layer_ComparisonLayer] = &DeserializerImpl::ParseComparison;
223  m_ParserFunctions[Layer_ConcatLayer] = &DeserializerImpl::ParseConcat;
224  m_ParserFunctions[Layer_ConstantLayer] = &DeserializerImpl::ParseConstant;
225  m_ParserFunctions[Layer_Convolution2dLayer] = &DeserializerImpl::ParseConvolution2d;
226  m_ParserFunctions[Layer_Convolution3dLayer] = &DeserializerImpl::ParseConvolution3d;
227  m_ParserFunctions[Layer_DepthToSpaceLayer] = &DeserializerImpl::ParseDepthToSpace;
228  m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &DeserializerImpl::ParseDepthwiseConvolution2d;
229  m_ParserFunctions[Layer_DequantizeLayer] = &DeserializerImpl::ParseDequantize;
230  m_ParserFunctions[Layer_DetectionPostProcessLayer] = &DeserializerImpl::ParseDetectionPostProcess;
231  m_ParserFunctions[Layer_DivisionLayer] = &DeserializerImpl::ParseDivision;
232  m_ParserFunctions[Layer_ElementwiseUnaryLayer] = &DeserializerImpl::ParseElementwiseUnary;
233  m_ParserFunctions[Layer_EqualLayer] = &DeserializerImpl::ParseEqual;
234  m_ParserFunctions[Layer_FullyConnectedLayer] = &DeserializerImpl::ParseFullyConnected;
235  m_ParserFunctions[Layer_FillLayer] = &DeserializerImpl::ParseFill;
236  m_ParserFunctions[Layer_FloorLayer] = &DeserializerImpl::ParseFloor;
237  m_ParserFunctions[Layer_GatherLayer] = &DeserializerImpl::ParseGather;
238  m_ParserFunctions[Layer_GatherNdLayer] = &DeserializerImpl::ParseGatherNd;
239  m_ParserFunctions[Layer_GreaterLayer] = &DeserializerImpl::ParseGreater;
240  m_ParserFunctions[Layer_InstanceNormalizationLayer] = &DeserializerImpl::ParseInstanceNormalization;
241  m_ParserFunctions[Layer_L2NormalizationLayer] = &DeserializerImpl::ParseL2Normalization;
242  m_ParserFunctions[Layer_LogicalBinaryLayer] = &DeserializerImpl::ParseLogicalBinary;
243  m_ParserFunctions[Layer_LogSoftmaxLayer] = &DeserializerImpl::ParseLogSoftmax;
244  m_ParserFunctions[Layer_LstmLayer] = &DeserializerImpl::ParseLstm;
245  m_ParserFunctions[Layer_MaximumLayer] = &DeserializerImpl::ParseMaximum;
246  m_ParserFunctions[Layer_MeanLayer] = &DeserializerImpl::ParseMean;
247  m_ParserFunctions[Layer_MinimumLayer] = &DeserializerImpl::ParseMinimum;
248  m_ParserFunctions[Layer_MergeLayer] = &DeserializerImpl::ParseMerge;
249  m_ParserFunctions[Layer_MergerLayer] = &DeserializerImpl::ParseConcat;
250  m_ParserFunctions[Layer_MultiplicationLayer] = &DeserializerImpl::ParseMultiplication;
251  m_ParserFunctions[Layer_NormalizationLayer] = &DeserializerImpl::ParseNormalization;
252  m_ParserFunctions[Layer_PadLayer] = &DeserializerImpl::ParsePad;
253  m_ParserFunctions[Layer_PermuteLayer] = &DeserializerImpl::ParsePermute;
254  m_ParserFunctions[Layer_Pooling2dLayer] = &DeserializerImpl::ParsePooling2d;
255  m_ParserFunctions[Layer_Pooling3dLayer] = &DeserializerImpl::ParsePooling3d;
256  m_ParserFunctions[Layer_PreluLayer] = &DeserializerImpl::ParsePrelu;
257  m_ParserFunctions[Layer_QLstmLayer] = &DeserializerImpl::ParseQLstm;
258  m_ParserFunctions[Layer_QuantizeLayer] = &DeserializerImpl::ParseQuantize;
259  m_ParserFunctions[Layer_QuantizedLstmLayer] = &DeserializerImpl::ParseQuantizedLstm;
260  m_ParserFunctions[Layer_RankLayer] = &DeserializerImpl::ParseRank;
261  m_ParserFunctions[Layer_ReduceLayer] = &DeserializerImpl::ParseReduce;
262  m_ParserFunctions[Layer_ReshapeLayer] = &DeserializerImpl::ParseReshape;
263  m_ParserFunctions[Layer_ResizeBilinearLayer] = &DeserializerImpl::ParseResizeBilinear;
264  m_ParserFunctions[Layer_ResizeLayer] = &DeserializerImpl::ParseResize;
265  m_ParserFunctions[Layer_RsqrtLayer] = &DeserializerImpl::ParseRsqrt;
266  m_ParserFunctions[Layer_ShapeLayer] = &DeserializerImpl::ParseShape;
267  m_ParserFunctions[Layer_SliceLayer] = &DeserializerImpl::ParseSlice;
268  m_ParserFunctions[Layer_SoftmaxLayer] = &DeserializerImpl::ParseSoftmax;
269  m_ParserFunctions[Layer_SpaceToBatchNdLayer] = &DeserializerImpl::ParseSpaceToBatchNd;
270  m_ParserFunctions[Layer_SpaceToDepthLayer] = &DeserializerImpl::ParseSpaceToDepth;
271  m_ParserFunctions[Layer_SplitterLayer] = &DeserializerImpl::ParseSplitter;
272  m_ParserFunctions[Layer_StackLayer] = &DeserializerImpl::ParseStack;
273  m_ParserFunctions[Layer_StandInLayer] = &DeserializerImpl::ParseStandIn;
274  m_ParserFunctions[Layer_StridedSliceLayer] = &DeserializerImpl::ParseStridedSlice;
275  m_ParserFunctions[Layer_SubtractionLayer] = &DeserializerImpl::ParseSubtraction;
276  m_ParserFunctions[Layer_SwitchLayer] = &DeserializerImpl::ParseSwitch;
277  m_ParserFunctions[Layer_TransposeConvolution2dLayer] = &DeserializerImpl::ParseTransposeConvolution2d;
278  m_ParserFunctions[Layer_TransposeLayer] = &DeserializerImpl::ParseTranspose;
279  m_ParserFunctions[Layer_UnidirectionalSequenceLstmLayer] = &DeserializerImpl::ParseUnidirectionalSequenceLstm;
280 }

◆ ~DeserializerImpl()

~DeserializerImpl ( )
default

◆ DeserializerImpl() [2/2]

DeserializerImpl ( const DeserializerImpl )
delete

Member Function Documentation

◆ CreateNetworkFromBinary() [1/2]

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

Create an input network from binary file contents.

Definition at line 816 of file Deserializer.cpp.

References IDeserializer::DeserializerImpl::LoadGraphFromBinary().

817 {
818  ResetParser();
819  GraphPtr graph = LoadGraphFromBinary(binaryContent.data(), binaryContent.size());
820  return CreateNetworkFromGraph(graph);
821 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
const armnnSerializer::SerializedGraph * GraphPtr

◆ CreateNetworkFromBinary() [2/2]

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

Create an input network from a binary input stream.

Definition at line 823 of file Deserializer.cpp.

References ARMNN_LOG, armnn::error, and IDeserializer::DeserializerImpl::LoadGraphFromBinary().

824 {
825  ResetParser();
826  if (binaryContent.fail()) {
827  ARMNN_LOG(error) << (std::string("Cannot read input"));
828  throw ParseException("Unable to read Input stream data");
829  }
830  binaryContent.seekg(0, std::ios::end);
831  const std::streamoff size = binaryContent.tellg();
832  std::vector<char> content(static_cast<size_t>(size));
833  binaryContent.seekg(0);
834  binaryContent.read(content.data(), static_cast<std::streamsize>(size));
835  GraphPtr graph = LoadGraphFromBinary(reinterpret_cast<uint8_t*>(content.data()), static_cast<size_t>(size));
836  return CreateNetworkFromGraph(graph);
837 }
static GraphPtr LoadGraphFromBinary(const uint8_t *binaryContent, size_t len)
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205
const armnnSerializer::SerializedGraph * GraphPtr

◆ GetBaseLayer()

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

Definition at line 282 of file Deserializer.cpp.

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

283 {
284  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
285 
286  switch(layerType)
287  {
288  case Layer::Layer_AbsLayer:
289  return graphPtr->layers()->Get(layerIndex)->layer_as_AbsLayer()->base();
290  case Layer::Layer_ActivationLayer:
291  return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base();
292  case Layer::Layer_AdditionLayer:
293  return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base();
294  case Layer::Layer_ArgMinMaxLayer:
295  return graphPtr->layers()->Get(layerIndex)->layer_as_ArgMinMaxLayer()->base();
296  case Layer::Layer_BatchMatMulLayer:
297  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchMatMulLayer()->base();
298  case Layer::Layer_BatchToSpaceNdLayer:
299  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchToSpaceNdLayer()->base();
300  case Layer::Layer_BatchNormalizationLayer:
301  return graphPtr->layers()->Get(layerIndex)->layer_as_BatchNormalizationLayer()->base();
302  case Layer::Layer_CastLayer:
303  return graphPtr->layers()->Get(layerIndex)->layer_as_CastLayer()->base();
304  case Layer::Layer_ChannelShuffleLayer:
305  return graphPtr->layers()->Get(layerIndex)->layer_as_ChannelShuffleLayer()->base();
306  case Layer::Layer_ComparisonLayer:
307  return graphPtr->layers()->Get(layerIndex)->layer_as_ComparisonLayer()->base();
308  case Layer::Layer_ConcatLayer:
309  return graphPtr->layers()->Get(layerIndex)->layer_as_ConcatLayer()->base();
310  case Layer::Layer_ConstantLayer:
311  return graphPtr->layers()->Get(layerIndex)->layer_as_ConstantLayer()->base();
312  case Layer::Layer_Convolution2dLayer:
313  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
314  case Layer::Layer_Convolution3dLayer:
315  return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution3dLayer()->base();
316  case Layer::Layer_DepthToSpaceLayer:
317  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthToSpaceLayer()->base();
318  case Layer::Layer_DepthwiseConvolution2dLayer:
319  return graphPtr->layers()->Get(layerIndex)->layer_as_DepthwiseConvolution2dLayer()->base();
320  case Layer::Layer_DequantizeLayer:
321  return graphPtr->layers()->Get(layerIndex)->layer_as_DequantizeLayer()->base();
322  case Layer::Layer_DetectionPostProcessLayer:
323  return graphPtr->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer()->base();
324  case Layer::Layer_DivisionLayer:
325  return graphPtr->layers()->Get(layerIndex)->layer_as_DivisionLayer()->base();
326  case Layer::Layer_EqualLayer:
327  return graphPtr->layers()->Get(layerIndex)->layer_as_EqualLayer()->base();
328  case Layer::Layer_ElementwiseUnaryLayer:
329  return graphPtr->layers()->Get(layerIndex)->layer_as_ElementwiseUnaryLayer()->base();
330  case Layer::Layer_FullyConnectedLayer:
331  return graphPtr->layers()->Get(layerIndex)->layer_as_FullyConnectedLayer()->base();
332  case Layer::Layer_FillLayer:
333  return graphPtr->layers()->Get(layerIndex)->layer_as_FillLayer()->base();
334  case Layer::Layer_FloorLayer:
335  return graphPtr->layers()->Get(layerIndex)->layer_as_FloorLayer()->base();
336  case Layer::Layer_GatherLayer:
337  return graphPtr->layers()->Get(layerIndex)->layer_as_GatherLayer()->base();
338  case Layer::Layer_GatherNdLayer:
339  return graphPtr->layers()->Get(layerIndex)->layer_as_GatherNdLayer()->base();
340  case Layer::Layer_GreaterLayer:
341  return graphPtr->layers()->Get(layerIndex)->layer_as_GreaterLayer()->base();
342  case Layer::Layer_InputLayer:
343  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base();
344  case Layer::Layer_InstanceNormalizationLayer:
345  return graphPtr->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer()->base();
346  case Layer::Layer_L2NormalizationLayer:
347  return graphPtr->layers()->Get(layerIndex)->layer_as_L2NormalizationLayer()->base();
348  case Layer::Layer_LogicalBinaryLayer:
349  return graphPtr->layers()->Get(layerIndex)->layer_as_LogicalBinaryLayer()->base();
350  case Layer::Layer_LogSoftmaxLayer:
351  return graphPtr->layers()->Get(layerIndex)->layer_as_LogSoftmaxLayer()->base();
352  case Layer::Layer_LstmLayer:
353  return graphPtr->layers()->Get(layerIndex)->layer_as_LstmLayer()->base();
354  case Layer::Layer_MeanLayer:
355  return graphPtr->layers()->Get(layerIndex)->layer_as_MeanLayer()->base();
356  case Layer::Layer_MinimumLayer:
357  return graphPtr->layers()->Get(layerIndex)->layer_as_MinimumLayer()->base();
358  case Layer::Layer_MaximumLayer:
359  return graphPtr->layers()->Get(layerIndex)->layer_as_MaximumLayer()->base();
360  case Layer::Layer_MergeLayer:
361  return graphPtr->layers()->Get(layerIndex)->layer_as_MergeLayer()->base();
362  case Layer::Layer_MergerLayer:
363  return graphPtr->layers()->Get(layerIndex)->layer_as_MergerLayer()->base();
364  case Layer::Layer_MultiplicationLayer:
365  return graphPtr->layers()->Get(layerIndex)->layer_as_MultiplicationLayer()->base();
366  case Layer::Layer_NormalizationLayer:
367  return graphPtr->layers()->Get(layerIndex)->layer_as_NormalizationLayer()->base();
368  case Layer::Layer_OutputLayer:
369  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->base();
370  case Layer::Layer_PadLayer:
371  return graphPtr->layers()->Get(layerIndex)->layer_as_PadLayer()->base();
372  case Layer::Layer_PermuteLayer:
373  return graphPtr->layers()->Get(layerIndex)->layer_as_PermuteLayer()->base();
374  case Layer::Layer_Pooling2dLayer:
375  return graphPtr->layers()->Get(layerIndex)->layer_as_Pooling2dLayer()->base();
376  case Layer::Layer_Pooling3dLayer:
377  return graphPtr->layers()->Get(layerIndex)->layer_as_Pooling3dLayer()->base();
378  case Layer::Layer_PreluLayer:
379  return graphPtr->layers()->Get(layerIndex)->layer_as_PreluLayer()->base();
380  case Layer::Layer_QLstmLayer:
381  return graphPtr->layers()->Get(layerIndex)->layer_as_QLstmLayer()->base();
382  case Layer::Layer_QuantizeLayer:
383  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizeLayer()->base();
384  case Layer::Layer_QuantizedLstmLayer:
385  return graphPtr->layers()->Get(layerIndex)->layer_as_QuantizedLstmLayer()->base();
386  case Layer::Layer_RankLayer:
387  return graphPtr->layers()->Get(layerIndex)->layer_as_RankLayer()->base();
388  case Layer::Layer_ReduceLayer:
389  return graphPtr->layers()->Get(layerIndex)->layer_as_ReduceLayer()->base();
390  case Layer::Layer_ReshapeLayer:
391  return graphPtr->layers()->Get(layerIndex)->layer_as_ReshapeLayer()->base();
392  case Layer::Layer_ResizeBilinearLayer:
393  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeBilinearLayer()->base();
394  case Layer::Layer_ResizeLayer:
395  return graphPtr->layers()->Get(layerIndex)->layer_as_ResizeLayer()->base();
396  case Layer::Layer_RsqrtLayer:
397  return graphPtr->layers()->Get(layerIndex)->layer_as_RsqrtLayer()->base();
398  case Layer::Layer_ShapeLayer:
399  return graphPtr->layers()->Get(layerIndex)->layer_as_ShapeLayer()->base();
400  case Layer::Layer_SliceLayer:
401  return graphPtr->layers()->Get(layerIndex)->layer_as_SliceLayer()->base();
402  case Layer::Layer_SoftmaxLayer:
403  return graphPtr->layers()->Get(layerIndex)->layer_as_SoftmaxLayer()->base();
404  case Layer::Layer_SpaceToBatchNdLayer:
405  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToBatchNdLayer()->base();
406  case Layer::Layer_SpaceToDepthLayer:
407  return graphPtr->layers()->Get(layerIndex)->layer_as_SpaceToDepthLayer()->base();
408  case Layer::Layer_SplitterLayer:
409  return graphPtr->layers()->Get(layerIndex)->layer_as_SplitterLayer()->base();
410  case Layer::Layer_StackLayer:
411  return graphPtr->layers()->Get(layerIndex)->layer_as_StackLayer()->base();
412  case Layer::Layer_StandInLayer:
413  return graphPtr->layers()->Get(layerIndex)->layer_as_StandInLayer()->base();
414  case Layer::Layer_StridedSliceLayer:
415  return graphPtr->layers()->Get(layerIndex)->layer_as_StridedSliceLayer()->base();
416  case Layer::Layer_SubtractionLayer:
417  return graphPtr->layers()->Get(layerIndex)->layer_as_SubtractionLayer()->base();
418  case Layer::Layer_SwitchLayer:
419  return graphPtr->layers()->Get(layerIndex)->layer_as_SwitchLayer()->base();
420  case Layer::Layer_TransposeConvolution2dLayer:
421  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeConvolution2dLayer()->base();
422  case Layer::Layer_TransposeLayer:
423  return graphPtr->layers()->Get(layerIndex)->layer_as_TransposeLayer()->base();
424  case Layer::Layer_UnidirectionalSequenceLstmLayer:
425  return graphPtr->layers()->Get(layerIndex)->layer_as_UnidirectionalSequenceLstmLayer()->base();
426  case Layer::Layer_NONE:
427  default:
428  throw ParseException(fmt::format("Layer type {} not recognized", layerType));
429  }
430 }

◆ GetBindingLayerInfo()

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

Definition at line 439 of file Deserializer.cpp.

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

440 {
441  auto layerType = graphPtr->layers()->Get(layerIndex)->layer_type();
442 
443  if (layerType == Layer::Layer_InputLayer)
444  {
445  return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->layerBindingId();
446  }
447  else if ( layerType == Layer::Layer_OutputLayer )
448  {
449  return graphPtr->layers()->Get(layerIndex)->layer_as_OutputLayer()->base()->layerBindingId();
450  }
451  return 0;
452 }

◆ GetInputs()

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

Definition at line 765 of file Deserializer.cpp.

References CHECK_LAYERS, CHECKED_NON_NEGATIVE, and IDeserializer::DeserializerImpl::GetBaseLayer().

Referenced by IDeserializer::DeserializerImpl::GetLstmDescriptor(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), IDeserializer::DeserializerImpl::GetNormalizationDescriptor(), armnnDeserializer::GetOriginsDescriptor(), IDeserializer::DeserializerImpl::GetPooling3dDescriptor(), IDeserializer::DeserializerImpl::GetQLstmDescriptor(), IDeserializer::DeserializerImpl::GetUnidirectionalSequenceLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

766 {
767  CHECK_LAYERS(graphPtr, 0, layerIndex);
768  auto layer = GetBaseLayer(graphPtr, layerIndex);
769  const auto& numInputs = layer->inputSlots()->size();
770 
771  TensorRawPtrVector result(numInputs);
772 
773  for (unsigned int i=0; i<numInputs; ++i)
774  {
775  auto inputId = CHECKED_NON_NEGATIVE(static_cast<int32_t>
776  (layer->inputSlots()->Get(i)->connection()->sourceLayerIndex()));
777  result[i] = GetBaseLayer(graphPtr, inputId)->outputSlots()->Get(0)->tensorInfo();
778  }
779  return result;
780 }
#define CHECK_LAYERS(GRAPH, LAYERS_INDEX, LAYER_INDEX)
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)
std::vector< TensorRawPtr > TensorRawPtrVector
#define CHECKED_NON_NEGATIVE(VALUE)

◆ GetLayerName()

◆ GetLstmDescriptor()

armnn::LstmDescriptor GetLstmDescriptor ( LstmDescriptorPtr  lstmDescriptor)
static

Definition at line 3150 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetLayerNormWeights, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputLayerNormWeights, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, LstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputLayerNormWeights, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), and armnnDeserializer::ToTensorInfo().

3151 {
3152  armnn::LstmDescriptor desc;
3153 
3154  desc.m_ActivationFunc = lstmDescriptor->activationFunc();
3155  desc.m_ClippingThresCell = lstmDescriptor->clippingThresCell();
3156  desc.m_ClippingThresProj = lstmDescriptor->clippingThresProj();
3157  desc.m_CifgEnabled = lstmDescriptor->cifgEnabled();
3158  desc.m_PeepholeEnabled = lstmDescriptor->peepholeEnabled();
3159  desc.m_ProjectionEnabled = lstmDescriptor->projectionEnabled();
3160  desc.m_LayerNormEnabled = lstmDescriptor->layerNormEnabled();
3161 
3162  return desc;
3163 }
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
An LstmDescriptor for the LstmLayer.
bool m_PeepholeEnabled
Enable/disable peephole.
uint32_t m_ActivationFunc
The activation function to use.
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
bool m_LayerNormEnabled
Enable/disable layer normalization.

◆ GetLstmInputParams()

static armnn::LstmInputParams GetLstmInputParams ( LstmDescriptorPtr  lstmDescriptor,
LstmInputParamsPtr  lstmInputParams 
)
static

◆ GetNetworkInputBindingInfo()

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

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

Definition at line 898 of file Deserializer.cpp.

References CHECK_LOCATION, and armnn::IgnoreUnused().

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

◆ GetNetworkOutputBindingInfo()

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

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

Definition at line 914 of file Deserializer.cpp.

References armnn::Abs, ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_GRAPH, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnn::Equal, IDeserializer::DeserializerImpl::GetBaseLayer(), IDeserializer::DeserializerImpl::GetBindingLayerInfo(), armnn::GetDataTypeSize(), BaseTensor< MemoryType >::GetInfo(), IDeserializer::DeserializerImpl::GetInputs(), IConnectableLayer::GetInputSlot(), IDeserializer::DeserializerImpl::GetLayerName(), BaseTensor< MemoryType >::GetMemoryArea(), TensorInfo::GetNumBytes(), Convolution2dDescriptor::GetNumInputs(), Convolution3dDescriptor::GetNumInputs(), DepthwiseConvolution2dDescriptor::GetNumInputs(), IConnectableLayer::GetNumInputSlots(), IConnectableLayer::GetNumOutputSlots(), IDeserializer::DeserializerImpl::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, Convolution3dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_BiasEnabled, BatchToSpaceNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, BatchToSpaceNdDescriptor::m_Crops, Convolution2dDescriptor::m_DataLayout, Convolution3dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DataLayout, L2NormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_DataLayout, InstanceNormalizationDescriptor::m_DataLayout, BatchToSpaceNdDescriptor::m_DataLayout, SpaceToDepthDescriptor::m_DataLayout, DetectionPostProcessDescriptor::m_DetectionsPerClass, Convolution2dDescriptor::m_DilationX, Convolution3dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationX, Convolution2dDescriptor::m_DilationY, Convolution3dDescriptor::m_DilationY, DepthwiseConvolution2dDescriptor::m_DilationY, Convolution3dDescriptor::m_DilationZ, L2NormalizationDescriptor::m_Eps, BatchNormalizationDescriptor::m_Eps, InstanceNormalizationDescriptor::m_Eps, ActivationDescriptor::m_Function, ArgMinMaxDescriptor::m_Function, InstanceNormalizationDescriptor::m_Gamma, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, LogicalBinaryDescriptor::m_Operation, Convolution3dDescriptor::m_PadBack, Convolution2dDescriptor::m_PadBottom, Convolution3dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadBottom, Convolution3dDescriptor::m_PadFront, Convolution2dDescriptor::m_PadLeft, Convolution3dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution3dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution3dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_PadTop, DetectionPostProcessDescriptor::m_ScaleH, DetectionPostProcessDescriptor::m_ScaleW, DetectionPostProcessDescriptor::m_ScaleX, DetectionPostProcessDescriptor::m_ScaleY, Convolution2dDescriptor::m_StrideX, Convolution3dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, Convolution3dDescriptor::m_StrideY, DepthwiseConvolution2dDescriptor::m_StrideY, Convolution3dDescriptor::m_StrideZ, DetectionPostProcessDescriptor::m_UseRegularNms, FillDescriptor::m_Value, armnn::numeric_cast(), armnnUtils::Permute(), armnnUtils::Permuted(), TensorInfo::SetConstant(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToActivationFunction(), armnnDeserializer::ToArgMinMaxFunction(), armnnDeserializer::ToConstTensor(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToLogicalBinaryOperation(), and armnnDeserializer::ToTensorInfo().

916 {
917  IgnoreUnused(layerIndex);
918  for (auto outputBinding : m_OutputBindings)
919  {
920  if (outputBinding.first == name)
921  {
922  return outputBinding.second;
923  }
924  }
925  throw ParseException(fmt::format("No output binding found for layer:{0} / {1}",
926  name,
927  CHECK_LOCATION().AsString()));
928 }
void IgnoreUnused(Ts &&...)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203

◆ GetNormalizationDescriptor()

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

Definition at line 2821 of file Deserializer.cpp.

References armnn::Across, ARMNN_ASSERT_MSG, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), armnn::IgnoreUnused(), armnn::LocalBrightness, armnn::LocalContrast, NormalizationDescriptor::m_Alpha, GatherDescriptor::m_Axis, MeanDescriptor::m_Axis, SliceDescriptor::m_Begin, NormalizationDescriptor::m_Beta, NormalizationDescriptor::m_DataLayout, NormalizationDescriptor::m_K, MeanDescriptor::m_KeepDims, NormalizationDescriptor::m_NormChannelType, NormalizationDescriptor::m_NormMethodType, NormalizationDescriptor::m_NormSize, SliceDescriptor::m_Size, armnn::NCHW, armnn::NHWC, armnn::Rsqrt, IOutputSlot::SetTensorInfo(), ViewsDescriptor::SetViewOriginCoord(), ViewsDescriptor::SetViewSize(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToTensorInfo(), and armnn::Within.

2824 {
2825  IgnoreUnused(layerIndex);
2827 
2828  switch (normalizationDescriptor->normChannelType())
2829  {
2830  case NormalizationAlgorithmChannel_Across:
2831  {
2833  break;
2834  }
2835  case NormalizationAlgorithmChannel_Within:
2836  {
2838  break;
2839  }
2840  default:
2841  {
2842  ARMNN_ASSERT_MSG(false, "Unsupported normalization channel type");
2843  }
2844  }
2845 
2846  switch (normalizationDescriptor->normMethodType())
2847  {
2848  case NormalizationAlgorithmMethod_LocalBrightness:
2849  {
2851  break;
2852  }
2853  case NormalizationAlgorithmMethod_LocalContrast:
2854  {
2856  break;
2857  }
2858  default:
2859  {
2860  ARMNN_ASSERT_MSG(false, "Unsupported normalization method type");
2861  }
2862  }
2863 
2864  switch (normalizationDescriptor->dataLayout())
2865  {
2866  case DataLayout_NCHW:
2867  {
2869  break;
2870  }
2871  case DataLayout_NHWC:
2872  {
2874  break;
2875  }
2876  default:
2877  {
2878  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2879  }
2880  }
2881 
2882  desc.m_Alpha = normalizationDescriptor->alpha();
2883  desc.m_Beta = normalizationDescriptor->beta();
2884  desc.m_K = normalizationDescriptor->k();
2885  desc.m_NormSize = normalizationDescriptor->normSize();
2886 
2887  return desc;
2888 }
float m_K
Kappa value used for the across channel normalization equation.
float m_Alpha
Alpha value for the normalization equation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void IgnoreUnused(Ts &&...)
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
Jarret 2009: Local Contrast Normalization.
Krichevsky 2012: Local Brightness Normalization.
A NormalizationDescriptor for the NormalizationLayer.
float m_Beta
Beta value for the normalization equation.
uint32_t m_NormSize
Depth radius value.

◆ GetOutputs()

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

Definition at line 782 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, and IDeserializer::DeserializerImpl::GetBaseLayer().

Referenced by IDeserializer::DeserializerImpl::GetLstmDescriptor(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), IDeserializer::DeserializerImpl::GetNormalizationDescriptor(), armnnDeserializer::GetOriginsDescriptor(), IDeserializer::DeserializerImpl::GetPooling3dDescriptor(), IDeserializer::DeserializerImpl::GetQLstmDescriptor(), IDeserializer::DeserializerImpl::GetUnidirectionalSequenceLstmDescriptor(), and IDeserializer::DeserializerImpl::OutputShapeOfReshape().

783 {
784  CHECK_LAYERS(graphPtr, 0, layerIndex);
785  auto layer = GetBaseLayer(graphPtr, layerIndex);
786  const auto& numOutputs = layer->outputSlots()->size();
787 
788  TensorRawPtrVector result(numOutputs);
789 
790  for (unsigned int i=0; i<numOutputs; ++i)
791  {
792  result[i] = layer->outputSlots()->Get(i)->tensorInfo();
793  }
794  return result;
795 }
#define CHECK_LAYERS(GRAPH, LAYERS_INDEX, LAYER_INDEX)
static LayerBaseRawPtr GetBaseLayer(const GraphPtr &graphPtr, unsigned int layerIndex)
std::vector< TensorRawPtr > TensorRawPtrVector

◆ GetPooling2dDescriptor()

armnn::Pooling2dDescriptor GetPooling2dDescriptor ( Pooling2dDescriptor  pooling2dDescriptor,
unsigned int  layerIndex 
)
static

Definition at line 2267 of file Deserializer.cpp.

References ARMNN_ASSERT_MSG, armnn::Average, armnn::Ceiling, armnn::Exclude, armnn::Floor, armnn::IgnoreUnused(), armnn::IgnoreValue, armnn::L2, Pooling2dDescriptor::m_DataLayout, Pooling2dDescriptor::m_OutputShapeRounding, Pooling2dDescriptor::m_PadBottom, Pooling2dDescriptor::m_PaddingMethod, Pooling2dDescriptor::m_PadLeft, Pooling2dDescriptor::m_PadRight, Pooling2dDescriptor::m_PadTop, Pooling2dDescriptor::m_PoolHeight, Pooling2dDescriptor::m_PoolType, Pooling2dDescriptor::m_PoolWidth, Pooling2dDescriptor::m_StrideX, Pooling2dDescriptor::m_StrideY, armnn::Max, armnn::NCHW, and armnn::NHWC.

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

2269 {
2270  IgnoreUnused(layerIndex);
2272 
2273  switch (pooling2dDesc->poolType())
2274  {
2275  case PoolingAlgorithm_Average:
2276  {
2278  break;
2279  }
2280  case PoolingAlgorithm_Max:
2281  {
2283  break;
2284  }
2285  case PoolingAlgorithm_L2:
2286  {
2288  break;
2289  }
2290  default:
2291  {
2292  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
2293  }
2294  }
2295 
2296  switch (pooling2dDesc->outputShapeRounding())
2297  {
2298  case OutputShapeRounding_Floor:
2299  {
2301  break;
2302  }
2303  case OutputShapeRounding_Ceiling:
2304  {
2306  break;
2307  }
2308  default:
2309  {
2310  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
2311  }
2312  }
2313 
2314  switch (pooling2dDesc->paddingMethod())
2315  {
2316  case PaddingMethod_Exclude:
2317  {
2319  break;
2320  }
2321  case PaddingMethod_IgnoreValue:
2322  {
2324  break;
2325  }
2326  default:
2327  {
2328  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
2329  }
2330  }
2331 
2332  switch (pooling2dDesc->dataLayout())
2333  {
2334  case DataLayout_NCHW:
2335  {
2337  break;
2338  }
2339  case DataLayout_NHWC:
2340  {
2342  break;
2343  }
2344  default:
2345  {
2346  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2347  }
2348  }
2349 
2350  desc.m_PadRight = pooling2dDesc->padRight();
2351  desc.m_PadLeft = pooling2dDesc->padLeft();
2352  desc.m_PadBottom = pooling2dDesc->padBottom();
2353  desc.m_PadTop = pooling2dDesc->padTop();
2354  desc.m_StrideX = pooling2dDesc->strideX();
2355  desc.m_StrideY = pooling2dDesc->strideY();
2356  desc.m_PoolWidth = pooling2dDesc->poolWidth();
2357  desc.m_PoolHeight = pooling2dDesc->poolHeight();
2358 
2359  return desc;
2360 }
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.

◆ GetPooling3dDescriptor()

armnn::Pooling3dDescriptor GetPooling3dDescriptor ( Pooling3dDescriptor  pooling3dDescriptor,
unsigned int  layerIndex 
)
static

Definition at line 2362 of file Deserializer.cpp.

References ARMNN_ASSERT_MSG, armnn::Average, armnn::Ceiling, CHECK_LAYERS, CHECK_VALID_SIZE, armnn::Exclude, armnn::Floor, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), IDeserializer::DeserializerImpl::GetPooling2dDescriptor(), armnn::IgnoreUnused(), armnn::IgnoreValue, armnn::L2, Pooling3dDescriptor::m_DataLayout, Pooling3dDescriptor::m_OutputShapeRounding, Pooling3dDescriptor::m_PadBack, Pooling3dDescriptor::m_PadBottom, Pooling3dDescriptor::m_PaddingMethod, Pooling3dDescriptor::m_PadFront, Pooling3dDescriptor::m_PadLeft, Pooling3dDescriptor::m_PadRight, Pooling3dDescriptor::m_PadTop, Pooling3dDescriptor::m_PoolDepth, Pooling3dDescriptor::m_PoolHeight, Pooling3dDescriptor::m_PoolType, Pooling3dDescriptor::m_PoolWidth, Pooling3dDescriptor::m_StrideX, Pooling3dDescriptor::m_StrideY, Pooling3dDescriptor::m_StrideZ, armnn::Max, armnn::NCDHW, armnn::NDHWC, IOutputSlot::SetTensorInfo(), and armnnDeserializer::ToTensorInfo().

2364 {
2365  IgnoreUnused(layerIndex);
2367 
2368  switch (pooling3dDesc->poolType())
2369  {
2370  case PoolingAlgorithm_Average:
2371  {
2373  break;
2374  }
2375  case PoolingAlgorithm_Max:
2376  {
2378  break;
2379  }
2380  case PoolingAlgorithm_L2:
2381  {
2383  break;
2384  }
2385  default:
2386  {
2387  ARMNN_ASSERT_MSG(false, "Unsupported pooling algorithm");
2388  }
2389  }
2390 
2391  switch (pooling3dDesc->outputShapeRounding())
2392  {
2393  case OutputShapeRounding_Floor:
2394  {
2396  break;
2397  }
2398  case OutputShapeRounding_Ceiling:
2399  {
2401  break;
2402  }
2403  default:
2404  {
2405  ARMNN_ASSERT_MSG(false, "Unsupported output shape rounding");
2406  }
2407  }
2408 
2409  switch (pooling3dDesc->paddingMethod())
2410  {
2411  case PaddingMethod_Exclude:
2412  {
2414  break;
2415  }
2416  case PaddingMethod_IgnoreValue:
2417  {
2419  break;
2420  }
2421  default:
2422  {
2423  ARMNN_ASSERT_MSG(false, "Unsupported padding method");
2424  }
2425  }
2426 
2427  switch (pooling3dDesc->dataLayout())
2428  {
2429  case DataLayout_NCDHW:
2430  {
2432  break;
2433  }
2434  case DataLayout_NDHWC:
2435  {
2437  break;
2438  }
2439  default:
2440  {
2441  ARMNN_ASSERT_MSG(false, "Unsupported data layout");
2442  }
2443  }
2444 
2445  desc.m_PadRight = pooling3dDesc->padRight();
2446  desc.m_PadLeft = pooling3dDesc->padLeft();
2447  desc.m_PadBottom = pooling3dDesc->padBottom();
2448  desc.m_PadTop = pooling3dDesc->padTop();
2449  desc.m_PadFront = pooling3dDesc->padFront();
2450  desc.m_PadBack = pooling3dDesc->padBack();
2451  desc.m_StrideX = pooling3dDesc->strideX();
2452  desc.m_StrideY = pooling3dDesc->strideY();
2453  desc.m_StrideZ = pooling3dDesc->strideZ();
2454  desc.m_PoolWidth = pooling3dDesc->poolWidth();
2455  desc.m_PoolHeight = pooling3dDesc->poolHeight();
2456  desc.m_PoolDepth = pooling3dDesc->poolDepth();
2457 
2458  return desc;
2459 }
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PoolDepth
Pooling depth value.
The padding fields don&#39;t count and are ignored.
uint32_t m_PadRight
Padding right value in the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
void IgnoreUnused(Ts &&...)
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadBack
Padding back value in the depth dimension.
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
A Pooling3dDescriptor for the Pooling3dLayer.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
The padding fields count, but are ignored.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).

◆ GetQLstmDescriptor()

armnn::QLstmDescriptor GetQLstmDescriptor ( QLstmDescriptorPtr  qLstmDescriptorPtr)
static

Definition at line 3281 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), TransposeConvolution2dDescriptor::m_BiasEnabled, QuantizedLstmInputParams::m_CellBias, LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CellIntermediateScale, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, TransposeConvolution2dDescriptor::m_DataLayout, QuantizedLstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetGateBias, QLstmDescriptor::m_ForgetIntermediateScale, LstmInputParams::m_ForgetLayerNormWeights, QLstmDescriptor::m_HiddenStateScale, QLstmDescriptor::m_HiddenStateZeroPoint, QuantizedLstmInputParams::m_InputGateBias, LstmInputParams::m_InputGateBias, QLstmDescriptor::m_InputIntermediateScale, LstmInputParams::m_InputLayerNormWeights, QuantizedLstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, LstmInputParams::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, StandInDescriptor::m_NumInputs, StandInDescriptor::m_NumOutputs, QuantizedLstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_OutputIntermediateScale, LstmInputParams::m_OutputLayerNormWeights, TransposeConvolution2dDescriptor::m_PadBottom, TransposeConvolution2dDescriptor::m_PadLeft, TransposeConvolution2dDescriptor::m_PadRight, TransposeConvolution2dDescriptor::m_PadTop, QLstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, QLstmDescriptor::m_ProjectionClip, QLstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, QuantizedLstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, LstmInputParams::m_RecurrentToOutputWeights, TransposeConvolution2dDescriptor::m_StrideX, TransposeConvolution2dDescriptor::m_StrideY, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), armnnDeserializer::ToDataLayout(), and armnnDeserializer::ToTensorInfo().

3282 {
3284 
3285  desc.m_CifgEnabled = qLstmDescriptor->cifgEnabled();
3286  desc.m_PeepholeEnabled = qLstmDescriptor->peepholeEnabled();
3287  desc.m_ProjectionEnabled = qLstmDescriptor->projectionEnabled();
3288  desc.m_LayerNormEnabled = qLstmDescriptor->layerNormEnabled();
3289 
3290  desc.m_CellClip = qLstmDescriptor->cellClip();
3291  desc.m_ProjectionClip = qLstmDescriptor->projectionClip();
3292 
3293  desc.m_InputIntermediateScale = qLstmDescriptor->inputIntermediateScale();
3294  desc.m_ForgetIntermediateScale = qLstmDescriptor->forgetIntermediateScale();
3295  desc.m_CellIntermediateScale = qLstmDescriptor->cellIntermediateScale();
3296  desc.m_OutputIntermediateScale = qLstmDescriptor->outputIntermediateScale();
3297 
3298  desc.m_HiddenStateScale = qLstmDescriptor->hiddenStateScale();
3299  desc.m_HiddenStateZeroPoint = qLstmDescriptor->hiddenStateZeroPoint();
3300 
3301  return desc;
3302 }
bool m_PeepholeEnabled
Enable/disable peephole.
float m_HiddenStateScale
Hidden State quantization scale.
float m_OutputIntermediateScale
Output intermediate quantization scale.
bool m_LayerNormEnabled
Enable/disable layer normalization.
float m_ProjectionClip
Clipping threshold value for the projection.
float m_InputIntermediateScale
Input intermediate quantization scale.
A QLstmDescriptor for the QLstmLayer.
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
float m_CellClip
Clipping threshold value for the cell state.
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_CellIntermediateScale
Cell intermediate quantization scale.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
int32_t m_HiddenStateZeroPoint
Hidden State zero point.

◆ GetUnidirectionalSequenceLstmDescriptor()

armnn::UnidirectionalSequenceLstmDescriptor GetUnidirectionalSequenceLstmDescriptor ( UnidirectionalSequenceLstmDescriptorPtr  descriptor)
static

Definition at line 3713 of file Deserializer.cpp.

References CHECK_LAYERS, CHECK_VALID_SIZE, IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetLayerNormWeights, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputLayerNormWeights, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, LstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputLayerNormWeights, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, LstmDescriptor::m_TimeMajor, IOutputSlot::SetTensorInfo(), armnnDeserializer::ToConstTensor(), and armnnDeserializer::ToTensorInfo().

3715 {
3717 
3718  desc.m_ActivationFunc = descriptor->activationFunc();
3719  desc.m_ClippingThresCell = descriptor->clippingThresCell();
3720  desc.m_ClippingThresProj = descriptor->clippingThresProj();
3721  desc.m_CifgEnabled = descriptor->cifgEnabled();
3722  desc.m_PeepholeEnabled = descriptor->peepholeEnabled();
3723  desc.m_ProjectionEnabled = descriptor->projectionEnabled();
3724  desc.m_LayerNormEnabled = descriptor->layerNormEnabled();
3725  desc.m_TimeMajor = descriptor->timeMajor();
3726 
3727  return desc;
3728 }
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
bool m_TimeMajor
Enable/disable time major.
An LstmDescriptor for the LstmLayer.
bool m_PeepholeEnabled
Enable/disable peephole.
uint32_t m_ActivationFunc
The activation function to use.
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
bool m_LayerNormEnabled
Enable/disable layer normalization.

◆ LoadGraphFromBinary()

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

Definition at line 839 of file Deserializer.cpp.

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

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

840 {
841  if (binaryContent == nullptr)
842  {
843  throw InvalidArgumentException(fmt::format("Invalid (null) binary content {}",
844  CHECK_LOCATION().AsString()));
845  }
846  flatbuffers::Verifier verifier(binaryContent, len);
847  if (verifier.VerifyBuffer<SerializedGraph>() == false)
848  {
849  throw ParseException(fmt::format("Buffer doesn't conform to the expected Armnn "
850  "flatbuffers format. size:{0} {1}",
851  len,
852  CHECK_LOCATION().AsString()));
853  }
854  return GetSerializedGraph(binaryContent);
855 }
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203

◆ operator=()

DeserializerImpl& operator= ( const DeserializerImpl )
delete

◆ OutputShapeOfReshape()

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

Definition at line 2522 of file Deserializer.cpp.

References armnn::Bilinear, CHECK_LAYERS, CHECK_LOCATION, CHECK_VALID_SIZE, armnnDeserializer::CheckShape(), IDeserializer::DeserializerImpl::GetInputs(), IDeserializer::DeserializerImpl::GetLayerName(), TensorInfo::GetNumElements(), IDeserializer::DeserializerImpl::GetOutputs(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), ResizeDescriptor::m_AlignCorners, SoftmaxDescriptor::m_Beta, SpaceToBatchNdDescriptor::m_BlockShape, SpaceToDepthDescriptor::m_BlockSize, ResizeDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToDepthDescriptor::m_DataLayout, ResizeDescriptor::m_HalfPixelCenters, ReduceDescriptor::m_KeepDims, ResizeDescriptor::m_Method, SpaceToBatchNdDescriptor::m_PadList, ReduceDescriptor::m_ReduceOperation, ResizeDescriptor::m_TargetHeight, ReshapeDescriptor::m_TargetShape, ResizeDescriptor::m_TargetWidth, ReduceDescriptor::m_vAxis, armnn::numeric_cast(), TensorInfo::SetShape(), IOutputSlot::SetTensorInfo(), armnnDeserializer::ToDataLayout(), armnnDeserializer::ToReduceOperation(), armnnDeserializer::ToResizeMethod(), and armnnDeserializer::ToTensorInfo().

2524 {
2525  std::vector<unsigned int> outputDims(targetDimsIn.begin(), targetDimsIn.end());
2526  const auto stretchDim = std::find(targetDimsIn.begin(), targetDimsIn.end(), -1);
2527 
2528  if (stretchDim != targetDimsIn.end())
2529  {
2530  if (std::find(std::next(stretchDim), targetDimsIn.end(), -1) != targetDimsIn.end())
2531  {
2532  throw ParseException(fmt::format("At most one component of shape can be -1 {}",
2533  CHECK_LOCATION().AsString()));
2534  }
2535 
2536  auto targetNumElements =
2537  armnn::numeric_cast<unsigned int>(
2538  std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
2539 
2540  auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
2541  outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
2542  }
2543 
2544  TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());
2545 
2546  armnn::TensorInfo reshapeInfo = inputTensorInfo;
2547  reshapeInfo.SetShape(outputShape);
2548 
2549  return reshapeInfo;
2550 }
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:193
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
unsigned int GetNumElements() const
Definition: Tensor.hpp:196

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