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);
229 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchToSpaceNd);
231 std::vector<unsigned int> crops;
232 crops.reserve(descriptor.
m_Crops.size() * 2);
233 for (
auto& crop : descriptor.
m_Crops)
235 crops.push_back(crop.first);
236 crops.push_back(crop.second);
239 auto flatBufferDescriptor =
240 CreateBatchToSpaceNdDescriptor(m_flatBufferBuilder,
241 m_flatBufferBuilder.CreateVector(descriptor.
m_BlockShape),
242 m_flatBufferBuilder.CreateVector(crops),
245 auto flatBufferLayer = serializer::CreateBatchToSpaceNdLayer(m_flatBufferBuilder,
247 flatBufferDescriptor);
249 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_BatchToSpaceNdLayer);
252 void SerializerStrategy::SerializeBatchNormalizationLayer(
255 const std::vector<armnn::ConstTensor>& constants,
265 auto fbBatchNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchNormalization);
266 auto fbBatchNormalizationDescriptor = serializer::CreateBatchNormalizationDescriptor(
268 batchNormDescriptor.
m_Eps,
271 auto fbMeanConstTensorInfo = CreateConstTensorInfo(mean);
272 auto fbVarianceConstTensorInfo = CreateConstTensorInfo(variance);
273 auto fbBetaConstTensorInfo = CreateConstTensorInfo(beta);
274 auto fbGammaConstTensorInfo = CreateConstTensorInfo(gamma);
275 auto fbBatchNormalizationLayer = serializer::CreateBatchNormalizationLayer(m_flatBufferBuilder,
276 fbBatchNormalizationBaseLayer,
277 fbBatchNormalizationDescriptor,
278 fbMeanConstTensorInfo,
279 fbVarianceConstTensorInfo,
280 fbBetaConstTensorInfo,
281 fbGammaConstTensorInfo);
283 CreateAnyLayer(fbBatchNormalizationLayer.o, serializer::Layer::Layer_BatchNormalizationLayer);
291 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Cast);
292 auto fbCastLayer = serializer::CreateCastLayer(m_flatBufferBuilder, fbBaseLayer);
293 CreateAnyLayer(fbCastLayer.o, serializer::Layer::Layer_CastLayer);
301 auto fbDescriptor = CreateChannelShuffleDescriptor(m_flatBufferBuilder,
304 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ChannelShuffle);
305 auto fbChannelShuffleLayer = serializer::CreateChannelShuffleLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
306 CreateAnyLayer(fbChannelShuffleLayer.o, serializer::Layer::Layer_ChannelShuffleLayer);
315 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Comparison);
316 auto fbDescriptor = serializer::CreateComparisonDescriptor(
320 auto fbLayer = serializer::CreateComparisonLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
321 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ComparisonLayer);
326 const std::vector<armnn::ConstTensor>& constants,
334 auto flatBufferConstantBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Constant);
336 auto flatBufferConstTensorInfo = CreateConstTensorInfo(input);
339 auto flatBufferLayer = CreateConstantLayer(m_flatBufferBuilder,
340 flatBufferConstantBaseLayer,
341 flatBufferConstTensorInfo);
344 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConstantLayer);
355 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
357 auto flatBufferDescriptor = CreateConvolution2dDescriptor(m_flatBufferBuilder,
370 auto flatBufferLayer = CreateConvolution2dLayer(m_flatBufferBuilder,
372 flatBufferDescriptor);
375 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution2dLayer);
386 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution3d);
388 auto flatBufferDescriptor = CreateConvolution3dDescriptor(m_flatBufferBuilder,
405 auto flatBufferLayer = CreateConvolution3dLayer(m_flatBufferBuilder,
407 flatBufferDescriptor);
410 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution3dLayer);
419 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthToSpace);
420 auto fbDescriptor = CreateDepthToSpaceDescriptor(m_flatBufferBuilder,
424 auto fbLayer = serializer::CreateDepthToSpaceLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
426 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_DepthToSpaceLayer);
435 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthwiseConvolution2d);
436 auto fbDescriptor = CreateDepthwiseConvolution2dDescriptor(m_flatBufferBuilder,
448 auto flatBufferLayer = CreateDepthwiseConvolution2dLayer(m_flatBufferBuilder,
452 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DepthwiseConvolution2dLayer);
460 auto fbDequantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Dequantize);
461 auto fbDequantizeLayer = serializer::CreateDequantizeLayer(m_flatBufferBuilder, fbDequantizeBaseLayer);
463 CreateAnyLayer(fbDequantizeLayer.o, serializer::Layer::Layer_DequantizeLayer);
468 const std::vector<armnn::ConstTensor>& constants,
475 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DetectionPostProcess);
476 auto fbDescriptor = CreateDetectionPostProcessDescriptor(m_flatBufferBuilder,
489 flatbuffers::Offset<serializer::ConstTensor> fbAnchorsConstTensorInfo = CreateConstTensorInfo(anchors);
491 auto flatBufferLayer = CreateDetectionPostProcessLayer(m_flatBufferBuilder,
494 fbAnchorsConstTensorInfo);
496 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DetectionPostProcessLayer);
503 auto fbDivisionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Division);
504 auto fbDivisionLayer = serializer::CreateDivisionLayer(m_flatBufferBuilder, fbDivisionBaseLayer);
506 CreateAnyLayer(fbDivisionLayer.o, serializer::Layer::Layer_DivisionLayer);
515 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ElementwiseUnary);
516 auto fbDescriptor = serializer::CreateElementwiseUnaryDescriptor(
520 auto fbLayer = serializer::CreateElementwiseUnaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
521 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseUnaryLayer);
530 auto fbFillBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Fill);
532 auto fbDescriptor = serializer::CreateFillDescriptor(m_flatBufferBuilder, fillDescriptor.
m_Value);
534 auto fbFillLayer = serializer::CreateFillLayer(m_flatBufferBuilder, fbFillBaseLayer, fbDescriptor);
536 CreateAnyLayer(fbFillLayer.o, serializer::Layer::Layer_FillLayer);
543 auto flatBufferFloorBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Floor);
544 auto flatBufferFloorLayer = serializer::CreateFloorLayer(m_flatBufferBuilder, flatBufferFloorBaseLayer);
546 CreateAnyLayer(flatBufferFloorLayer.o, serializer::Layer::Layer_FloorLayer);
555 auto fbGatherDescriptor = CreateGatherDescriptor(m_flatBufferBuilder,
557 auto fbGatherBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Gather);
558 auto flatBufferLayer = serializer::CreateGatherLayer(m_flatBufferBuilder, fbGatherBaseLayer, fbGatherDescriptor);
560 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherLayer);
568 auto fbGatherNdBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_GatherNd);
569 auto flatBufferLayer = serializer::CreateGatherNdLayer(m_flatBufferBuilder, fbGatherNdBaseLayer);
571 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherNdLayer);
574 void SerializerStrategy::SerializeInstanceNormalizationLayer(
581 auto fbDescriptor = serializer::CreateInstanceNormalizationDescriptor(
583 instanceNormalizationDescriptor.
m_Gamma,
584 instanceNormalizationDescriptor.
m_Beta,
585 instanceNormalizationDescriptor.
m_Eps,
588 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_InstanceNormalization);
589 auto fbLayer = serializer::CreateInstanceNormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
591 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_InstanceNormalizationLayer);
601 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_L2Normalization);
604 auto fbDescriptor = serializer::CreateL2NormalizationDescriptor(
607 l2NormalizationDescriptor.
m_Eps);
610 auto fbLayer = serializer::CreateL2NormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
612 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_L2NormalizationLayer);
621 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogicalBinary);
622 auto fbDescriptor = serializer::CreateLogicalBinaryDescriptor(
626 auto fbLayer = serializer::CreateLogicalBinaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
627 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_LogicalBinaryLayer);
637 auto flatBufferLogSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogSoftmax);
640 auto flatBufferLogSoftmaxDesc =
641 serializer::CreateLogSoftmaxDescriptor(m_flatBufferBuilder,
642 logSoftmaxDescriptor.
m_Beta,
643 logSoftmaxDescriptor.
m_Axis);
646 auto flatBufferLogSoftmaxLayer =
647 serializer::CreateLogSoftmaxLayer(m_flatBufferBuilder,
648 flatBufferLogSoftmaxBaseLayer,
649 flatBufferLogSoftmaxDesc);
651 CreateAnyLayer(flatBufferLogSoftmaxLayer.o, serializer::Layer::Layer_LogSoftmaxLayer);
656 const std::vector<armnn::ConstTensor>& constants,
661 auto fbLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Lstm);
663 auto fbLstmDescriptor = serializer::CreateLstmDescriptor(
677 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
678 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
679 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
680 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
681 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
682 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
683 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
684 auto cellBias = CreateConstTensorInfo(constants[i++]);
685 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
690 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
691 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
692 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
693 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
694 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
695 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
696 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
697 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
698 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
699 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
700 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
701 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
705 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
706 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
707 inputGateBias = CreateConstTensorInfo(constants[i++]);
714 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
716 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
717 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
722 projectionWeights = CreateConstTensorInfo(constants[i++]);
723 projectionBias = CreateConstTensorInfo(constants[i++]);
730 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
732 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
733 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
734 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
737 auto fbLstmParams = serializer::CreateLstmInputParams(
739 inputToForgetWeights,
741 inputToOutputWeights,
742 recurrentToForgetWeights,
743 recurrentToCellWeights,
744 recurrentToOutputWeights,
749 recurrentToInputWeights,
756 inputLayerNormWeights,
757 forgetLayerNormWeights,
758 cellLayerNormWeights,
759 outputLayerNormWeights);
761 auto fbLstmLayer = serializer::CreateLstmLayer(
767 CreateAnyLayer(fbLstmLayer.o, serializer::Layer::Layer_LstmLayer);
774 auto fbMaximumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Maximum);
775 auto fbMaximumLayer = serializer::CreateMaximumLayer(m_flatBufferBuilder, fbMaximumBaseLayer);
777 CreateAnyLayer(fbMaximumLayer.o, serializer::Layer::Layer_MaximumLayer);
786 auto fbMeanBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Mean);
787 auto fbMeanDescriptor = serializer::CreateMeanDescriptor(m_flatBufferBuilder,
788 m_flatBufferBuilder.CreateVector(descriptor.
m_Axis),
791 auto fbMeanLayer = serializer::CreateMeanLayer(m_flatBufferBuilder,
795 CreateAnyLayer(fbMeanLayer.o, serializer::Layer::Layer_MeanLayer);
802 auto fbMinimumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Minimum);
803 auto fbMinimumLayer = serializer::CreateMinimumLayer(m_flatBufferBuilder, fbMinimumBaseLayer);
805 CreateAnyLayer(fbMinimumLayer.o, serializer::Layer::Layer_MinimumLayer);
812 auto fbMergeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Merge);
813 auto fbMergeLayer = serializer::CreateMergeLayer(m_flatBufferBuilder, fbMergeBaseLayer);
815 CreateAnyLayer(fbMergeLayer.o, serializer::Layer::Layer_MergeLayer);
824 auto flatBufferConcatBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Concat);
826 std::vector<flatbuffers::Offset<UintVector>> views;
827 for (
unsigned int v = 0; v < concatDescriptor.
GetNumViews(); ++v)
830 std::vector<uint32_t> origins;
833 origins.push_back(origin[d]);
835 auto view = m_flatBufferBuilder.CreateVector(origins);
836 auto uintVector = CreateUintVector(m_flatBufferBuilder, view);
837 views.push_back(uintVector);
840 auto flatBufferConcatDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
844 m_flatBufferBuilder.CreateVector(views));
846 auto flatBufferLayer = CreateConcatLayer(m_flatBufferBuilder,
847 flatBufferConcatBaseLayer,
848 flatBufferConcatDescriptor);
850 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConcatLayer);
857 auto fbMultiplicationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Multiplication);
858 auto fbMultiplicationLayer = serializer::CreateMultiplicationLayer(m_flatBufferBuilder,
859 fbMultiplicationBaseLayer);
861 CreateAnyLayer(fbMultiplicationLayer.o, serializer::Layer::Layer_MultiplicationLayer);
870 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pad);
872 std::vector<unsigned int> padList;
875 padList.push_back(p.first);
876 padList.push_back(p.second);
879 auto flatBufferPadDesc = serializer::CreatePadDescriptor(m_flatBufferBuilder,
880 m_flatBufferBuilder.CreateVector(padList),
884 auto flatBufferPadLayer = serializer::CreatePadLayer(m_flatBufferBuilder,
888 CreateAnyLayer(flatBufferPadLayer.o, serializer::Layer::Layer_PadLayer);
898 auto flatBufferPermuteBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Permute);
900 std::vector<unsigned int> dimMappings;
906 auto flatBufferPermuteDesc = serializer::CreatePermuteDescriptor(m_flatBufferBuilder,
907 m_flatBufferBuilder.CreateVector(dimMappings));
910 auto flatBufferPermuteLayer = serializer::CreatePermuteLayer(m_flatBufferBuilder,
911 flatBufferPermuteBaseLayer,
912 flatBufferPermuteDesc);
915 CreateAnyLayer(flatBufferPermuteLayer.o, serializer::Layer::Layer_PermuteLayer);
923 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Rank);
924 auto flatBufferRankLayer = serializer::CreateRankLayer(m_flatBufferBuilder, flatBufferBaseLayer);
926 CreateAnyLayer(flatBufferRankLayer.o, serializer::Layer::Layer_RankLayer);
933 auto fbReduceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reduce);
934 auto fbDescriptor = CreateReduceDescriptor(m_flatBufferBuilder,
936 m_flatBufferBuilder.CreateVector(reduceDescriptor.
m_vAxis),
938 auto fbReduceLayer = serializer::CreateReduceLayer(m_flatBufferBuilder,
942 CreateAnyLayer(fbReduceLayer.o, serializer::Layer::Layer_ReduceLayer);
953 auto flatBufferReshapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reshape);
955 std::vector<unsigned int> targetShape;
961 auto flatBufferReshapeDesc = serializer::CreateReshapeDescriptor(m_flatBufferBuilder,
962 m_flatBufferBuilder.CreateVector(targetShape));
965 auto flatBufferReshapeLayer = serializer::CreateReshapeLayer(m_flatBufferBuilder, flatBufferReshapeBaseLayer,
966 flatBufferReshapeDesc);
969 CreateAnyLayer(flatBufferReshapeLayer.o, serializer::Layer::Layer_ReshapeLayer);
978 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Resize);
980 auto flatBufferDescriptor =
981 CreateResizeDescriptor(m_flatBufferBuilder,
989 auto flatBufferLayer = serializer::CreateResizeLayer(m_flatBufferBuilder,
991 flatBufferDescriptor);
993 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeLayer);
1002 auto fbSliceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Slice);
1003 auto fbSliceDescriptor = CreateSliceDescriptor(m_flatBufferBuilder,
1004 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Begin),
1005 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Size));
1007 auto fbSliceLayer = serializer::CreateSliceLayer(m_flatBufferBuilder, fbSliceBaseLayer, fbSliceDescriptor);
1009 CreateAnyLayer(fbSliceLayer.o, serializer::Layer::Layer_SliceLayer);
1020 auto flatBufferSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Softmax);
1023 auto flatBufferSoftmaxDesc =
1024 serializer::CreateSoftmaxDescriptor(m_flatBufferBuilder,
1025 softmaxDescriptor.
m_Beta,
1026 softmaxDescriptor.
m_Axis);
1029 auto flatBufferSoftmaxLayer =
1030 serializer::CreateSoftmaxLayer(m_flatBufferBuilder,
1031 flatBufferSoftmaxBaseLayer,
1032 flatBufferSoftmaxDesc);
1034 CreateAnyLayer(flatBufferSoftmaxLayer.o, serializer::Layer::Layer_SoftmaxLayer);
1043 auto fbPooling2dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling2d);
1044 auto fbPooling2dDescriptor = serializer::CreatePooling2dDescriptor(
1045 m_flatBufferBuilder,
1059 auto fbPooling2dLayer = serializer::CreatePooling2dLayer(m_flatBufferBuilder,
1060 fbPooling2dBaseLayer,
1061 fbPooling2dDescriptor);
1063 CreateAnyLayer(fbPooling2dLayer.o, serializer::Layer::Layer_Pooling2dLayer);
1072 auto fbPooling3dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling3d);
1073 auto fbPooling3dDescriptor = serializer::CreatePooling3dDescriptor(
1074 m_flatBufferBuilder,
1092 auto fbPooling3dLayer = serializer::CreatePooling3dLayer(m_flatBufferBuilder,
1093 fbPooling3dBaseLayer,
1094 fbPooling3dDescriptor);
1096 CreateAnyLayer(fbPooling3dLayer.o, serializer::Layer::Layer_Pooling3dLayer);
1105 auto flatBufferPreluBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Prelu);
1108 auto flatBufferPreluLayer = serializer::CreatePreluLayer(m_flatBufferBuilder, flatBufferPreluBaseLayer);
1111 CreateAnyLayer(flatBufferPreluLayer.o, serializer::Layer::Layer_PreluLayer);
1118 auto fbQuantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Quantize);
1119 auto fbQuantizeLayer = serializer::CreateQuantizeLayer(m_flatBufferBuilder,
1120 fbQuantizeBaseLayer);
1121 CreateAnyLayer(fbQuantizeLayer.o, serializer::Layer::Layer_QuantizeLayer);
1130 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_FullyConnected);
1133 auto flatBufferDescriptor =
1134 serializer::CreateFullyConnectedDescriptor(m_flatBufferBuilder,
1140 auto flatBufferLayer = serializer::CreateFullyConnectedLayer(m_flatBufferBuilder,
1141 flatBufferBaseLayer,
1142 flatBufferDescriptor);
1145 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_FullyConnectedLayer);
1156 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToBatchNd);
1158 std::vector<unsigned int> padList;
1159 padList.reserve(spaceToBatchNdDescriptor.
m_PadList.size()*2);
1160 for (
auto& pad : spaceToBatchNdDescriptor.
m_PadList)
1162 padList.push_back(pad.first);
1163 padList.push_back(pad.second);
1166 auto flatBufferDescriptor =
1167 CreateSpaceToBatchNdDescriptor(m_flatBufferBuilder,
1168 m_flatBufferBuilder.CreateVector(spaceToBatchNdDescriptor.
m_BlockShape),
1169 m_flatBufferBuilder.CreateVector(padList),
1172 auto flatBufferLayer = serializer::CreateSpaceToBatchNdLayer(m_flatBufferBuilder,
1173 flatBufferBaseLayer,
1174 flatBufferDescriptor);
1176 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToBatchNdLayer);
1186 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToDepth);
1187 auto flatBufferDescriptor =
1188 CreateSpaceToDepthDescriptor(m_flatBufferBuilder,
1192 auto flatBufferLayer = serializer::CreateSpaceToDepthLayer(m_flatBufferBuilder,
1193 flatBufferBaseLayer,
1194 flatBufferDescriptor);
1196 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToDepthLayer);
1207 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewOrigins;
1208 flatBufferViewOrigins.reserve(viewsDescriptor.
GetNumViews());
1210 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1212 std::vector<uint32_t> viewOrigin;
1216 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1218 viewOrigin.push_back(viewsDescriptor.
GetViewOrigin(vIdx)[dIdx]);
1221 flatBufferViewOrigins.push_back(CreateUintVector(m_flatBufferBuilder,
1222 m_flatBufferBuilder.CreateVector(viewOrigin)));
1226 auto flatBufferOriginDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
1230 m_flatBufferBuilder.CreateVector(flatBufferViewOrigins));
1233 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewSizes;
1234 flatBufferViewSizes.reserve(viewsDescriptor.
GetNumViews());
1236 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1238 std::vector<uint32_t> viewSize;
1242 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1244 viewSize.push_back(viewsDescriptor.
GetViewSizes(vIdx)[dIdx]);
1247 flatBufferViewSizes.push_back(CreateUintVector(m_flatBufferBuilder,
1248 m_flatBufferBuilder.CreateVector(viewSize)));
1252 auto flatBufferViewsDescriptor = CreateViewsDescriptor(m_flatBufferBuilder,
1253 flatBufferOriginDescriptor,
1254 m_flatBufferBuilder.CreateVector(flatBufferViewSizes));
1257 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Splitter);
1259 auto flatBufferSplitterLayer = serializer::CreateSplitterLayer(m_flatBufferBuilder,
1260 flatBufferBaseLayer,
1261 flatBufferViewsDescriptor);
1263 CreateAnyLayer(flatBufferSplitterLayer.o, serializer::Layer::Layer_SplitterLayer);
1272 auto fbNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Normalization);
1274 auto fbNormalizationDescriptor = serializer::CreateNormalizationDescriptor(
1275 m_flatBufferBuilder,
1284 auto flatBufferLayer = serializer::CreateNormalizationLayer(m_flatBufferBuilder,
1285 fbNormalizationBaseLayer,
1286 fbNormalizationDescriptor);
1288 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_NormalizationLayer);
1296 auto shapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Shape);
1297 auto shapeLayer = serializer::CreateShapeLayer(m_flatBufferBuilder, shapeBaseLayer);
1299 CreateAnyLayer(shapeLayer.o, serializer::Layer::Layer_ShapeLayer);
1308 auto stackBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Stack);
1310 std::vector<unsigned int> inputShape;
1316 auto flatBufferStackDescriptor = CreateStackDescriptor(m_flatBufferBuilder,
1319 m_flatBufferBuilder.CreateVector(inputShape));
1321 auto stackLayer = serializer::CreateStackLayer(m_flatBufferBuilder, stackBaseLayer, flatBufferStackDescriptor);
1322 CreateAnyLayer(stackLayer.o, serializer::Layer::Layer_StackLayer);
1331 auto fbDescriptor = serializer::CreateStandInDescriptor(m_flatBufferBuilder,
1335 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StandIn);
1336 auto fbLayer = serializer::CreateStandInLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
1338 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_StandInLayer);
1347 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StridedSlice);
1349 auto flatBufferDescriptor =
1350 CreateStridedSliceDescriptor(m_flatBufferBuilder,
1351 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Begin),
1352 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_End),
1353 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Stride),
1361 auto flatBufferLayer = serializer::CreateStridedSliceLayer(m_flatBufferBuilder,
1362 flatBufferBaseLayer,
1363 flatBufferDescriptor);
1365 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_StridedSliceLayer);
1372 auto fbSubtractionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Subtraction);
1373 auto fbSubtractionLayer = serializer::CreateSubtractionLayer(m_flatBufferBuilder, fbSubtractionBaseLayer);
1375 CreateAnyLayer(fbSubtractionLayer.o, serializer::Layer::Layer_SubtractionLayer);
1382 auto fbSwitchBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Switch);
1383 auto fbSwitchLayer = serializer::CreateSwitchLayer(m_flatBufferBuilder, fbSwitchBaseLayer);
1385 CreateAnyLayer(fbSwitchLayer.o, serializer::Layer::Layer_SwitchLayer);
1388 void SerializerStrategy::SerializeTransposeConvolution2dLayer(
1391 const std::vector<armnn::ConstTensor>& constants,
1398 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
1399 auto fbDescriptor = CreateTransposeConvolution2dDescriptor(m_flatBufferBuilder,
1410 auto fbWeightsConstTensorInfo = CreateConstTensorInfo(weights);
1411 flatbuffers::Offset<serializer::ConstTensor> fbBiasesConstTensorInfo;
1412 if (constants.size() > 1)
1415 fbBiasesConstTensorInfo = CreateConstTensorInfo(biases);
1418 auto fbLayer = CreateTransposeConvolution2dLayer(m_flatBufferBuilder,
1421 fbWeightsConstTensorInfo,
1422 fbBiasesConstTensorInfo);
1424 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_TransposeConvolution2dLayer);
1434 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Transpose);
1436 std::vector<unsigned int> dimMappings;
1442 auto flatBufferDesc = serializer::CreateTransposeDescriptor(m_flatBufferBuilder,
1443 m_flatBufferBuilder.CreateVector(dimMappings));
1446 auto flatBufferLayer = serializer::CreateTransposeLayer(m_flatBufferBuilder,
1447 flatBufferBaseLayer,
1451 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_TransposeLayer);
1456 const std::vector<armnn::ConstTensor>& constants,
1461 auto fbQLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QLstm);
1463 auto fbQLstmDescriptor = serializer::CreateQLstmDescriptor(
1464 m_flatBufferBuilder,
1483 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1484 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1485 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1486 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1487 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1488 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1489 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1490 auto cellBias = CreateConstTensorInfo(constants[i++]);
1491 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1494 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1495 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1496 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1500 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1501 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1502 inputGateBias = CreateConstTensorInfo(constants[i++]);
1506 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1507 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1508 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1514 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1516 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1517 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1521 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1522 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1526 projectionWeights = CreateConstTensorInfo(constants[i++]);
1527 projectionBias = CreateConstTensorInfo(constants[i++]);
1531 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1532 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1533 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1534 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1540 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1542 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1543 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1544 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1547 auto fbQLstmParams = serializer::CreateQLstmInputParams(
1548 m_flatBufferBuilder,
1549 inputToForgetWeights,
1551 inputToOutputWeights,
1552 recurrentToForgetWeights,
1553 recurrentToCellWeights,
1554 recurrentToOutputWeights,
1558 inputToInputWeights,
1559 recurrentToInputWeights,
1564 cellToForgetWeights,
1565 cellToOutputWeights,
1566 inputLayerNormWeights,
1567 forgetLayerNormWeights,
1568 cellLayerNormWeights,
1569 outputLayerNormWeights);
1571 auto fbQLstmLayer = serializer::CreateQLstmLayer(
1572 m_flatBufferBuilder,
1577 CreateAnyLayer(fbQLstmLayer.o, serializer::Layer::Layer_QLstmLayer);
1581 const std::vector<armnn::ConstTensor>& constants,
1586 auto fbQuantizedLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QuantizedLstm);
1592 auto inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1593 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1594 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1595 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1597 auto recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1598 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1599 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1600 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1602 auto inputGateBias = CreateConstTensorInfo(constants[i++]);
1603 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1604 auto cellBias = CreateConstTensorInfo(constants[i++]);
1605 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1607 auto fbQuantizedLstmParams = serializer::CreateQuantizedLstmInputParams(
1608 m_flatBufferBuilder,
1609 inputToInputWeights,
1610 inputToForgetWeights,
1612 inputToOutputWeights,
1613 recurrentToInputWeights,
1614 recurrentToForgetWeights,
1615 recurrentToCellWeights,
1616 recurrentToOutputWeights,
1622 auto fbQuantizedLstmLayer = serializer::CreateQuantizedLstmLayer(
1623 m_flatBufferBuilder,
1624 fbQuantizedLstmBaseLayer,
1625 fbQuantizedLstmParams);
1627 CreateAnyLayer(fbQuantizedLstmLayer.o, serializer::Layer::Layer_QuantizedLstmLayer);
1630 void SerializerStrategy::SerializeUnidirectionalSequenceLstmLayer(
1633 const std::vector<armnn::ConstTensor>& constants,
1638 auto fbUnidirectionalSequenceLstmBaseLayer =
1639 CreateLayerBase(layer, serializer::LayerType::LayerType_UnidirectionalSequenceLstm);
1641 auto fbUnidirectionalSequenceLstmDescriptor = serializer::CreateUnidirectionalSequenceLstmDescriptor(
1642 m_flatBufferBuilder,
1656 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1657 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1658 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1659 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1660 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1661 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1662 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1663 auto cellBias = CreateConstTensorInfo(constants[i++]);
1664 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1667 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1668 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1669 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1670 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1671 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1672 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1673 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1674 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1675 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1676 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1677 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1678 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1682 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1683 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1684 inputGateBias = CreateConstTensorInfo(constants[i++]);
1691 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1693 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1694 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1699 projectionWeights = CreateConstTensorInfo(constants[i++]);
1700 projectionBias = CreateConstTensorInfo(constants[i++]);
1707 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1709 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1710 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1711 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1714 auto fbUnidirectionalSequenceLstmParams = serializer::CreateLstmInputParams(
1715 m_flatBufferBuilder,
1716 inputToForgetWeights,
1718 inputToOutputWeights,
1719 recurrentToForgetWeights,
1720 recurrentToCellWeights,
1721 recurrentToOutputWeights,
1725 inputToInputWeights,
1726 recurrentToInputWeights,
1731 cellToForgetWeights,
1732 cellToOutputWeights,
1733 inputLayerNormWeights,
1734 forgetLayerNormWeights,
1735 cellLayerNormWeights,
1736 outputLayerNormWeights);
1738 auto fbUnidirectionalSequenceLstmLayer = serializer::CreateUnidirectionalSequenceLstmLayer(
1739 m_flatBufferBuilder,
1740 fbUnidirectionalSequenceLstmBaseLayer,
1741 fbUnidirectionalSequenceLstmDescriptor,
1742 fbUnidirectionalSequenceLstmParams);
1744 CreateAnyLayer(fbUnidirectionalSequenceLstmLayer.o, serializer::Layer::Layer_UnidirectionalSequenceLstmLayer);
1747 fb::Offset<serializer::LayerBase> SerializerStrategy::CreateLayerBase(
const IConnectableLayer* layer,
1751 uint32_t fbIndex = GetSerializedId(layer->
GetGuid());
1753 std::vector<fb::Offset<serializer::InputSlot>> inputSlots = CreateInputSlots(layer);
1754 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots = CreateOutputSlots(layer);
1756 return serializer::CreateLayerBase(m_flatBufferBuilder,
1758 m_flatBufferBuilder.CreateString(layer->
GetName()),
1760 m_flatBufferBuilder.CreateVector(inputSlots),
1761 m_flatBufferBuilder.CreateVector(outputSlots));
1764 void SerializerStrategy::CreateAnyLayer(
const flatbuffers::Offset<void>& layer,
const serializer::Layer serializerLayer)
1767 auto anyLayer = armnnSerializer::CreateAnyLayer(m_flatBufferBuilder, serializerLayer, layer);
1768 m_serializedLayers.push_back(anyLayer);
1771 template <
typename T>
1772 flatbuffers::Offset<flatbuffers::Vector<T>> SerializerStrategy::CreateDataVector(
const void* memory,
unsigned int size)
1774 const T* buffer =
reinterpret_cast<const T*
>(memory);
1775 std::vector<T> vector(buffer, buffer + (size /
sizeof(T)));
1776 auto fbVector = m_flatBufferBuilder.CreateVector(vector);
1780 flatbuffers::Offset<TensorInfo> SerializerStrategy::CreateTensorInfo(
const armnn::TensorInfo& tensorInfo)
1783 std::vector<unsigned int> shape;
1784 std::vector<bool> specificity;
1793 shape.push_back(tensorInfo.
GetShape()[dim]);
1804 auto flatBufferTensorInfo =
1805 serializer::CreateTensorInfo(m_flatBufferBuilder,
1806 m_flatBufferBuilder.CreateVector(shape),
1812 static_cast<unsigned int> 1814 m_flatBufferBuilder.CreateVector(specificity));
1815 return flatBufferTensorInfo;
1819 auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder,
1820 m_flatBufferBuilder.CreateVector(shape),
1826 static_cast<unsigned int> 1828 m_flatBufferBuilder.CreateVector(specificity));
1829 return flatBufferTensorInfo;
1832 flatbuffers::Offset<serializer::ConstTensor>
1837 flatbuffers::Offset<void> fbPayload;
1844 flatbuffers::Offset<serializer::LongData> flatBuffersData = serializer::CreateLongData(
1845 m_flatBufferBuilder,
1847 fbPayload = flatBuffersData.o;
1854 flatbuffers::Offset<serializer::IntData> flatBuffersData = serializer::CreateIntData(
1855 m_flatBufferBuilder,
1857 fbPayload = flatBuffersData.o;
1865 flatbuffers::Offset<serializer::ShortData> flatBuffersData = serializer::CreateShortData(
1866 m_flatBufferBuilder,
1868 fbPayload = flatBuffersData.o;
1878 flatbuffers::Offset<serializer::ByteData> flatBuffersData = serializer::CreateByteData(
1879 m_flatBufferBuilder,
1881 fbPayload = flatBuffersData.o;
1884 flatbuffers::Offset<serializer::ConstTensor> flatBufferConstTensor = serializer::CreateConstTensor(
1885 m_flatBufferBuilder,
1886 CreateTensorInfo(tensorInfo),
1889 return flatBufferConstTensor;
1892 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> SerializerStrategy::GetVersionTable()
1894 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> versionsTable =
1895 serializer::CreateFeatureCompatibilityVersions(
1896 m_flatBufferBuilder,
1901 return versionsTable;
1904 std::vector<fb::Offset<serializer::InputSlot>>
1907 std::vector<fb::Offset<serializer::InputSlot>> inputSlots;
1910 for (
unsigned int slotIndex = 0; slotIndex<layer->
GetNumInputSlots(); ++slotIndex)
1921 inputSlots.push_back(serializer::CreateInputSlot(m_flatBufferBuilder, slotIndex, &conn));
1926 std::vector<fb::Offset<serializer::OutputSlot>>
1929 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots;
1932 for (
unsigned int slotIndex = 0; slotIndex < layer->
GetNumOutputSlots(); ++slotIndex)
1938 outputSlots.push_back(serializer::CreateOutputSlot(m_flatBufferBuilder,
1940 CreateTensorInfo(tensorInfo)));
1947 const std::vector<armnn::ConstTensor>& constants,
1959 SerializeActivationLayer(layer, layerDescriptor, name);
1964 SerializeAdditionLayer(layer, name);
1971 SerializeArgMinMaxLayer(layer, layerDescriptor, name);
1978 SerializeBatchNormalizationLayer(layer,
1988 SerializeBatchToSpaceNdLayer(layer,
1995 SerializeCastLayer(layer, name);
2002 SerializeChannelShuffleLayer(layer,
2011 SerializeComparisonLayer(layer,
2020 SerializeConcatLayer(layer,
2027 SerializeConstantLayer(layer,
2036 SerializeConvolution2dLayer(layer,
2045 SerializeConvolution3dLayer(layer,
2054 SerializeDepthToSpaceLayer(layer,
2063 SerializeDepthwiseConvolution2dLayer(layer,
2070 SerializeDequantizeLayer(layer,
2078 SerializeDetectionPostProcessLayer(layer, layerDescriptor, constants, name);
2083 SerializeDivisionLayer(layer, name);
2090 SerializeElementwiseUnaryLayer(layer, layerDescriptor, name);
2097 SerializeFillLayer(layer, layerDescriptor, name);
2102 SerializeFloorLayer(layer, name);
2109 SerializeFullyConnectedLayer(layer, layerDescriptor, name);
2116 SerializeGatherLayer(layer, layerDescriptor, name);
2121 SerializeGatherNdLayer(layer, name);
2126 SerializeInputLayer(layer,
id, name);
2133 SerializeInstanceNormalizationLayer(layer, layerDescriptor, name);
2140 SerializeL2NormalizationLayer(layer, layerDescriptor, name);
2147 SerializeLogicalBinaryLayer(layer, layerDescriptor, name);
2154 SerializeLogSoftmaxLayer(layer, layerDescriptor, name);
2161 SerializeLstmLayer(layer, layerDescriptor, constants, name);
2168 SerializeQLstmLayer(layer, layerDescriptor, constants, name);
2173 SerializeMaximumLayer(layer, name);
2180 SerializeMeanLayer(layer, layerDescriptor, name);
2185 SerializeMergeLayer(layer, name);
2190 SerializeMinimumLayer(layer, name);
2195 SerializeMultiplicationLayer(layer, name);
2202 SerializeNormalizationLayer(layer, layerDescriptor, name);
2207 SerializeOutputLayer(layer,
id, name);
2214 SerializePadLayer(layer, layerDescriptor, name);
2221 SerializePermuteLayer(layer, layerDescriptor, name);
2228 SerializePooling2dLayer(layer, layerDescriptor, name);
2235 SerializePooling3dLayer(layer, layerDescriptor, name);
2240 SerializePreluLayer(layer, name);
2245 SerializeQuantizeLayer(layer, name);
2249 SerializeQuantizedLstmLayer(layer, constants, name);
2255 SerializeReshapeLayer(layer, layerDescriptor, name);
2260 SerializeRankLayer(layer, name);
2267 SerializeReduceLayer(layer, layerDescriptor, name);
2274 SerializeResizeLayer(layer, layerDescriptor, name);
2279 SerializeShapeLayer(layer, name);
2286 SerializeSliceLayer(layer, layerDescriptor, name);
2293 SerializeSoftmaxLayer(layer, layerDescriptor, name);
2300 SerializeSpaceToBatchNdLayer(layer, layerDescriptor, name);
2307 SerializeSpaceToDepthLayer(layer, layerDescriptor, name);
2314 SerializeSplitterLayer(layer, layerDescriptor, name);
2321 SerializeStackLayer(layer, layerDescriptor, name);
2328 SerializeStandInLayer(layer, layerDescriptor, name);
2335 SerializeStridedSliceLayer(layer, layerDescriptor, name);
2340 SerializeSubtractionLayer(layer, name);
2345 SerializeSwitchLayer(layer, name);
2352 SerializeTransposeLayer(layer, layerDescriptor, name);
2359 SerializeTransposeConvolution2dLayer(layer, layerDescriptor, constants, name);
2366 SerializeUnidirectionalSequenceLstmLayer(layer, layerDescriptor, constants, name);
2372 fmt::format(
"A layer of unknown type was given to the serializer. Layer name: {}; Layer Id: {}",
2379 void ISerializer::SerializerImpl::Serialize(
const INetwork& inNetwork)
2383 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2386 auto serializedGraph = serializer::CreateSerializedGraph(
2388 fbBuilder.CreateVector(m_SerializerStrategy.GetSerializedLayers()),
2389 fbBuilder.CreateVector(m_SerializerStrategy.GetInputIds()),
2390 fbBuilder.CreateVector(m_SerializerStrategy.GetOutputIds()),
2391 m_SerializerStrategy.GetVersionTable());
2394 fbBuilder.Finish(serializedGraph);
2398 bool ISerializer::SerializerImpl::SaveSerializedToStream(std::ostream& stream)
2400 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2403 stream.write(reinterpret_cast<const char*>(fbBuilder.GetBufferPointer()), bytesToWrite);
2404 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.
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).
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 ResizeBilinearDescriptor for the ResizeBilinearLayer.
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.
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.
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.