14 #include <fmt/format.h> 17 using namespace armnn;
18 namespace fb = flatbuffers;
24 ISerializer::ISerializer() : pSerializerImpl(new SerializerImpl())
28 ISerializer::~ISerializer() =
default;
50 bool ISerializer::SaveSerializedToStream(std::ostream& stream)
52 return pSerializerImpl->SaveSerializedToStream(stream);
60 return serializer::ActivationFunction::ActivationFunction_Sigmoid;
62 return serializer::ActivationFunction::ActivationFunction_TanH;
64 return serializer::ActivationFunction::ActivationFunction_Linear;
66 return serializer::ActivationFunction::ActivationFunction_ReLu;
68 return serializer::ActivationFunction::ActivationFunction_BoundedReLu;
70 return serializer::ActivationFunction::ActivationFunction_LeakyReLu;
72 return serializer::ActivationFunction::ActivationFunction_Abs;
74 return serializer::ActivationFunction::ActivationFunction_Sqrt;
76 return serializer::ActivationFunction::ActivationFunction_Square;
78 return serializer::ActivationFunction::ActivationFunction_Elu;
80 return serializer::ActivationFunction::ActivationFunction_HardSwish;
82 return serializer::ActivationFunction::ActivationFunction_Sigmoid;
91 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Max;
94 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Min;
98 uint32_t SerializerStrategy::GetSerializedId(
LayerGuid guid)
100 if (m_guidMap.empty())
102 m_guidMap.insert(std::make_pair(guid, m_layerId));
104 else if (m_guidMap.find(guid) == m_guidMap.end())
107 m_guidMap.insert(std::make_pair(guid, m_layerId));
111 return m_guidMap[guid];
120 auto flatBufferInputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Input);
123 auto flatBufferInputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
124 flatBufferInputBaseLayer,
127 m_inputIds.push_back(
id);
130 auto flatBufferInputLayer = serializer::CreateInputLayer(m_flatBufferBuilder, flatBufferInputBindableBaseLayer);
133 CreateAnyLayer(flatBufferInputLayer.o, serializer::Layer::Layer_InputLayer);
143 auto flatBufferOutputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Output);
146 auto flatBufferOutputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
147 flatBufferOutputBaseLayer,
150 m_outputIds.push_back(
id);
153 auto flatBufferOutputLayer = serializer::CreateOutputLayer(m_flatBufferBuilder, flatBufferOutputBindableBaseLayer);
155 CreateAnyLayer(flatBufferOutputLayer.o, serializer::Layer::Layer_OutputLayer);
166 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Activation);
169 auto flatBufferDescriptor = CreateActivationDescriptor(m_flatBufferBuilder,
175 auto flatBufferAdditionLayer = CreateActivationLayer(m_flatBufferBuilder,
177 flatBufferDescriptor);
180 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_ActivationLayer);
189 auto flatBufferAdditionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Addition);
192 auto flatBufferAdditionLayer = serializer::CreateAdditionLayer(m_flatBufferBuilder, flatBufferAdditionBaseLayer);
195 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_AdditionLayer);
206 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ArgMinMax);
209 auto flatBufferDescriptor = CreateArgMinMaxDescriptor(m_flatBufferBuilder,
214 auto flatBufferLayer = CreateArgMinMaxLayer(m_flatBufferBuilder,
216 flatBufferDescriptor);
218 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ArgMinMaxLayer);
228 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchMatMul);
231 auto flatBufferDescriptor = CreateBatchMatMulDescriptor(m_flatBufferBuilder,
240 auto flatBufferBatchMatMulLayer = CreateBatchMatMulLayer(m_flatBufferBuilder,
242 flatBufferDescriptor);
245 CreateAnyLayer(flatBufferBatchMatMulLayer.o, serializer::Layer::Layer_BatchMatMulLayer);
256 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchToSpaceNd);
258 std::vector<unsigned int> crops;
259 crops.reserve(descriptor.
m_Crops.size() * 2);
260 for (
auto& crop : descriptor.
m_Crops)
262 crops.push_back(crop.first);
263 crops.push_back(crop.second);
266 auto flatBufferDescriptor =
267 CreateBatchToSpaceNdDescriptor(m_flatBufferBuilder,
268 m_flatBufferBuilder.CreateVector(descriptor.
m_BlockShape),
269 m_flatBufferBuilder.CreateVector(crops),
272 auto flatBufferLayer = serializer::CreateBatchToSpaceNdLayer(m_flatBufferBuilder,
274 flatBufferDescriptor);
276 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_BatchToSpaceNdLayer);
279 void SerializerStrategy::SerializeBatchNormalizationLayer(
282 const std::vector<armnn::ConstTensor>& constants,
292 auto fbBatchNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchNormalization);
293 auto fbBatchNormalizationDescriptor = serializer::CreateBatchNormalizationDescriptor(
295 batchNormDescriptor.
m_Eps,
298 auto fbMeanConstTensorInfo = CreateConstTensorInfo(mean);
299 auto fbVarianceConstTensorInfo = CreateConstTensorInfo(variance);
300 auto fbBetaConstTensorInfo = CreateConstTensorInfo(beta);
301 auto fbGammaConstTensorInfo = CreateConstTensorInfo(gamma);
302 auto fbBatchNormalizationLayer = serializer::CreateBatchNormalizationLayer(m_flatBufferBuilder,
303 fbBatchNormalizationBaseLayer,
304 fbBatchNormalizationDescriptor,
305 fbMeanConstTensorInfo,
306 fbVarianceConstTensorInfo,
307 fbBetaConstTensorInfo,
308 fbGammaConstTensorInfo);
310 CreateAnyLayer(fbBatchNormalizationLayer.o, serializer::Layer::Layer_BatchNormalizationLayer);
318 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Cast);
319 auto fbCastLayer = serializer::CreateCastLayer(m_flatBufferBuilder, fbBaseLayer);
320 CreateAnyLayer(fbCastLayer.o, serializer::Layer::Layer_CastLayer);
328 auto fbDescriptor = CreateChannelShuffleDescriptor(m_flatBufferBuilder,
331 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ChannelShuffle);
332 auto fbChannelShuffleLayer = serializer::CreateChannelShuffleLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
333 CreateAnyLayer(fbChannelShuffleLayer.o, serializer::Layer::Layer_ChannelShuffleLayer);
342 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Comparison);
343 auto fbDescriptor = serializer::CreateComparisonDescriptor(
347 auto fbLayer = serializer::CreateComparisonLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
348 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ComparisonLayer);
353 const std::vector<armnn::ConstTensor>& constants,
361 auto flatBufferConstantBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Constant);
363 auto flatBufferConstTensorInfo = CreateConstTensorInfo(input);
366 auto flatBufferLayer = CreateConstantLayer(m_flatBufferBuilder,
367 flatBufferConstantBaseLayer,
368 flatBufferConstTensorInfo);
371 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConstantLayer);
382 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
384 auto flatBufferDescriptor = CreateConvolution2dDescriptor(m_flatBufferBuilder,
397 auto flatBufferLayer = CreateConvolution2dLayer(m_flatBufferBuilder,
399 flatBufferDescriptor);
402 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution2dLayer);
413 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution3d);
415 auto flatBufferDescriptor = CreateConvolution3dDescriptor(m_flatBufferBuilder,
432 auto flatBufferLayer = CreateConvolution3dLayer(m_flatBufferBuilder,
434 flatBufferDescriptor);
437 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution3dLayer);
446 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthToSpace);
447 auto fbDescriptor = CreateDepthToSpaceDescriptor(m_flatBufferBuilder,
451 auto fbLayer = serializer::CreateDepthToSpaceLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
453 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_DepthToSpaceLayer);
462 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthwiseConvolution2d);
463 auto fbDescriptor = CreateDepthwiseConvolution2dDescriptor(m_flatBufferBuilder,
475 auto flatBufferLayer = CreateDepthwiseConvolution2dLayer(m_flatBufferBuilder,
479 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DepthwiseConvolution2dLayer);
487 auto fbDequantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Dequantize);
488 auto fbDequantizeLayer = serializer::CreateDequantizeLayer(m_flatBufferBuilder, fbDequantizeBaseLayer);
490 CreateAnyLayer(fbDequantizeLayer.o, serializer::Layer::Layer_DequantizeLayer);
495 const std::vector<armnn::ConstTensor>& constants,
502 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DetectionPostProcess);
503 auto fbDescriptor = CreateDetectionPostProcessDescriptor(m_flatBufferBuilder,
516 flatbuffers::Offset<serializer::ConstTensor> fbAnchorsConstTensorInfo = CreateConstTensorInfo(anchors);
518 auto flatBufferLayer = CreateDetectionPostProcessLayer(m_flatBufferBuilder,
521 fbAnchorsConstTensorInfo);
523 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DetectionPostProcessLayer);
530 auto fbDivisionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Division);
531 auto fbDivisionLayer = serializer::CreateDivisionLayer(m_flatBufferBuilder, fbDivisionBaseLayer);
533 CreateAnyLayer(fbDivisionLayer.o, serializer::Layer::Layer_DivisionLayer);
542 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ElementwiseUnary);
543 auto fbDescriptor = serializer::CreateElementwiseUnaryDescriptor(
547 auto fbLayer = serializer::CreateElementwiseUnaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
548 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseUnaryLayer);
557 auto fbFillBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Fill);
559 auto fbDescriptor = serializer::CreateFillDescriptor(m_flatBufferBuilder, fillDescriptor.
m_Value);
561 auto fbFillLayer = serializer::CreateFillLayer(m_flatBufferBuilder, fbFillBaseLayer, fbDescriptor);
563 CreateAnyLayer(fbFillLayer.o, serializer::Layer::Layer_FillLayer);
570 auto flatBufferFloorBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Floor);
571 auto flatBufferFloorLayer = serializer::CreateFloorLayer(m_flatBufferBuilder, flatBufferFloorBaseLayer);
573 CreateAnyLayer(flatBufferFloorLayer.o, serializer::Layer::Layer_FloorLayer);
582 auto fbGatherDescriptor = CreateGatherDescriptor(m_flatBufferBuilder,
584 auto fbGatherBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Gather);
585 auto flatBufferLayer = serializer::CreateGatherLayer(m_flatBufferBuilder, fbGatherBaseLayer, fbGatherDescriptor);
587 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherLayer);
595 auto fbGatherNdBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_GatherNd);
596 auto flatBufferLayer = serializer::CreateGatherNdLayer(m_flatBufferBuilder, fbGatherNdBaseLayer);
598 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherNdLayer);
601 void SerializerStrategy::SerializeInstanceNormalizationLayer(
608 auto fbDescriptor = serializer::CreateInstanceNormalizationDescriptor(
610 instanceNormalizationDescriptor.
m_Gamma,
611 instanceNormalizationDescriptor.
m_Beta,
612 instanceNormalizationDescriptor.
m_Eps,
615 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_InstanceNormalization);
616 auto fbLayer = serializer::CreateInstanceNormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
618 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_InstanceNormalizationLayer);
628 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_L2Normalization);
631 auto fbDescriptor = serializer::CreateL2NormalizationDescriptor(
634 l2NormalizationDescriptor.
m_Eps);
637 auto fbLayer = serializer::CreateL2NormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
639 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_L2NormalizationLayer);
648 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogicalBinary);
649 auto fbDescriptor = serializer::CreateLogicalBinaryDescriptor(
653 auto fbLayer = serializer::CreateLogicalBinaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
654 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_LogicalBinaryLayer);
664 auto flatBufferLogSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogSoftmax);
667 auto flatBufferLogSoftmaxDesc =
668 serializer::CreateLogSoftmaxDescriptor(m_flatBufferBuilder,
669 logSoftmaxDescriptor.
m_Beta,
670 logSoftmaxDescriptor.
m_Axis);
673 auto flatBufferLogSoftmaxLayer =
674 serializer::CreateLogSoftmaxLayer(m_flatBufferBuilder,
675 flatBufferLogSoftmaxBaseLayer,
676 flatBufferLogSoftmaxDesc);
678 CreateAnyLayer(flatBufferLogSoftmaxLayer.o, serializer::Layer::Layer_LogSoftmaxLayer);
683 const std::vector<armnn::ConstTensor>& constants,
688 auto fbLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Lstm);
690 auto fbLstmDescriptor = serializer::CreateLstmDescriptor(
704 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
705 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
706 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
707 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
708 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
709 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
710 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
711 auto cellBias = CreateConstTensorInfo(constants[i++]);
712 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
717 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
718 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
719 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
720 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
721 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
722 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
723 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
724 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
725 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
726 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
727 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
728 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
732 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
733 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
734 inputGateBias = CreateConstTensorInfo(constants[i++]);
741 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
743 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
744 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
749 projectionWeights = CreateConstTensorInfo(constants[i++]);
750 projectionBias = CreateConstTensorInfo(constants[i++]);
757 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
759 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
760 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
761 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
764 auto fbLstmParams = serializer::CreateLstmInputParams(
766 inputToForgetWeights,
768 inputToOutputWeights,
769 recurrentToForgetWeights,
770 recurrentToCellWeights,
771 recurrentToOutputWeights,
776 recurrentToInputWeights,
783 inputLayerNormWeights,
784 forgetLayerNormWeights,
785 cellLayerNormWeights,
786 outputLayerNormWeights);
788 auto fbLstmLayer = serializer::CreateLstmLayer(
794 CreateAnyLayer(fbLstmLayer.o, serializer::Layer::Layer_LstmLayer);
801 auto fbMaximumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Maximum);
802 auto fbMaximumLayer = serializer::CreateMaximumLayer(m_flatBufferBuilder, fbMaximumBaseLayer);
804 CreateAnyLayer(fbMaximumLayer.o, serializer::Layer::Layer_MaximumLayer);
813 auto fbMeanBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Mean);
814 auto fbMeanDescriptor = serializer::CreateMeanDescriptor(m_flatBufferBuilder,
815 m_flatBufferBuilder.CreateVector(descriptor.
m_Axis),
818 auto fbMeanLayer = serializer::CreateMeanLayer(m_flatBufferBuilder,
822 CreateAnyLayer(fbMeanLayer.o, serializer::Layer::Layer_MeanLayer);
829 auto fbMinimumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Minimum);
830 auto fbMinimumLayer = serializer::CreateMinimumLayer(m_flatBufferBuilder, fbMinimumBaseLayer);
832 CreateAnyLayer(fbMinimumLayer.o, serializer::Layer::Layer_MinimumLayer);
839 auto fbMergeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Merge);
840 auto fbMergeLayer = serializer::CreateMergeLayer(m_flatBufferBuilder, fbMergeBaseLayer);
842 CreateAnyLayer(fbMergeLayer.o, serializer::Layer::Layer_MergeLayer);
851 auto flatBufferConcatBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Concat);
853 std::vector<flatbuffers::Offset<UintVector>> views;
854 for (
unsigned int v = 0; v < concatDescriptor.
GetNumViews(); ++v)
857 std::vector<uint32_t> origins;
860 origins.push_back(origin[d]);
862 auto view = m_flatBufferBuilder.CreateVector(origins);
863 auto uintVector = CreateUintVector(m_flatBufferBuilder, view);
864 views.push_back(uintVector);
867 auto flatBufferConcatDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
871 m_flatBufferBuilder.CreateVector(views));
873 auto flatBufferLayer = CreateConcatLayer(m_flatBufferBuilder,
874 flatBufferConcatBaseLayer,
875 flatBufferConcatDescriptor);
877 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConcatLayer);
884 auto fbMultiplicationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Multiplication);
885 auto fbMultiplicationLayer = serializer::CreateMultiplicationLayer(m_flatBufferBuilder,
886 fbMultiplicationBaseLayer);
888 CreateAnyLayer(fbMultiplicationLayer.o, serializer::Layer::Layer_MultiplicationLayer);
897 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pad);
899 std::vector<unsigned int> padList;
902 padList.push_back(p.first);
903 padList.push_back(p.second);
906 auto flatBufferPadDesc = serializer::CreatePadDescriptor(m_flatBufferBuilder,
907 m_flatBufferBuilder.CreateVector(padList),
911 auto flatBufferPadLayer = serializer::CreatePadLayer(m_flatBufferBuilder,
915 CreateAnyLayer(flatBufferPadLayer.o, serializer::Layer::Layer_PadLayer);
925 auto flatBufferPermuteBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Permute);
927 std::vector<unsigned int> dimMappings;
933 auto flatBufferPermuteDesc = serializer::CreatePermuteDescriptor(m_flatBufferBuilder,
934 m_flatBufferBuilder.CreateVector(dimMappings));
937 auto flatBufferPermuteLayer = serializer::CreatePermuteLayer(m_flatBufferBuilder,
938 flatBufferPermuteBaseLayer,
939 flatBufferPermuteDesc);
942 CreateAnyLayer(flatBufferPermuteLayer.o, serializer::Layer::Layer_PermuteLayer);
950 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Rank);
951 auto flatBufferRankLayer = serializer::CreateRankLayer(m_flatBufferBuilder, flatBufferBaseLayer);
953 CreateAnyLayer(flatBufferRankLayer.o, serializer::Layer::Layer_RankLayer);
960 auto fbReduceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reduce);
961 auto fbDescriptor = CreateReduceDescriptor(m_flatBufferBuilder,
963 m_flatBufferBuilder.CreateVector(reduceDescriptor.
m_vAxis),
965 auto fbReduceLayer = serializer::CreateReduceLayer(m_flatBufferBuilder,
969 CreateAnyLayer(fbReduceLayer.o, serializer::Layer::Layer_ReduceLayer);
980 auto flatBufferReshapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reshape);
982 std::vector<unsigned int> targetShape;
988 auto flatBufferReshapeDesc = serializer::CreateReshapeDescriptor(m_flatBufferBuilder,
989 m_flatBufferBuilder.CreateVector(targetShape));
992 auto flatBufferReshapeLayer = serializer::CreateReshapeLayer(m_flatBufferBuilder, flatBufferReshapeBaseLayer,
993 flatBufferReshapeDesc);
996 CreateAnyLayer(flatBufferReshapeLayer.o, serializer::Layer::Layer_ReshapeLayer);
1005 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Resize);
1007 auto flatBufferDescriptor =
1008 CreateResizeDescriptor(m_flatBufferBuilder,
1016 auto flatBufferLayer = serializer::CreateResizeLayer(m_flatBufferBuilder,
1017 flatBufferBaseLayer,
1018 flatBufferDescriptor);
1020 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeLayer);
1029 auto fbSliceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Slice);
1030 auto fbSliceDescriptor = CreateSliceDescriptor(m_flatBufferBuilder,
1031 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Begin),
1032 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Size));
1034 auto fbSliceLayer = serializer::CreateSliceLayer(m_flatBufferBuilder, fbSliceBaseLayer, fbSliceDescriptor);
1036 CreateAnyLayer(fbSliceLayer.o, serializer::Layer::Layer_SliceLayer);
1047 auto flatBufferSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Softmax);
1050 auto flatBufferSoftmaxDesc =
1051 serializer::CreateSoftmaxDescriptor(m_flatBufferBuilder,
1052 softmaxDescriptor.
m_Beta,
1053 softmaxDescriptor.
m_Axis);
1056 auto flatBufferSoftmaxLayer =
1057 serializer::CreateSoftmaxLayer(m_flatBufferBuilder,
1058 flatBufferSoftmaxBaseLayer,
1059 flatBufferSoftmaxDesc);
1061 CreateAnyLayer(flatBufferSoftmaxLayer.o, serializer::Layer::Layer_SoftmaxLayer);
1070 auto fbPooling2dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling2d);
1071 auto fbPooling2dDescriptor = serializer::CreatePooling2dDescriptor(
1072 m_flatBufferBuilder,
1086 auto fbPooling2dLayer = serializer::CreatePooling2dLayer(m_flatBufferBuilder,
1087 fbPooling2dBaseLayer,
1088 fbPooling2dDescriptor);
1090 CreateAnyLayer(fbPooling2dLayer.o, serializer::Layer::Layer_Pooling2dLayer);
1099 auto fbPooling3dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling3d);
1100 auto fbPooling3dDescriptor = serializer::CreatePooling3dDescriptor(
1101 m_flatBufferBuilder,
1119 auto fbPooling3dLayer = serializer::CreatePooling3dLayer(m_flatBufferBuilder,
1120 fbPooling3dBaseLayer,
1121 fbPooling3dDescriptor);
1123 CreateAnyLayer(fbPooling3dLayer.o, serializer::Layer::Layer_Pooling3dLayer);
1132 auto flatBufferPreluBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Prelu);
1135 auto flatBufferPreluLayer = serializer::CreatePreluLayer(m_flatBufferBuilder, flatBufferPreluBaseLayer);
1138 CreateAnyLayer(flatBufferPreluLayer.o, serializer::Layer::Layer_PreluLayer);
1145 auto fbQuantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Quantize);
1146 auto fbQuantizeLayer = serializer::CreateQuantizeLayer(m_flatBufferBuilder,
1147 fbQuantizeBaseLayer);
1148 CreateAnyLayer(fbQuantizeLayer.o, serializer::Layer::Layer_QuantizeLayer);
1157 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_FullyConnected);
1160 auto flatBufferDescriptor =
1161 serializer::CreateFullyConnectedDescriptor(m_flatBufferBuilder,
1167 auto flatBufferLayer = serializer::CreateFullyConnectedLayer(m_flatBufferBuilder,
1168 flatBufferBaseLayer,
1169 flatBufferDescriptor);
1172 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_FullyConnectedLayer);
1183 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToBatchNd);
1185 std::vector<unsigned int> padList;
1186 padList.reserve(spaceToBatchNdDescriptor.
m_PadList.size()*2);
1187 for (
auto& pad : spaceToBatchNdDescriptor.
m_PadList)
1189 padList.push_back(pad.first);
1190 padList.push_back(pad.second);
1193 auto flatBufferDescriptor =
1194 CreateSpaceToBatchNdDescriptor(m_flatBufferBuilder,
1195 m_flatBufferBuilder.CreateVector(spaceToBatchNdDescriptor.
m_BlockShape),
1196 m_flatBufferBuilder.CreateVector(padList),
1199 auto flatBufferLayer = serializer::CreateSpaceToBatchNdLayer(m_flatBufferBuilder,
1200 flatBufferBaseLayer,
1201 flatBufferDescriptor);
1203 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToBatchNdLayer);
1213 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToDepth);
1214 auto flatBufferDescriptor =
1215 CreateSpaceToDepthDescriptor(m_flatBufferBuilder,
1219 auto flatBufferLayer = serializer::CreateSpaceToDepthLayer(m_flatBufferBuilder,
1220 flatBufferBaseLayer,
1221 flatBufferDescriptor);
1223 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToDepthLayer);
1234 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewOrigins;
1235 flatBufferViewOrigins.reserve(viewsDescriptor.
GetNumViews());
1237 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1239 std::vector<uint32_t> viewOrigin;
1243 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1245 viewOrigin.push_back(viewsDescriptor.
GetViewOrigin(vIdx)[dIdx]);
1248 flatBufferViewOrigins.push_back(CreateUintVector(m_flatBufferBuilder,
1249 m_flatBufferBuilder.CreateVector(viewOrigin)));
1253 auto flatBufferOriginDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
1257 m_flatBufferBuilder.CreateVector(flatBufferViewOrigins));
1260 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewSizes;
1261 flatBufferViewSizes.reserve(viewsDescriptor.
GetNumViews());
1263 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1265 std::vector<uint32_t> viewSize;
1269 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1271 viewSize.push_back(viewsDescriptor.
GetViewSizes(vIdx)[dIdx]);
1274 flatBufferViewSizes.push_back(CreateUintVector(m_flatBufferBuilder,
1275 m_flatBufferBuilder.CreateVector(viewSize)));
1279 auto flatBufferViewsDescriptor = CreateViewsDescriptor(m_flatBufferBuilder,
1280 flatBufferOriginDescriptor,
1281 m_flatBufferBuilder.CreateVector(flatBufferViewSizes));
1284 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Splitter);
1286 auto flatBufferSplitterLayer = serializer::CreateSplitterLayer(m_flatBufferBuilder,
1287 flatBufferBaseLayer,
1288 flatBufferViewsDescriptor);
1290 CreateAnyLayer(flatBufferSplitterLayer.o, serializer::Layer::Layer_SplitterLayer);
1299 auto fbNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Normalization);
1301 auto fbNormalizationDescriptor = serializer::CreateNormalizationDescriptor(
1302 m_flatBufferBuilder,
1311 auto flatBufferLayer = serializer::CreateNormalizationLayer(m_flatBufferBuilder,
1312 fbNormalizationBaseLayer,
1313 fbNormalizationDescriptor);
1315 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_NormalizationLayer);
1323 auto shapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Shape);
1324 auto shapeLayer = serializer::CreateShapeLayer(m_flatBufferBuilder, shapeBaseLayer);
1326 CreateAnyLayer(shapeLayer.o, serializer::Layer::Layer_ShapeLayer);
1335 auto stackBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Stack);
1337 std::vector<unsigned int> inputShape;
1343 auto flatBufferStackDescriptor = CreateStackDescriptor(m_flatBufferBuilder,
1346 m_flatBufferBuilder.CreateVector(inputShape));
1348 auto stackLayer = serializer::CreateStackLayer(m_flatBufferBuilder, stackBaseLayer, flatBufferStackDescriptor);
1349 CreateAnyLayer(stackLayer.o, serializer::Layer::Layer_StackLayer);
1358 auto fbDescriptor = serializer::CreateStandInDescriptor(m_flatBufferBuilder,
1362 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StandIn);
1363 auto fbLayer = serializer::CreateStandInLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
1365 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_StandInLayer);
1374 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StridedSlice);
1376 auto flatBufferDescriptor =
1377 CreateStridedSliceDescriptor(m_flatBufferBuilder,
1378 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Begin),
1379 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_End),
1380 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Stride),
1388 auto flatBufferLayer = serializer::CreateStridedSliceLayer(m_flatBufferBuilder,
1389 flatBufferBaseLayer,
1390 flatBufferDescriptor);
1392 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_StridedSliceLayer);
1399 auto fbSubtractionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Subtraction);
1400 auto fbSubtractionLayer = serializer::CreateSubtractionLayer(m_flatBufferBuilder, fbSubtractionBaseLayer);
1402 CreateAnyLayer(fbSubtractionLayer.o, serializer::Layer::Layer_SubtractionLayer);
1409 auto fbSwitchBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Switch);
1410 auto fbSwitchLayer = serializer::CreateSwitchLayer(m_flatBufferBuilder, fbSwitchBaseLayer);
1412 CreateAnyLayer(fbSwitchLayer.o, serializer::Layer::Layer_SwitchLayer);
1415 void SerializerStrategy::SerializeTransposeConvolution2dLayer(
1418 const std::vector<armnn::ConstTensor>& constants,
1425 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
1426 auto fbDescriptor = CreateTransposeConvolution2dDescriptor(m_flatBufferBuilder,
1437 auto fbWeightsConstTensorInfo = CreateConstTensorInfo(weights);
1438 flatbuffers::Offset<serializer::ConstTensor> fbBiasesConstTensorInfo;
1439 if (constants.size() > 1)
1442 fbBiasesConstTensorInfo = CreateConstTensorInfo(biases);
1445 auto fbLayer = CreateTransposeConvolution2dLayer(m_flatBufferBuilder,
1448 fbWeightsConstTensorInfo,
1449 fbBiasesConstTensorInfo);
1451 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_TransposeConvolution2dLayer);
1461 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Transpose);
1463 std::vector<unsigned int> dimMappings;
1469 auto flatBufferDesc = serializer::CreateTransposeDescriptor(m_flatBufferBuilder,
1470 m_flatBufferBuilder.CreateVector(dimMappings));
1473 auto flatBufferLayer = serializer::CreateTransposeLayer(m_flatBufferBuilder,
1474 flatBufferBaseLayer,
1478 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_TransposeLayer);
1483 const std::vector<armnn::ConstTensor>& constants,
1488 auto fbQLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QLstm);
1490 auto fbQLstmDescriptor = serializer::CreateQLstmDescriptor(
1491 m_flatBufferBuilder,
1510 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1511 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1512 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1513 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1514 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1515 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1516 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1517 auto cellBias = CreateConstTensorInfo(constants[i++]);
1518 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1521 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1522 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1523 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1527 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1528 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1529 inputGateBias = CreateConstTensorInfo(constants[i++]);
1533 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1534 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1535 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1541 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1543 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1544 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1548 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1549 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1553 projectionWeights = CreateConstTensorInfo(constants[i++]);
1554 projectionBias = CreateConstTensorInfo(constants[i++]);
1558 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1559 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1560 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1561 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1567 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1569 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1570 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1571 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1574 auto fbQLstmParams = serializer::CreateQLstmInputParams(
1575 m_flatBufferBuilder,
1576 inputToForgetWeights,
1578 inputToOutputWeights,
1579 recurrentToForgetWeights,
1580 recurrentToCellWeights,
1581 recurrentToOutputWeights,
1585 inputToInputWeights,
1586 recurrentToInputWeights,
1591 cellToForgetWeights,
1592 cellToOutputWeights,
1593 inputLayerNormWeights,
1594 forgetLayerNormWeights,
1595 cellLayerNormWeights,
1596 outputLayerNormWeights);
1598 auto fbQLstmLayer = serializer::CreateQLstmLayer(
1599 m_flatBufferBuilder,
1604 CreateAnyLayer(fbQLstmLayer.o, serializer::Layer::Layer_QLstmLayer);
1608 const std::vector<armnn::ConstTensor>& constants,
1613 auto fbQuantizedLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QuantizedLstm);
1619 auto inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1620 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1621 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1622 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1624 auto recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1625 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1626 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1627 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1629 auto inputGateBias = CreateConstTensorInfo(constants[i++]);
1630 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1631 auto cellBias = CreateConstTensorInfo(constants[i++]);
1632 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1634 auto fbQuantizedLstmParams = serializer::CreateQuantizedLstmInputParams(
1635 m_flatBufferBuilder,
1636 inputToInputWeights,
1637 inputToForgetWeights,
1639 inputToOutputWeights,
1640 recurrentToInputWeights,
1641 recurrentToForgetWeights,
1642 recurrentToCellWeights,
1643 recurrentToOutputWeights,
1649 auto fbQuantizedLstmLayer = serializer::CreateQuantizedLstmLayer(
1650 m_flatBufferBuilder,
1651 fbQuantizedLstmBaseLayer,
1652 fbQuantizedLstmParams);
1654 CreateAnyLayer(fbQuantizedLstmLayer.o, serializer::Layer::Layer_QuantizedLstmLayer);
1657 void SerializerStrategy::SerializeUnidirectionalSequenceLstmLayer(
1660 const std::vector<armnn::ConstTensor>& constants,
1665 auto fbUnidirectionalSequenceLstmBaseLayer =
1666 CreateLayerBase(layer, serializer::LayerType::LayerType_UnidirectionalSequenceLstm);
1668 auto fbUnidirectionalSequenceLstmDescriptor = serializer::CreateUnidirectionalSequenceLstmDescriptor(
1669 m_flatBufferBuilder,
1683 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1684 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1685 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1686 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1687 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1688 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1689 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1690 auto cellBias = CreateConstTensorInfo(constants[i++]);
1691 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1694 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1695 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1696 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1697 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1698 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1699 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1700 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1701 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1702 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1703 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1704 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1705 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1709 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1710 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1711 inputGateBias = CreateConstTensorInfo(constants[i++]);
1718 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1720 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1721 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1726 projectionWeights = CreateConstTensorInfo(constants[i++]);
1727 projectionBias = CreateConstTensorInfo(constants[i++]);
1734 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1736 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1737 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1738 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1741 auto fbUnidirectionalSequenceLstmParams = serializer::CreateLstmInputParams(
1742 m_flatBufferBuilder,
1743 inputToForgetWeights,
1745 inputToOutputWeights,
1746 recurrentToForgetWeights,
1747 recurrentToCellWeights,
1748 recurrentToOutputWeights,
1752 inputToInputWeights,
1753 recurrentToInputWeights,
1758 cellToForgetWeights,
1759 cellToOutputWeights,
1760 inputLayerNormWeights,
1761 forgetLayerNormWeights,
1762 cellLayerNormWeights,
1763 outputLayerNormWeights);
1765 auto fbUnidirectionalSequenceLstmLayer = serializer::CreateUnidirectionalSequenceLstmLayer(
1766 m_flatBufferBuilder,
1767 fbUnidirectionalSequenceLstmBaseLayer,
1768 fbUnidirectionalSequenceLstmDescriptor,
1769 fbUnidirectionalSequenceLstmParams);
1771 CreateAnyLayer(fbUnidirectionalSequenceLstmLayer.o, serializer::Layer::Layer_UnidirectionalSequenceLstmLayer);
1774 fb::Offset<serializer::LayerBase> SerializerStrategy::CreateLayerBase(
const IConnectableLayer* layer,
1778 uint32_t fbIndex = GetSerializedId(layer->
GetGuid());
1780 std::vector<fb::Offset<serializer::InputSlot>> inputSlots = CreateInputSlots(layer);
1781 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots = CreateOutputSlots(layer);
1783 return serializer::CreateLayerBase(m_flatBufferBuilder,
1785 m_flatBufferBuilder.CreateString(layer->
GetName()),
1787 m_flatBufferBuilder.CreateVector(inputSlots),
1788 m_flatBufferBuilder.CreateVector(outputSlots));
1791 void SerializerStrategy::CreateAnyLayer(
const flatbuffers::Offset<void>& layer,
const serializer::Layer serializerLayer)
1794 auto anyLayer = armnnSerializer::CreateAnyLayer(m_flatBufferBuilder, serializerLayer, layer);
1795 m_serializedLayers.push_back(anyLayer);
1798 template <
typename T>
1799 flatbuffers::Offset<flatbuffers::Vector<T>> SerializerStrategy::CreateDataVector(
const void* memory,
unsigned int size)
1801 const T* buffer =
reinterpret_cast<const T*
>(memory);
1802 std::vector<T> vector(buffer, buffer + (size /
sizeof(T)));
1803 auto fbVector = m_flatBufferBuilder.CreateVector(vector);
1807 flatbuffers::Offset<TensorInfo> SerializerStrategy::CreateTensorInfo(
const armnn::TensorInfo& tensorInfo)
1810 std::vector<unsigned int> shape;
1811 std::vector<bool> specificity;
1820 shape.push_back(tensorInfo.
GetShape()[dim]);
1831 auto flatBufferTensorInfo =
1832 serializer::CreateTensorInfo(m_flatBufferBuilder,
1833 m_flatBufferBuilder.CreateVector(shape),
1839 static_cast<unsigned int> 1841 m_flatBufferBuilder.CreateVector(specificity));
1842 return flatBufferTensorInfo;
1846 auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder,
1847 m_flatBufferBuilder.CreateVector(shape),
1853 static_cast<unsigned int> 1855 m_flatBufferBuilder.CreateVector(specificity));
1856 return flatBufferTensorInfo;
1859 flatbuffers::Offset<serializer::ConstTensor>
1864 flatbuffers::Offset<void> fbPayload;
1871 flatbuffers::Offset<serializer::LongData> flatBuffersData = serializer::CreateLongData(
1872 m_flatBufferBuilder,
1874 fbPayload = flatBuffersData.o;
1881 flatbuffers::Offset<serializer::IntData> flatBuffersData = serializer::CreateIntData(
1882 m_flatBufferBuilder,
1884 fbPayload = flatBuffersData.o;
1892 flatbuffers::Offset<serializer::ShortData> flatBuffersData = serializer::CreateShortData(
1893 m_flatBufferBuilder,
1895 fbPayload = flatBuffersData.o;
1905 flatbuffers::Offset<serializer::ByteData> flatBuffersData = serializer::CreateByteData(
1906 m_flatBufferBuilder,
1908 fbPayload = flatBuffersData.o;
1911 flatbuffers::Offset<serializer::ConstTensor> flatBufferConstTensor = serializer::CreateConstTensor(
1912 m_flatBufferBuilder,
1913 CreateTensorInfo(tensorInfo),
1916 return flatBufferConstTensor;
1919 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> SerializerStrategy::GetVersionTable()
1921 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> versionsTable =
1922 serializer::CreateFeatureCompatibilityVersions(
1923 m_flatBufferBuilder,
1928 return versionsTable;
1931 std::vector<fb::Offset<serializer::InputSlot>>
1934 std::vector<fb::Offset<serializer::InputSlot>> inputSlots;
1937 for (
unsigned int slotIndex = 0; slotIndex<layer->
GetNumInputSlots(); ++slotIndex)
1948 inputSlots.push_back(serializer::CreateInputSlot(m_flatBufferBuilder, slotIndex, &conn));
1953 std::vector<fb::Offset<serializer::OutputSlot>>
1956 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots;
1959 for (
unsigned int slotIndex = 0; slotIndex < layer->
GetNumOutputSlots(); ++slotIndex)
1965 outputSlots.push_back(serializer::CreateOutputSlot(m_flatBufferBuilder,
1967 CreateTensorInfo(tensorInfo)));
1974 const std::vector<armnn::ConstTensor>& constants,
1986 SerializeActivationLayer(layer, layerDescriptor, name);
1991 SerializeAdditionLayer(layer, name);
1998 SerializeArgMinMaxLayer(layer, layerDescriptor, name);
2005 SerializeBatchMatMulLayer(layer,
2014 SerializeBatchNormalizationLayer(layer,
2024 SerializeBatchToSpaceNdLayer(layer,
2031 SerializeCastLayer(layer, name);
2038 SerializeChannelShuffleLayer(layer,
2047 SerializeComparisonLayer(layer,
2056 SerializeConcatLayer(layer,
2063 SerializeConstantLayer(layer,
2072 SerializeConvolution2dLayer(layer,
2081 SerializeConvolution3dLayer(layer,
2090 SerializeDepthToSpaceLayer(layer,
2099 SerializeDepthwiseConvolution2dLayer(layer,
2106 SerializeDequantizeLayer(layer,
2114 SerializeDetectionPostProcessLayer(layer, layerDescriptor, constants, name);
2119 SerializeDivisionLayer(layer, name);
2126 SerializeElementwiseUnaryLayer(layer, layerDescriptor, name);
2133 SerializeFillLayer(layer, layerDescriptor, name);
2138 SerializeFloorLayer(layer, name);
2145 SerializeFullyConnectedLayer(layer, layerDescriptor, name);
2152 SerializeGatherLayer(layer, layerDescriptor, name);
2157 SerializeGatherNdLayer(layer, name);
2162 SerializeInputLayer(layer,
id, name);
2169 SerializeInstanceNormalizationLayer(layer, layerDescriptor, name);
2176 SerializeL2NormalizationLayer(layer, layerDescriptor, name);
2183 SerializeLogicalBinaryLayer(layer, layerDescriptor, name);
2190 SerializeLogSoftmaxLayer(layer, layerDescriptor, name);
2197 SerializeLstmLayer(layer, layerDescriptor, constants, name);
2204 SerializeQLstmLayer(layer, layerDescriptor, constants, name);
2209 SerializeMaximumLayer(layer, name);
2216 SerializeMeanLayer(layer, layerDescriptor, name);
2221 SerializeMergeLayer(layer, name);
2226 SerializeMinimumLayer(layer, name);
2231 SerializeMultiplicationLayer(layer, name);
2238 SerializeNormalizationLayer(layer, layerDescriptor, name);
2243 SerializeOutputLayer(layer,
id, name);
2250 SerializePadLayer(layer, layerDescriptor, name);
2257 SerializePermuteLayer(layer, layerDescriptor, name);
2264 SerializePooling2dLayer(layer, layerDescriptor, name);
2271 SerializePooling3dLayer(layer, layerDescriptor, name);
2276 SerializePreluLayer(layer, name);
2281 SerializeQuantizeLayer(layer, name);
2285 SerializeQuantizedLstmLayer(layer, constants, name);
2291 SerializeReshapeLayer(layer, layerDescriptor, name);
2296 SerializeRankLayer(layer, name);
2303 SerializeReduceLayer(layer, layerDescriptor, name);
2310 SerializeResizeLayer(layer, layerDescriptor, name);
2315 SerializeShapeLayer(layer, name);
2322 SerializeSliceLayer(layer, layerDescriptor, name);
2329 SerializeSoftmaxLayer(layer, layerDescriptor, name);
2336 SerializeSpaceToBatchNdLayer(layer, layerDescriptor, name);
2343 SerializeSpaceToDepthLayer(layer, layerDescriptor, name);
2350 SerializeSplitterLayer(layer, layerDescriptor, name);
2357 SerializeStackLayer(layer, layerDescriptor, name);
2364 SerializeStandInLayer(layer, layerDescriptor, name);
2371 SerializeStridedSliceLayer(layer, layerDescriptor, name);
2376 SerializeSubtractionLayer(layer, name);
2381 SerializeSwitchLayer(layer, name);
2388 SerializeTransposeLayer(layer, layerDescriptor, name);
2395 SerializeTransposeConvolution2dLayer(layer, layerDescriptor, constants, name);
2402 SerializeUnidirectionalSequenceLstmLayer(layer, layerDescriptor, constants, name);
2408 fmt::format(
"A layer of unknown type was given to the serializer. Layer name: {}; Layer Id: {}",
2415 void ISerializer::SerializerImpl::Serialize(
const INetwork& inNetwork)
2419 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2422 auto serializedGraph = serializer::CreateSerializedGraph(
2424 fbBuilder.CreateVector(m_SerializerStrategy.GetSerializedLayers()),
2425 fbBuilder.CreateVector(m_SerializerStrategy.GetInputIds()),
2426 fbBuilder.CreateVector(m_SerializerStrategy.GetOutputIds()),
2427 m_SerializerStrategy.GetVersionTable());
2430 fbBuilder.Finish(serializedGraph);
2434 bool ISerializer::SerializerImpl::SaveSerializedToStream(std::ostream& stream)
2436 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2439 stream.write(reinterpret_cast<const char*>(fbBuilder.GetBufferPointer()), bytesToWrite);
2440 return !stream.bad();
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
float m_Eps
Used to avoid dividing by zero.
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperation comparisonOperation)
bool m_ProjectionEnabled
Enable/disable the projection layer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
UnaryOperation m_Operation
Specifies the elementwiseUnary operation to execute.
uint32_t m_Axis
0-based axis along which to stack the input tensors.
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
float m_ScaleW
Center size encoding scale weight.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
void ExecuteStrategy(IStrategy &strategy) const
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
float m_K
Kappa value used for the across channel normalization equation.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
const TensorShape & GetShape() const
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
float m_ClippingThresProj
Clipping threshold value for the projection.
uint32_t m_PoolDepth
Pooling depth value.
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
A ReshapeDescriptor for the ReshapeLayer.
std::vector< int > m_Begin
Begin values for the input that will be sliced.
uint32_t m_PadBack
Padding back value in the depth dimension.
float m_PadValue
Optional value to use for padding, defaults to 0.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t GetNumDimensions() const
Get the number of dimensions.
A ComparisonDescriptor for the ComparisonLayer.
float m_ScaleX
Center size encoding scale x.
TensorShape m_InputShape
Required shape of all input tensors.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
Dimensionality GetDimensionality() const
Function that returns the tensor type.
bool HasPerAxisQuantization() const
uint32_t m_PoolWidth
Pooling width value.
bool m_PeepholeEnabled
Enable/disable peephole.
armnnSerializer::OutputShapeRounding GetFlatBufferOutputShapeRounding(armnn::OutputShapeRounding outputShapeRounding)
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A Convolution2dDescriptor for the Convolution2dLayer.
float m_Alpha
Alpha value for the normalization equation.
uint32_t m_PadLeft
Padding left value in the width dimension.
bool m_KeepDims
if true then output shape has no change.
float m_HiddenStateScale
Hidden State quantization scale.
bool m_BiasEnabled
Enable/disable bias.
bool m_TransposeX
Transpose the slices of each input tensor Transpose and Adjoint can not both be set to true for the s...
Optional< unsigned int > GetQuantizationDim() const
float m_OutputIntermediateScale
Output intermediate quantization scale.
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0. ...
float m_Beta
Exponentiation value.
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
bool m_AdjointX
Adjoint the slices of each input tensor Transpose and Adjoint can not both be set to true for the sam...
serializer::ActivationFunction GetFlatBufferActivationFunction(armnn::ActivationFunction function)
Main network class which provides the interface for building up a neural network. ...
uint32_t m_PadRight
Padding right value in the width dimension.
armnnSerializer::NormalizationAlgorithmMethod GetFlatBufferNormalizationAlgorithmMethod(armnn::NormalizationAlgorithmMethod normalizationAlgorithmMethod)
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
MemoryType GetMemoryArea() const
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
uint32_t GetNumViews() const
Get the number of views.
ReduceOperation m_ReduceOperation
Specifies the reduction operation to execute.
bool m_TimeMajor
Enable/disable time major.
Copyright (c) 2021 ARM Limited and Contributors.
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
void IgnoreUnused(Ts &&...)
uint32_t m_PadBottom
Padding bottom value in the height dimension.
int32_t m_BeginMask
Begin mask value.
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_DilationY
Dilation along y axis.
int32_t m_EndMask
End mask value.
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
uint32_t m_PoolHeight
Pooling height value.
std::vector< float > GetQuantizationScales() const
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_DilationY
Dilation factor value for height dimension.
armnnSerializer::ConstTensorData GetFlatBufferConstTensorData(armnn::DataType dataType)
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
LogicalBinaryOperation m_Operation
Specifies the logical operation to execute.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination, when source and target potentially have different memory layouts e.g.
armnnSerializer::ReduceOperation GetFlatBufferReduceOperation(armnn::ReduceOperation reduceOperation)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
armnnSerializer::DataType GetFlatBufferDataType(armnn::DataType dataType)
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_NumOutputs
Number of output tensors.
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
A ResizeDescriptor for the ResizeLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
Base class for all descriptors.
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
A StackDescriptor for the StackLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
serializer::ArgMinMaxFunction GetFlatBufferArgMinMaxFunction(armnn::ArgMinMaxFunction function)
TensorShape m_TargetShape
Target shape value.
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_MaxDetections
Maximum numbers of detections.
A PadDescriptor for the PadLayer.
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.
DataLayout m_DataLayoutX
Data layout of each input tensor, such as NHWC/NDHWC (leave as default for arbitrary layout) ...
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_PadBack
Padding back value in the depth dimension.
armnnSerializer::NormalizationAlgorithmChannel GetFlatBufferNormalizationAlgorithmChannel(armnn::NormalizationAlgorithmChannel normalizationAlgorithmChannel)
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
bool m_LayerNormEnabled
Enable/disable layer normalization.
float m_NmsIouThreshold
Intersection over union threshold.
armnnSerializer::LogicalBinaryOperation GetFlatBufferLogicalBinaryOperation(armnn::LogicalBinaryOperation logicalBinaryOperation)
An LstmDescriptor for the LstmLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
int32_t m_NewAxisMask
New axis mask value.
bool m_KeepDims
Enable/disable keep dimensions. If true, then the reduced dimensions that are of length 1 are kept...
std::vector< unsigned int > m_BlockShape
Block shape values.
float m_Eps
Epsilon, small scalar value added to variance to avoid dividing by zero. Defaults to 1e-12f...
An output connection slot for a layer.
A L2NormalizationDescriptor for the L2NormalizationLayer.
int32_t GetQuantizationOffset() const
An ArgMinMaxDescriptor for ArgMinMaxLayer.
armnnSerializer::PaddingMode GetFlatBufferPaddingMode(armnn::PaddingMode paddingMode)
float GetQuantizationScale() const
DataType GetDataType() const
An OriginsDescriptor for the ConcatLayer.
A ReduceDescriptor for the REDUCE operators.
float m_ProjectionClip
Clipping threshold value for the projection.
A FullyConnectedDescriptor for the FullyConnectedLayer.
int32_t m_EllipsisMask
Ellipsis mask value.
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
bool m_BiasEnabled
Enable/disable bias.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
float m_InputIntermediateScale
Input intermediate quantization scale.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
uint32_t m_TargetWidth
Target width value.
A GatherDescriptor for the GatherLayer.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_PeepholeEnabled
Enable/disable peephole.
uint32_t m_NumClasses
Number of classes.
bool m_HalfPixelCenters
Half Pixel Centers.
void Serialize(const armnn::INetwork &inNetwork)
Serializes the network to ArmNN SerializedGraph.
uint32_t m_PadTop
Padding top value in the height dimension.
A StandInDescriptor for the StandIn layer.
A QLstmDescriptor for the QLstmLayer.
virtual unsigned int CalculateIndexOnOwner() const =0
bool m_UseRegularNms
Use Regular NMS.
uint32_t m_PadFront
Padding front value in the depth dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< unsigned int > m_BlockShape
Block shape value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
An ActivationDescriptor for the ActivationLayer.
const TensorInfo & GetInfo() const
min(a, max(b, input)) ReLu1 & ReLu6.
uint32_t m_NumInputs
Number of input tensors.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_TargetHeight
Target height value.
uint32_t m_ActivationFunc
The activation function to use.
A SliceDescriptor for the SliceLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
A Convolution3dDescriptor for the Convolution3dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
float m_ClippingThresCell
Clipping threshold value for the cell state.
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
uint32_t m_NumGroups
Number of groups for the channel shuffle operation.
A BatchMatMulDescriptor for the BatchMatMul operator.
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
PaddingMode m_PaddingMode
Specifies the Padding mode (Constant, Reflect or Symmetric)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_Beta
Beta, the offset scalar value applied for the normalized tensor. Defaults to 1.0. ...
armnnSerializer::DataLayout GetFlatBufferDataLayout(armnn::DataLayout dataLayout)
A Pooling3dDescriptor for the Pooling3dLayer.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
float m_ScaleH
Center size encoding scale height.
ComparisonOperation m_Operation
Specifies the comparison operation to execute.
std::vector< int > m_End
End values for the input that will be sliced.
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
DataLayout m_DataLayout
The data layout to be used (NDHWC, NCDHW).
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
float m_CellClip
Clipping threshold value for the cell state.
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH, Elu).
uint32_t m_DilationX
Dilation along x axis.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
arm::pipe::ProfilingGuid LayerGuid
Define LayerGuid type.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
std::unique_ptr< ISerializer, void(*)(ISerializer *serializer)> ISerializerPtr
uint32_t m_PadLeft
Padding left value in the width dimension.
armnnSerializer::ComparisonOperation GetFlatBufferComparisonOperation(armnn::ComparisonOperation comparisonOperation)
bool m_AlignCorners
Aligned corners.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
int32_t m_Axis
The axis in params to gather indices from.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
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_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
std::vector< std::pair< unsigned int, unsigned int > > m_Crops
The values to crop from the input dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
uint32_t m_PadTop
Padding top value in the height dimension.
bool m_ProjectionEnabled
Enable/disable the projection layer.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
armnnSerializer::ResizeMethod GetFlatBufferResizeMethod(armnn::ResizeMethod method)
uint32_t m_NumInputs
Number of input tensors.
uint32_t GetNumDimensions() const
Get the number of dimensions.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A MeanDescriptor for the MeanLayer.
armnnSerializer::PaddingMethod GetFlatBufferPaddingMethod(armnn::PaddingMethod paddingMethod)
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
uint32_t m_PadRight
Padding right value in the width dimension.
A TransposeDescriptor for the TransposeLayer.
A StridedSliceDescriptor for the StridedSliceLayer.
virtual const TensorInfo & GetTensorInfo() const =0
uint32_t m_Axis
Axis to apply channel shuffle operation on.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
int m_Axis
Axis to reduce across the input tensor.
virtual const char * GetName() const =0
Returns the name of the layer.
float m_ScaleY
Center size encoding scale y.
uint32_t GetNumViews() const
Get the number of views.
float m_NmsScoreThreshold
NMS score threshold.
virtual LayerGuid GetOwningLayerGuid() const =0
A Pooling2dDescriptor for the Pooling2dLayer.
A NormalizationDescriptor for the NormalizationLayer.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
unsigned int GetConcatAxis() const
Get the concatenation axis value.
A ChannelShuffleDescriptor for the ChannelShuffle operator.
float m_CellIntermediateScale
Cell intermediate quantization scale.
uint32_t m_DilationZ
Dilation along z axis.
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
A SoftmaxDescriptor for the SoftmaxLayer.
float m_Beta
Beta value for the normalization equation.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
const OriginsDescriptor & GetOrigins() const
Get the View Origins.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination, when source and target potentially have different memory layouts e.g.
uint32_t m_NormSize
Depth radius value.
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
armnnSerializer::PoolingAlgorithm GetFlatBufferPoolingAlgorithm(armnn::PoolingAlgorithm poolingAlgorithm)
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
uint32_t m_DilationY
Dilation along y axis.
A FillDescriptor for the FillLayer.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
uint32_t m_PadLeft
Padding left value in the width dimension.
unsigned int GetNumBytes() const
A PermuteDescriptor for the PermuteLayer.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
uint32_t m_PadRight
Padding right value in the width dimension.
int32_t m_HiddenStateZeroPoint
Hidden State zero point.
bool m_ConstantWeights
Enable/disable constant weights and biases.