14 #include <fmt/format.h>
17 using namespace armnn;
18 namespace fb = flatbuffers;
24 ISerializer::ISerializer() : pSerializerImpl(new SerializerImpl())
28 ISerializer::~ISerializer() =
default;
47 pSerializerImpl->Serialize(inNetwork);
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_Gelu;
84 return serializer::ActivationFunction::ActivationFunction_Sigmoid;
93 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Max;
96 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Min;
105 return serializer::ScatterNdFunction::ScatterNdFunction_Update;
107 return serializer::ScatterNdFunction::ScatterNdFunction_Add;
109 return serializer::ScatterNdFunction::ScatterNdFunction_Sub;
111 return serializer::ScatterNdFunction::ScatterNdFunction_Max;
113 return serializer::ScatterNdFunction::ScatterNdFunction_Min;
115 return serializer::ScatterNdFunction::ScatterNdFunction_Update;
119 uint32_t SerializerStrategy::GetSerializedId(
LayerGuid guid)
121 if (m_guidMap.empty())
123 m_guidMap.insert(std::make_pair(guid, m_layerId));
125 else if (m_guidMap.find(guid) == m_guidMap.end())
128 m_guidMap.insert(std::make_pair(guid, m_layerId));
132 return m_guidMap[guid];
141 auto flatBufferInputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Input);
144 auto flatBufferInputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
145 flatBufferInputBaseLayer,
148 m_inputIds.push_back(
id);
151 auto flatBufferInputLayer = serializer::CreateInputLayer(m_flatBufferBuilder, flatBufferInputBindableBaseLayer);
154 CreateAnyLayer(flatBufferInputLayer.o, serializer::Layer::Layer_InputLayer);
164 auto flatBufferOutputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Output);
167 auto flatBufferOutputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
168 flatBufferOutputBaseLayer,
171 m_outputIds.push_back(
id);
174 auto flatBufferOutputLayer = serializer::CreateOutputLayer(m_flatBufferBuilder, flatBufferOutputBindableBaseLayer);
176 CreateAnyLayer(flatBufferOutputLayer.o, serializer::Layer::Layer_OutputLayer);
187 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Activation);
190 auto flatBufferDescriptor = CreateActivationDescriptor(m_flatBufferBuilder,
196 auto flatBufferAdditionLayer = CreateActivationLayer(m_flatBufferBuilder,
198 flatBufferDescriptor);
201 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_ActivationLayer);
210 auto flatBufferAdditionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Addition);
213 auto flatBufferAdditionLayer = serializer::CreateAdditionLayer(m_flatBufferBuilder, flatBufferAdditionBaseLayer);
216 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_AdditionLayer);
227 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ArgMinMax);
230 auto flatBufferDescriptor = CreateArgMinMaxDescriptor(m_flatBufferBuilder,
235 auto flatBufferLayer = CreateArgMinMaxLayer(m_flatBufferBuilder,
237 flatBufferDescriptor);
239 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ArgMinMaxLayer);
249 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchMatMul);
252 auto flatBufferDescriptor = CreateBatchMatMulDescriptor(m_flatBufferBuilder,
261 auto flatBufferBatchMatMulLayer = CreateBatchMatMulLayer(m_flatBufferBuilder,
263 flatBufferDescriptor);
266 CreateAnyLayer(flatBufferBatchMatMulLayer.o, serializer::Layer::Layer_BatchMatMulLayer);
277 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchToSpaceNd);
279 std::vector<unsigned int> crops;
280 crops.reserve(descriptor.
m_Crops.size() * 2);
281 for (
auto& crop : descriptor.
m_Crops)
283 crops.push_back(crop.first);
284 crops.push_back(crop.second);
287 auto flatBufferDescriptor =
288 CreateBatchToSpaceNdDescriptor(m_flatBufferBuilder,
289 m_flatBufferBuilder.CreateVector(descriptor.
m_BlockShape),
290 m_flatBufferBuilder.CreateVector(crops),
293 auto flatBufferLayer = serializer::CreateBatchToSpaceNdLayer(m_flatBufferBuilder,
295 flatBufferDescriptor);
297 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_BatchToSpaceNdLayer);
300 void SerializerStrategy::SerializeBatchNormalizationLayer(
303 const std::vector<armnn::ConstTensor>& constants,
313 auto fbBatchNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchNormalization);
314 auto fbBatchNormalizationDescriptor = serializer::CreateBatchNormalizationDescriptor(
316 batchNormDescriptor.
m_Eps,
319 auto fbMeanConstTensorInfo = CreateConstTensorInfo(mean);
320 auto fbVarianceConstTensorInfo = CreateConstTensorInfo(variance);
321 auto fbBetaConstTensorInfo = CreateConstTensorInfo(beta);
322 auto fbGammaConstTensorInfo = CreateConstTensorInfo(gamma);
323 auto fbBatchNormalizationLayer = serializer::CreateBatchNormalizationLayer(m_flatBufferBuilder,
324 fbBatchNormalizationBaseLayer,
325 fbBatchNormalizationDescriptor,
326 fbMeanConstTensorInfo,
327 fbVarianceConstTensorInfo,
328 fbBetaConstTensorInfo,
329 fbGammaConstTensorInfo);
331 CreateAnyLayer(fbBatchNormalizationLayer.o, serializer::Layer::Layer_BatchNormalizationLayer);
339 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Cast);
340 auto fbCastLayer = serializer::CreateCastLayer(m_flatBufferBuilder, fbBaseLayer);
341 CreateAnyLayer(fbCastLayer.o, serializer::Layer::Layer_CastLayer);
349 auto fbDescriptor = CreateChannelShuffleDescriptor(m_flatBufferBuilder,
352 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ChannelShuffle);
353 auto fbChannelShuffleLayer = serializer::CreateChannelShuffleLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
354 CreateAnyLayer(fbChannelShuffleLayer.o, serializer::Layer::Layer_ChannelShuffleLayer);
363 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Comparison);
364 auto fbDescriptor = serializer::CreateComparisonDescriptor(
368 auto fbLayer = serializer::CreateComparisonLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
369 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ComparisonLayer);
374 const std::vector<armnn::ConstTensor>& constants,
382 auto flatBufferConstantBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Constant);
384 auto flatBufferConstTensorInfo = CreateConstTensorInfo(input);
387 auto flatBufferLayer = CreateConstantLayer(m_flatBufferBuilder,
388 flatBufferConstantBaseLayer,
389 flatBufferConstTensorInfo);
392 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConstantLayer);
403 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
405 auto flatBufferDescriptor = CreateConvolution2dDescriptor(m_flatBufferBuilder,
418 auto flatBufferLayer = CreateConvolution2dLayer(m_flatBufferBuilder,
420 flatBufferDescriptor);
423 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution2dLayer);
434 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution3d);
436 auto flatBufferDescriptor = CreateConvolution3dDescriptor(m_flatBufferBuilder,
453 auto flatBufferLayer = CreateConvolution3dLayer(m_flatBufferBuilder,
455 flatBufferDescriptor);
458 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution3dLayer);
467 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthToSpace);
468 auto fbDescriptor = CreateDepthToSpaceDescriptor(m_flatBufferBuilder,
472 auto fbLayer = serializer::CreateDepthToSpaceLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
474 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_DepthToSpaceLayer);
483 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthwiseConvolution2d);
484 auto fbDescriptor = CreateDepthwiseConvolution2dDescriptor(m_flatBufferBuilder,
496 auto flatBufferLayer = CreateDepthwiseConvolution2dLayer(m_flatBufferBuilder,
500 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DepthwiseConvolution2dLayer);
508 auto fbDequantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Dequantize);
509 auto fbDequantizeLayer = serializer::CreateDequantizeLayer(m_flatBufferBuilder, fbDequantizeBaseLayer);
511 CreateAnyLayer(fbDequantizeLayer.o, serializer::Layer::Layer_DequantizeLayer);
516 const std::vector<armnn::ConstTensor>& constants,
523 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DetectionPostProcess);
524 auto fbDescriptor = CreateDetectionPostProcessDescriptor(m_flatBufferBuilder,
537 flatbuffers::Offset<serializer::ConstTensor> fbAnchorsConstTensorInfo = CreateConstTensorInfo(anchors);
539 auto flatBufferLayer = CreateDetectionPostProcessLayer(m_flatBufferBuilder,
542 fbAnchorsConstTensorInfo);
544 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DetectionPostProcessLayer);
551 auto fbDivisionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Division);
552 auto fbDivisionLayer = serializer::CreateDivisionLayer(m_flatBufferBuilder, fbDivisionBaseLayer);
554 CreateAnyLayer(fbDivisionLayer.o, serializer::Layer::Layer_DivisionLayer);
563 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ElementwiseBinary);
564 auto fbDescriptor = serializer::CreateElementwiseBinaryDescriptor(
568 auto fbLayer = serializer::CreateElementwiseBinaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
569 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseBinaryLayer);
578 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ElementwiseUnary);
579 auto fbDescriptor = serializer::CreateElementwiseUnaryDescriptor(
583 auto fbLayer = serializer::CreateElementwiseUnaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
584 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseUnaryLayer);
593 auto fbFillBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Fill);
595 auto fbDescriptor = serializer::CreateFillDescriptor(m_flatBufferBuilder, fillDescriptor.
m_Value);
597 auto fbFillLayer = serializer::CreateFillLayer(m_flatBufferBuilder, fbFillBaseLayer, fbDescriptor);
599 CreateAnyLayer(fbFillLayer.o, serializer::Layer::Layer_FillLayer);
606 auto flatBufferFloorBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Floor);
607 auto flatBufferFloorLayer = serializer::CreateFloorLayer(m_flatBufferBuilder, flatBufferFloorBaseLayer);
609 CreateAnyLayer(flatBufferFloorLayer.o, serializer::Layer::Layer_FloorLayer);
618 auto fbGatherDescriptor = CreateGatherDescriptor(m_flatBufferBuilder,
620 auto fbGatherBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Gather);
621 auto flatBufferLayer = serializer::CreateGatherLayer(m_flatBufferBuilder, fbGatherBaseLayer, fbGatherDescriptor);
623 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherLayer);
631 auto fbGatherNdBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_GatherNd);
632 auto flatBufferLayer = serializer::CreateGatherNdLayer(m_flatBufferBuilder, fbGatherNdBaseLayer);
634 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherNdLayer);
637 void SerializerStrategy::SerializeInstanceNormalizationLayer(
644 auto fbDescriptor = serializer::CreateInstanceNormalizationDescriptor(
646 instanceNormalizationDescriptor.
m_Gamma,
647 instanceNormalizationDescriptor.
m_Beta,
648 instanceNormalizationDescriptor.
m_Eps,
651 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_InstanceNormalization);
652 auto fbLayer = serializer::CreateInstanceNormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
654 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_InstanceNormalizationLayer);
664 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_L2Normalization);
667 auto fbDescriptor = serializer::CreateL2NormalizationDescriptor(
670 l2NormalizationDescriptor.
m_Eps);
673 auto fbLayer = serializer::CreateL2NormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
675 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_L2NormalizationLayer);
684 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogicalBinary);
685 auto fbDescriptor = serializer::CreateLogicalBinaryDescriptor(
689 auto fbLayer = serializer::CreateLogicalBinaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
690 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_LogicalBinaryLayer);
700 auto flatBufferLogSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogSoftmax);
703 auto flatBufferLogSoftmaxDesc =
704 serializer::CreateLogSoftmaxDescriptor(m_flatBufferBuilder,
705 logSoftmaxDescriptor.
m_Beta,
706 logSoftmaxDescriptor.
m_Axis);
709 auto flatBufferLogSoftmaxLayer =
710 serializer::CreateLogSoftmaxLayer(m_flatBufferBuilder,
711 flatBufferLogSoftmaxBaseLayer,
712 flatBufferLogSoftmaxDesc);
714 CreateAnyLayer(flatBufferLogSoftmaxLayer.o, serializer::Layer::Layer_LogSoftmaxLayer);
719 const std::vector<armnn::ConstTensor>& constants,
724 auto fbLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Lstm);
726 auto fbLstmDescriptor = serializer::CreateLstmDescriptor(
740 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
741 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
742 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
743 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
744 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
745 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
746 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
747 auto cellBias = CreateConstTensorInfo(constants[i++]);
748 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
753 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
754 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
755 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
756 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
757 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
758 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
759 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
760 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
761 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
762 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
763 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
764 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
768 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
769 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
770 inputGateBias = CreateConstTensorInfo(constants[i++]);
777 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
779 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
780 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
785 projectionWeights = CreateConstTensorInfo(constants[i++]);
786 projectionBias = CreateConstTensorInfo(constants[i++]);
793 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
795 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
796 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
797 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
800 auto fbLstmParams = serializer::CreateLstmInputParams(
802 inputToForgetWeights,
804 inputToOutputWeights,
805 recurrentToForgetWeights,
806 recurrentToCellWeights,
807 recurrentToOutputWeights,
812 recurrentToInputWeights,
819 inputLayerNormWeights,
820 forgetLayerNormWeights,
821 cellLayerNormWeights,
822 outputLayerNormWeights);
824 auto fbLstmLayer = serializer::CreateLstmLayer(
830 CreateAnyLayer(fbLstmLayer.o, serializer::Layer::Layer_LstmLayer);
837 auto fbMaximumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Maximum);
838 auto fbMaximumLayer = serializer::CreateMaximumLayer(m_flatBufferBuilder, fbMaximumBaseLayer);
840 CreateAnyLayer(fbMaximumLayer.o, serializer::Layer::Layer_MaximumLayer);
849 auto fbMeanBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Mean);
850 auto fbMeanDescriptor = serializer::CreateMeanDescriptor(m_flatBufferBuilder,
851 m_flatBufferBuilder.CreateVector(descriptor.
m_Axis),
854 auto fbMeanLayer = serializer::CreateMeanLayer(m_flatBufferBuilder,
858 CreateAnyLayer(fbMeanLayer.o, serializer::Layer::Layer_MeanLayer);
865 auto fbMinimumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Minimum);
866 auto fbMinimumLayer = serializer::CreateMinimumLayer(m_flatBufferBuilder, fbMinimumBaseLayer);
868 CreateAnyLayer(fbMinimumLayer.o, serializer::Layer::Layer_MinimumLayer);
875 auto fbMergeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Merge);
876 auto fbMergeLayer = serializer::CreateMergeLayer(m_flatBufferBuilder, fbMergeBaseLayer);
878 CreateAnyLayer(fbMergeLayer.o, serializer::Layer::Layer_MergeLayer);
887 auto flatBufferConcatBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Concat);
889 std::vector<flatbuffers::Offset<UintVector>> views;
890 for (
unsigned int v = 0; v < concatDescriptor.
GetNumViews(); ++v)
893 std::vector<uint32_t> origins;
896 origins.push_back(origin[d]);
898 auto view = m_flatBufferBuilder.CreateVector(origins);
899 auto uintVector = CreateUintVector(m_flatBufferBuilder, view);
900 views.push_back(uintVector);
903 auto flatBufferConcatDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
907 m_flatBufferBuilder.CreateVector(views));
909 auto flatBufferLayer = CreateConcatLayer(m_flatBufferBuilder,
910 flatBufferConcatBaseLayer,
911 flatBufferConcatDescriptor);
913 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConcatLayer);
920 auto fbMultiplicationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Multiplication);
921 auto fbMultiplicationLayer = serializer::CreateMultiplicationLayer(m_flatBufferBuilder,
922 fbMultiplicationBaseLayer);
924 CreateAnyLayer(fbMultiplicationLayer.o, serializer::Layer::Layer_MultiplicationLayer);
933 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pad);
935 std::vector<unsigned int> padList;
938 padList.push_back(p.first);
939 padList.push_back(p.second);
942 auto flatBufferPadDesc = serializer::CreatePadDescriptor(m_flatBufferBuilder,
943 m_flatBufferBuilder.CreateVector(padList),
947 auto flatBufferPadLayer = serializer::CreatePadLayer(m_flatBufferBuilder,
951 CreateAnyLayer(flatBufferPadLayer.o, serializer::Layer::Layer_PadLayer);
961 auto flatBufferPermuteBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Permute);
963 std::vector<unsigned int> dimMappings;
969 auto flatBufferPermuteDesc = serializer::CreatePermuteDescriptor(m_flatBufferBuilder,
970 m_flatBufferBuilder.CreateVector(dimMappings));
973 auto flatBufferPermuteLayer = serializer::CreatePermuteLayer(m_flatBufferBuilder,
974 flatBufferPermuteBaseLayer,
975 flatBufferPermuteDesc);
978 CreateAnyLayer(flatBufferPermuteLayer.o, serializer::Layer::Layer_PermuteLayer);
986 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Rank);
987 auto flatBufferRankLayer = serializer::CreateRankLayer(m_flatBufferBuilder, flatBufferBaseLayer);
989 CreateAnyLayer(flatBufferRankLayer.o, serializer::Layer::Layer_RankLayer);
996 auto fbReduceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reduce);
997 auto fbDescriptor = CreateReduceDescriptor(m_flatBufferBuilder,
999 m_flatBufferBuilder.CreateVector(reduceDescriptor.
m_vAxis),
1001 auto fbReduceLayer = serializer::CreateReduceLayer(m_flatBufferBuilder,
1005 CreateAnyLayer(fbReduceLayer.o, serializer::Layer::Layer_ReduceLayer);
1016 auto flatBufferReshapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reshape);
1018 std::vector<unsigned int> targetShape;
1024 auto flatBufferReshapeDesc = serializer::CreateReshapeDescriptor(m_flatBufferBuilder,
1025 m_flatBufferBuilder.CreateVector(targetShape));
1028 auto flatBufferReshapeLayer = serializer::CreateReshapeLayer(m_flatBufferBuilder, flatBufferReshapeBaseLayer,
1029 flatBufferReshapeDesc);
1032 CreateAnyLayer(flatBufferReshapeLayer.o, serializer::Layer::Layer_ReshapeLayer);
1041 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Resize);
1043 auto flatBufferDescriptor =
1044 CreateResizeDescriptor(m_flatBufferBuilder,
1052 auto flatBufferLayer = serializer::CreateResizeLayer(m_flatBufferBuilder,
1053 flatBufferBaseLayer,
1054 flatBufferDescriptor);
1056 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeLayer);
1064 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ReverseV2);
1066 auto flatBufferLayer = serializer::CreateReverseV2Layer(m_flatBufferBuilder,
1067 flatBufferBaseLayer);
1069 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ReverseV2Layer);
1078 auto fbSliceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Slice);
1079 auto fbSliceDescriptor = CreateSliceDescriptor(m_flatBufferBuilder,
1080 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Begin),
1081 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Size));
1083 auto fbSliceLayer = serializer::CreateSliceLayer(m_flatBufferBuilder, fbSliceBaseLayer, fbSliceDescriptor);
1085 CreateAnyLayer(fbSliceLayer.o, serializer::Layer::Layer_SliceLayer);
1096 auto flatBufferSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Softmax);
1099 auto flatBufferSoftmaxDesc =
1100 serializer::CreateSoftmaxDescriptor(m_flatBufferBuilder,
1101 softmaxDescriptor.
m_Beta,
1102 softmaxDescriptor.
m_Axis);
1105 auto flatBufferSoftmaxLayer =
1106 serializer::CreateSoftmaxLayer(m_flatBufferBuilder,
1107 flatBufferSoftmaxBaseLayer,
1108 flatBufferSoftmaxDesc);
1110 CreateAnyLayer(flatBufferSoftmaxLayer.o, serializer::Layer::Layer_SoftmaxLayer);
1119 auto fbPooling2dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling2d);
1120 auto fbPooling2dDescriptor = serializer::CreatePooling2dDescriptor(
1121 m_flatBufferBuilder,
1135 auto fbPooling2dLayer = serializer::CreatePooling2dLayer(m_flatBufferBuilder,
1136 fbPooling2dBaseLayer,
1137 fbPooling2dDescriptor);
1139 CreateAnyLayer(fbPooling2dLayer.o, serializer::Layer::Layer_Pooling2dLayer);
1148 auto fbPooling3dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling3d);
1149 auto fbPooling3dDescriptor = serializer::CreatePooling3dDescriptor(
1150 m_flatBufferBuilder,
1168 auto fbPooling3dLayer = serializer::CreatePooling3dLayer(m_flatBufferBuilder,
1169 fbPooling3dBaseLayer,
1170 fbPooling3dDescriptor);
1172 CreateAnyLayer(fbPooling3dLayer.o, serializer::Layer::Layer_Pooling3dLayer);
1181 auto flatBufferPreluBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Prelu);
1184 auto flatBufferPreluLayer = serializer::CreatePreluLayer(m_flatBufferBuilder, flatBufferPreluBaseLayer);
1187 CreateAnyLayer(flatBufferPreluLayer.o, serializer::Layer::Layer_PreluLayer);
1194 auto fbQuantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Quantize);
1195 auto fbQuantizeLayer = serializer::CreateQuantizeLayer(m_flatBufferBuilder,
1196 fbQuantizeBaseLayer);
1197 CreateAnyLayer(fbQuantizeLayer.o, serializer::Layer::Layer_QuantizeLayer);
1206 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_FullyConnected);
1209 auto flatBufferDescriptor =
1210 serializer::CreateFullyConnectedDescriptor(m_flatBufferBuilder,
1216 auto flatBufferLayer = serializer::CreateFullyConnectedLayer(m_flatBufferBuilder,
1217 flatBufferBaseLayer,
1218 flatBufferDescriptor);
1221 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_FullyConnectedLayer);
1232 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToBatchNd);
1234 std::vector<unsigned int> padList;
1235 padList.reserve(spaceToBatchNdDescriptor.
m_PadList.size()*2);
1236 for (
auto& pad : spaceToBatchNdDescriptor.
m_PadList)
1238 padList.push_back(pad.first);
1239 padList.push_back(pad.second);
1242 auto flatBufferDescriptor =
1243 CreateSpaceToBatchNdDescriptor(m_flatBufferBuilder,
1244 m_flatBufferBuilder.CreateVector(spaceToBatchNdDescriptor.
m_BlockShape),
1245 m_flatBufferBuilder.CreateVector(padList),
1248 auto flatBufferLayer = serializer::CreateSpaceToBatchNdLayer(m_flatBufferBuilder,
1249 flatBufferBaseLayer,
1250 flatBufferDescriptor);
1252 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToBatchNdLayer);
1262 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToDepth);
1263 auto flatBufferDescriptor =
1264 CreateSpaceToDepthDescriptor(m_flatBufferBuilder,
1268 auto flatBufferLayer = serializer::CreateSpaceToDepthLayer(m_flatBufferBuilder,
1269 flatBufferBaseLayer,
1270 flatBufferDescriptor);
1272 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToDepthLayer);
1283 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewOrigins;
1284 flatBufferViewOrigins.reserve(viewsDescriptor.
GetNumViews());
1286 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1288 std::vector<uint32_t> viewOrigin;
1292 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1294 viewOrigin.push_back(viewsDescriptor.
GetViewOrigin(vIdx)[dIdx]);
1297 flatBufferViewOrigins.push_back(CreateUintVector(m_flatBufferBuilder,
1298 m_flatBufferBuilder.CreateVector(viewOrigin)));
1302 auto flatBufferOriginDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
1306 m_flatBufferBuilder.CreateVector(flatBufferViewOrigins));
1309 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewSizes;
1310 flatBufferViewSizes.reserve(viewsDescriptor.
GetNumViews());
1312 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1314 std::vector<uint32_t> viewSize;
1318 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1320 viewSize.push_back(viewsDescriptor.
GetViewSizes(vIdx)[dIdx]);
1323 flatBufferViewSizes.push_back(CreateUintVector(m_flatBufferBuilder,
1324 m_flatBufferBuilder.CreateVector(viewSize)));
1328 auto flatBufferViewsDescriptor = CreateViewsDescriptor(m_flatBufferBuilder,
1329 flatBufferOriginDescriptor,
1330 m_flatBufferBuilder.CreateVector(flatBufferViewSizes),
1335 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Splitter);
1337 auto flatBufferSplitterLayer = serializer::CreateSplitterLayer(m_flatBufferBuilder,
1338 flatBufferBaseLayer,
1339 flatBufferViewsDescriptor);
1341 CreateAnyLayer(flatBufferSplitterLayer.o, serializer::Layer::Layer_SplitterLayer);
1350 auto fbNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Normalization);
1352 auto fbNormalizationDescriptor = serializer::CreateNormalizationDescriptor(
1353 m_flatBufferBuilder,
1362 auto flatBufferLayer = serializer::CreateNormalizationLayer(m_flatBufferBuilder,
1363 fbNormalizationBaseLayer,
1364 fbNormalizationDescriptor);
1366 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_NormalizationLayer);
1376 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ScatterNd);
1378 auto flatBufferDesc = serializer::CreateScatterNdDescriptor(
1379 m_flatBufferBuilder,
1386 auto flatBufferLayer = serializer::CreateScatterNdLayer(
1387 m_flatBufferBuilder,
1388 flatBufferBaseLayer,
1392 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ScatterNdLayer);
1400 auto shapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Shape);
1401 auto shapeLayer = serializer::CreateShapeLayer(m_flatBufferBuilder, shapeBaseLayer);
1403 CreateAnyLayer(shapeLayer.o, serializer::Layer::Layer_ShapeLayer);
1412 auto stackBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Stack);
1414 std::vector<unsigned int> inputShape;
1420 auto flatBufferStackDescriptor = CreateStackDescriptor(m_flatBufferBuilder,
1423 m_flatBufferBuilder.CreateVector(inputShape));
1425 auto stackLayer = serializer::CreateStackLayer(m_flatBufferBuilder, stackBaseLayer, flatBufferStackDescriptor);
1426 CreateAnyLayer(stackLayer.o, serializer::Layer::Layer_StackLayer);
1435 auto fbDescriptor = serializer::CreateStandInDescriptor(m_flatBufferBuilder,
1439 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StandIn);
1440 auto fbLayer = serializer::CreateStandInLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
1442 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_StandInLayer);
1451 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StridedSlice);
1453 auto flatBufferDescriptor =
1454 CreateStridedSliceDescriptor(m_flatBufferBuilder,
1455 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Begin),
1456 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_End),
1457 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Stride),
1465 auto flatBufferLayer = serializer::CreateStridedSliceLayer(m_flatBufferBuilder,
1466 flatBufferBaseLayer,
1467 flatBufferDescriptor);
1469 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_StridedSliceLayer);
1476 auto fbSubtractionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Subtraction);
1477 auto fbSubtractionLayer = serializer::CreateSubtractionLayer(m_flatBufferBuilder, fbSubtractionBaseLayer);
1479 CreateAnyLayer(fbSubtractionLayer.o, serializer::Layer::Layer_SubtractionLayer);
1486 auto fbSwitchBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Switch);
1487 auto fbSwitchLayer = serializer::CreateSwitchLayer(m_flatBufferBuilder, fbSwitchBaseLayer);
1489 CreateAnyLayer(fbSwitchLayer.o, serializer::Layer::Layer_SwitchLayer);
1499 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Tile);
1501 auto flatBufferDesc = serializer::CreateTileDescriptor(m_flatBufferBuilder,
1502 m_flatBufferBuilder.CreateVector(descriptor.
m_Multiples));
1505 auto flatBufferLayer = serializer::CreateTileLayer(m_flatBufferBuilder,
1506 flatBufferBaseLayer,
1510 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_TileLayer);
1513 void SerializerStrategy::SerializeTransposeConvolution2dLayer(
1516 const std::vector<armnn::ConstTensor>& constants,
1523 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
1524 auto fbDescriptor = CreateTransposeConvolution2dDescriptor(m_flatBufferBuilder,
1535 auto fbWeightsConstTensorInfo = CreateConstTensorInfo(weights);
1536 flatbuffers::Offset<serializer::ConstTensor> fbBiasesConstTensorInfo;
1537 if (constants.size() > 1)
1540 fbBiasesConstTensorInfo = CreateConstTensorInfo(biases);
1543 auto fbLayer = CreateTransposeConvolution2dLayer(m_flatBufferBuilder,
1546 fbWeightsConstTensorInfo,
1547 fbBiasesConstTensorInfo);
1549 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_TransposeConvolution2dLayer);
1559 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Transpose);
1561 std::vector<unsigned int> dimMappings;
1567 auto flatBufferDesc = serializer::CreateTransposeDescriptor(m_flatBufferBuilder,
1568 m_flatBufferBuilder.CreateVector(dimMappings));
1571 auto flatBufferLayer = serializer::CreateTransposeLayer(m_flatBufferBuilder,
1572 flatBufferBaseLayer,
1576 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_TransposeLayer);
1581 const std::vector<armnn::ConstTensor>& constants,
1586 auto fbQLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QLstm);
1588 auto fbQLstmDescriptor = serializer::CreateQLstmDescriptor(
1589 m_flatBufferBuilder,
1608 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1609 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1610 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1611 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1612 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1613 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1614 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1615 auto cellBias = CreateConstTensorInfo(constants[i++]);
1616 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1619 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1620 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1621 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1625 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1626 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1627 inputGateBias = CreateConstTensorInfo(constants[i++]);
1631 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1632 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1633 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1639 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1641 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1642 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1646 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1647 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1651 projectionWeights = CreateConstTensorInfo(constants[i++]);
1652 projectionBias = CreateConstTensorInfo(constants[i++]);
1656 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1657 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1658 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1659 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1665 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1667 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1668 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1669 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1672 auto fbQLstmParams = serializer::CreateQLstmInputParams(
1673 m_flatBufferBuilder,
1674 inputToForgetWeights,
1676 inputToOutputWeights,
1677 recurrentToForgetWeights,
1678 recurrentToCellWeights,
1679 recurrentToOutputWeights,
1683 inputToInputWeights,
1684 recurrentToInputWeights,
1689 cellToForgetWeights,
1690 cellToOutputWeights,
1691 inputLayerNormWeights,
1692 forgetLayerNormWeights,
1693 cellLayerNormWeights,
1694 outputLayerNormWeights);
1696 auto fbQLstmLayer = serializer::CreateQLstmLayer(
1697 m_flatBufferBuilder,
1702 CreateAnyLayer(fbQLstmLayer.o, serializer::Layer::Layer_QLstmLayer);
1706 const std::vector<armnn::ConstTensor>& constants,
1711 auto fbQuantizedLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QuantizedLstm);
1717 auto inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1718 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1719 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1720 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1722 auto recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1723 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1724 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1725 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1727 auto inputGateBias = CreateConstTensorInfo(constants[i++]);
1728 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1729 auto cellBias = CreateConstTensorInfo(constants[i++]);
1730 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1732 auto fbQuantizedLstmParams = serializer::CreateQuantizedLstmInputParams(
1733 m_flatBufferBuilder,
1734 inputToInputWeights,
1735 inputToForgetWeights,
1737 inputToOutputWeights,
1738 recurrentToInputWeights,
1739 recurrentToForgetWeights,
1740 recurrentToCellWeights,
1741 recurrentToOutputWeights,
1747 auto fbQuantizedLstmLayer = serializer::CreateQuantizedLstmLayer(
1748 m_flatBufferBuilder,
1749 fbQuantizedLstmBaseLayer,
1750 fbQuantizedLstmParams);
1752 CreateAnyLayer(fbQuantizedLstmLayer.o, serializer::Layer::Layer_QuantizedLstmLayer);
1755 void SerializerStrategy::SerializeUnidirectionalSequenceLstmLayer(
1758 const std::vector<armnn::ConstTensor>& constants,
1763 auto fbUnidirectionalSequenceLstmBaseLayer =
1764 CreateLayerBase(layer, serializer::LayerType::LayerType_UnidirectionalSequenceLstm);
1766 auto fbUnidirectionalSequenceLstmDescriptor = serializer::CreateUnidirectionalSequenceLstmDescriptor(
1767 m_flatBufferBuilder,
1781 auto inputToForgetWeights = CreateConstTensorInfo(constants[i++]);
1782 auto inputToCellWeights = CreateConstTensorInfo(constants[i++]);
1783 auto inputToOutputWeights = CreateConstTensorInfo(constants[i++]);
1784 auto recurrentToForgetWeights = CreateConstTensorInfo(constants[i++]);
1785 auto recurrentToCellWeights = CreateConstTensorInfo(constants[i++]);
1786 auto recurrentToOutputWeights = CreateConstTensorInfo(constants[i++]);
1787 auto forgetGateBias = CreateConstTensorInfo(constants[i++]);
1788 auto cellBias = CreateConstTensorInfo(constants[i++]);
1789 auto outputGateBias = CreateConstTensorInfo(constants[i++]);
1792 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
1793 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
1794 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
1795 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
1796 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
1797 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
1798 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
1799 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
1800 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
1801 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
1802 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
1803 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
1807 inputToInputWeights = CreateConstTensorInfo(constants[i++]);
1808 recurrentToInputWeights = CreateConstTensorInfo(constants[i++]);
1809 inputGateBias = CreateConstTensorInfo(constants[i++]);
1816 cellToInputWeights = CreateConstTensorInfo(constants[i++]);
1818 cellToForgetWeights = CreateConstTensorInfo(constants[i++]);
1819 cellToOutputWeights = CreateConstTensorInfo(constants[i++]);
1824 projectionWeights = CreateConstTensorInfo(constants[i++]);
1825 projectionBias = CreateConstTensorInfo(constants[i++]);
1832 inputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1834 forgetLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1835 cellLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1836 outputLayerNormWeights = CreateConstTensorInfo(constants[i++]);
1839 auto fbUnidirectionalSequenceLstmParams = serializer::CreateLstmInputParams(
1840 m_flatBufferBuilder,
1841 inputToForgetWeights,
1843 inputToOutputWeights,
1844 recurrentToForgetWeights,
1845 recurrentToCellWeights,
1846 recurrentToOutputWeights,
1850 inputToInputWeights,
1851 recurrentToInputWeights,
1856 cellToForgetWeights,
1857 cellToOutputWeights,
1858 inputLayerNormWeights,
1859 forgetLayerNormWeights,
1860 cellLayerNormWeights,
1861 outputLayerNormWeights);
1863 auto fbUnidirectionalSequenceLstmLayer = serializer::CreateUnidirectionalSequenceLstmLayer(
1864 m_flatBufferBuilder,
1865 fbUnidirectionalSequenceLstmBaseLayer,
1866 fbUnidirectionalSequenceLstmDescriptor,
1867 fbUnidirectionalSequenceLstmParams);
1869 CreateAnyLayer(fbUnidirectionalSequenceLstmLayer.o, serializer::Layer::Layer_UnidirectionalSequenceLstmLayer);
1872 fb::Offset<serializer::LayerBase> SerializerStrategy::CreateLayerBase(
const IConnectableLayer* layer,
1876 uint32_t fbIndex = GetSerializedId(layer->
GetGuid());
1878 std::vector<fb::Offset<serializer::InputSlot>> inputSlots = CreateInputSlots(layer);
1879 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots = CreateOutputSlots(layer);
1881 return serializer::CreateLayerBase(m_flatBufferBuilder,
1883 m_flatBufferBuilder.CreateString(layer->
GetName()),
1885 m_flatBufferBuilder.CreateVector(inputSlots),
1886 m_flatBufferBuilder.CreateVector(outputSlots));
1889 void SerializerStrategy::CreateAnyLayer(
const flatbuffers::Offset<void>& layer,
const serializer::Layer serializerLayer)
1892 auto anyLayer = armnnSerializer::CreateAnyLayer(m_flatBufferBuilder, serializerLayer, layer);
1893 m_serializedLayers.push_back(anyLayer);
1896 template <
typename T>
1897 flatbuffers::Offset<flatbuffers::Vector<T>> SerializerStrategy::CreateDataVector(
const void* memory,
unsigned int size)
1899 const T* buffer =
reinterpret_cast<const T*
>(memory);
1900 std::vector<T> vector(buffer, buffer + (size /
sizeof(T)));
1901 auto fbVector = m_flatBufferBuilder.CreateVector(vector);
1905 flatbuffers::Offset<TensorInfo> SerializerStrategy::CreateTensorInfo(
const armnn::TensorInfo& tensorInfo)
1908 std::vector<unsigned int> shape;
1909 std::vector<bool> specificity;
1912 for(
unsigned int dim = 0; dim < tensorInfo.
GetShape().GetNumDimensions(); ++dim)
1918 shape.push_back(tensorInfo.
GetShape()[dim]);
1929 auto flatBufferTensorInfo =
1930 serializer::CreateTensorInfo(m_flatBufferBuilder,
1931 m_flatBufferBuilder.CreateVector(shape),
1937 static_cast<unsigned int>
1939 m_flatBufferBuilder.CreateVector(specificity));
1940 return flatBufferTensorInfo;
1944 auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder,
1945 m_flatBufferBuilder.CreateVector(shape),
1951 static_cast<unsigned int>
1953 m_flatBufferBuilder.CreateVector(specificity));
1954 return flatBufferTensorInfo;
1957 flatbuffers::Offset<serializer::ConstTensor>
1962 flatbuffers::Offset<void> fbPayload;
1969 flatbuffers::Offset<serializer::LongData> flatBuffersData = serializer::CreateLongData(
1970 m_flatBufferBuilder,
1972 fbPayload = flatBuffersData.o;
1979 flatbuffers::Offset<serializer::IntData> flatBuffersData = serializer::CreateIntData(
1980 m_flatBufferBuilder,
1982 fbPayload = flatBuffersData.o;
1990 flatbuffers::Offset<serializer::ShortData> flatBuffersData = serializer::CreateShortData(
1991 m_flatBufferBuilder,
1993 fbPayload = flatBuffersData.o;
2003 flatbuffers::Offset<serializer::ByteData> flatBuffersData = serializer::CreateByteData(
2004 m_flatBufferBuilder,
2006 fbPayload = flatBuffersData.o;
2009 flatbuffers::Offset<serializer::ConstTensor> flatBufferConstTensor = serializer::CreateConstTensor(
2010 m_flatBufferBuilder,
2011 CreateTensorInfo(tensorInfo),
2014 return flatBufferConstTensor;
2017 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> SerializerStrategy::GetVersionTable()
2019 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> versionsTable =
2020 serializer::CreateFeatureCompatibilityVersions(
2021 m_flatBufferBuilder,
2026 return versionsTable;
2029 std::vector<fb::Offset<serializer::InputSlot>>
2032 std::vector<fb::Offset<serializer::InputSlot>> inputSlots;
2035 for (
unsigned int slotIndex = 0; slotIndex<layer->
GetNumInputSlots(); ++slotIndex)
2043 flatbuffers::Offset<TensorInfo> overriddenTensorInfo = CreateTensorInfo(inputSlot.
GetTensorInfo());
2049 inputSlots.push_back(serializer::CreateInputSlot(m_flatBufferBuilder, slotIndex, &conn, isOverridden,
2050 overriddenTensorInfo));
2055 std::vector<fb::Offset<serializer::OutputSlot>>
2058 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots;
2061 for (
unsigned int slotIndex = 0; slotIndex < layer->
GetNumOutputSlots(); ++slotIndex)
2067 outputSlots.push_back(serializer::CreateOutputSlot(m_flatBufferBuilder,
2069 CreateTensorInfo(tensorInfo)));
2076 const std::vector<armnn::ConstTensor>& constants,
2088 SerializeActivationLayer(layer, layerDescriptor, name);
2093 SerializeAdditionLayer(layer, name);
2100 SerializeArgMinMaxLayer(layer, layerDescriptor, name);
2107 SerializeBatchMatMulLayer(layer,
2116 SerializeBatchNormalizationLayer(layer,
2126 SerializeBatchToSpaceNdLayer(layer,
2133 SerializeCastLayer(layer, name);
2140 SerializeChannelShuffleLayer(layer,
2149 SerializeComparisonLayer(layer,
2158 SerializeConcatLayer(layer,
2165 SerializeConstantLayer(layer,
2174 SerializeConvolution2dLayer(layer,
2183 SerializeConvolution3dLayer(layer,
2192 SerializeDepthToSpaceLayer(layer,
2201 SerializeDepthwiseConvolution2dLayer(layer,
2208 SerializeDequantizeLayer(layer,
2216 SerializeDetectionPostProcessLayer(layer, layerDescriptor, constants, name);
2221 SerializeDivisionLayer(layer, name);
2228 SerializeElementwiseBinaryLayer(layer, layerDescriptor, name);
2235 SerializeElementwiseUnaryLayer(layer, layerDescriptor, name);
2242 SerializeFillLayer(layer, layerDescriptor, name);
2247 SerializeFloorLayer(layer, name);
2254 SerializeFullyConnectedLayer(layer, layerDescriptor, name);
2261 SerializeGatherLayer(layer, layerDescriptor, name);
2266 SerializeGatherNdLayer(layer, name);
2271 SerializeInputLayer(layer,
id, name);
2278 SerializeInstanceNormalizationLayer(layer, layerDescriptor, name);
2285 SerializeL2NormalizationLayer(layer, layerDescriptor, name);
2292 SerializeLogicalBinaryLayer(layer, layerDescriptor, name);
2299 SerializeLogSoftmaxLayer(layer, layerDescriptor, name);
2306 SerializeLstmLayer(layer, layerDescriptor, constants, name);
2313 SerializeQLstmLayer(layer, layerDescriptor, constants, name);
2318 SerializeMaximumLayer(layer, name);
2325 SerializeMeanLayer(layer, layerDescriptor, name);
2330 SerializeMergeLayer(layer, name);
2335 SerializeMinimumLayer(layer, name);
2340 SerializeMultiplicationLayer(layer, name);
2347 SerializeNormalizationLayer(layer, layerDescriptor, name);
2352 SerializeOutputLayer(layer,
id, name);
2359 SerializePadLayer(layer, layerDescriptor, name);
2366 SerializePermuteLayer(layer, layerDescriptor, name);
2373 SerializePooling2dLayer(layer, layerDescriptor, name);
2380 SerializePooling3dLayer(layer, layerDescriptor, name);
2385 SerializePreluLayer(layer, name);
2390 SerializeQuantizeLayer(layer, name);
2394 SerializeQuantizedLstmLayer(layer, constants, name);
2400 SerializeReshapeLayer(layer, layerDescriptor, name);
2405 SerializeRankLayer(layer, name);
2412 SerializeReduceLayer(layer, layerDescriptor, name);
2419 SerializeResizeLayer(layer, layerDescriptor, name);
2424 SerializeReverseV2Layer(layer, name);
2431 SerializeScatterNdLayer(layer, layerDescriptor, name);
2436 SerializeShapeLayer(layer, name);
2443 SerializeSliceLayer(layer, layerDescriptor, name);
2450 SerializeSoftmaxLayer(layer, layerDescriptor, name);
2457 SerializeSpaceToBatchNdLayer(layer, layerDescriptor, name);
2464 SerializeSpaceToDepthLayer(layer, layerDescriptor, name);
2471 SerializeSplitterLayer(layer, layerDescriptor, name);
2478 SerializeStackLayer(layer, layerDescriptor, name);
2485 SerializeStandInLayer(layer, layerDescriptor, name);
2492 SerializeStridedSliceLayer(layer, layerDescriptor, name);
2497 SerializeSubtractionLayer(layer, name);
2502 SerializeSwitchLayer(layer, name);
2509 SerializeTileLayer(layer, layerDescriptor, name);
2516 SerializeTransposeLayer(layer, layerDescriptor, name);
2523 SerializeTransposeConvolution2dLayer(layer, layerDescriptor, constants, name);
2530 SerializeUnidirectionalSequenceLstmLayer(layer, layerDescriptor, constants, name);
2536 fmt::format(
"A layer of unknown type was given to the serializer. Layer name: {}; Layer Id: {}",
2543 void ISerializer::SerializerImpl::Serialize(
const INetwork& inNetwork)
2547 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2550 auto serializedGraph = serializer::CreateSerializedGraph(
2552 fbBuilder.CreateVector(m_SerializerStrategy.GetSerializedLayers()),
2553 fbBuilder.CreateVector(m_SerializerStrategy.GetInputIds()),
2554 fbBuilder.CreateVector(m_SerializerStrategy.GetOutputIds()),
2555 m_SerializerStrategy.GetVersionTable());
2558 fbBuilder.Finish(serializedGraph);
2562 bool ISerializer::SerializerImpl::SaveSerializedToStream(std::ostream& stream)
2564 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2566 auto bytesToWrite = armnn::numeric_cast<std::streamsize>(fbBuilder.GetSize());
2567 stream.write(
reinterpret_cast<const char*
>(fbBuilder.GetBufferPointer()), bytesToWrite);
2568 return !stream.bad();
arm::pipe::ProfilingGuid LayerGuid
Define LayerGuid type.
const TensorInfo & GetInfo() const
MemoryType GetMemoryArea() const
unsigned int GetNumBytes() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
virtual const char * GetName() const =0
Returns the name of the layer.
Main network class which provides the interface for building up a neural network.
void ExecuteStrategy(IStrategy &strategy) const
An output connection slot for a layer.
virtual unsigned int CalculateIndexOnOwner() const =0
virtual const TensorInfo & GetTensorInfo() const =0
virtual LayerGuid GetOwningLayerGuid() const =0
float GetQuantizationScale() const
int32_t GetQuantizationOffset() const
const TensorShape & GetShape() const
Optional< unsigned int > GetQuantizationDim() const
std::vector< float > GetQuantizationScales() const
bool HasPerAxisQuantization() const
DataType GetDataType() const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
Dimensionality GetDimensionality() const
Function that returns the tensor type.
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
@ BoundedReLu
min(a, max(b, input)) ReLu1 & ReLu6.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
@ UnidirectionalSequenceLstm
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
armnnSerializer::ComparisonOperation GetFlatBufferComparisonOperation(armnn::ComparisonOperation comparisonOperation)
armnnSerializer::ResizeMethod GetFlatBufferResizeMethod(armnn::ResizeMethod method)
armnnSerializer::DataType GetFlatBufferDataType(armnn::DataType dataType)
armnnSerializer::ReduceOperation GetFlatBufferReduceOperation(armnn::ReduceOperation reduceOperation)
armnnSerializer::LogicalBinaryOperation GetFlatBufferLogicalBinaryOperation(armnn::LogicalBinaryOperation logicalBinaryOperation)
armnnSerializer::PaddingMethod GetFlatBufferPaddingMethod(armnn::PaddingMethod paddingMethod)
armnnSerializer::BinaryOperation GetFlatBufferBinaryOperation(armnn::BinaryOperation binaryOperation)
armnnSerializer::PaddingMode GetFlatBufferPaddingMode(armnn::PaddingMode paddingMode)
std::unique_ptr< ISerializer, void(*)(ISerializer *serializer)> ISerializerPtr
armnnSerializer::DataLayout GetFlatBufferDataLayout(armnn::DataLayout dataLayout)
serializer::ArgMinMaxFunction GetFlatBufferArgMinMaxFunction(armnn::ArgMinMaxFunction function)
armnnSerializer::OutputShapeRounding GetFlatBufferOutputShapeRounding(armnn::OutputShapeRounding outputShapeRounding)
serializer::ScatterNdFunction GetFlatBufferScatterNdFunction(armnn::ScatterNdFunction function)
serializer::ActivationFunction GetFlatBufferActivationFunction(armnn::ActivationFunction function)
armnnSerializer::PoolingAlgorithm GetFlatBufferPoolingAlgorithm(armnn::PoolingAlgorithm poolingAlgorithm)
armnnSerializer::NormalizationAlgorithmMethod GetFlatBufferNormalizationAlgorithmMethod(armnn::NormalizationAlgorithmMethod normalizationAlgorithmMethod)
armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperation unaryOperation)
armnnSerializer::NormalizationAlgorithmChannel GetFlatBufferNormalizationAlgorithmChannel(armnn::NormalizationAlgorithmChannel normalizationAlgorithmChannel)
armnnSerializer::ConstTensorData GetFlatBufferConstTensorData(armnn::DataType dataType)
An ActivationDescriptor for the ActivationLayer.
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH,...
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu,...
An ArgMinMaxDescriptor for ArgMinMaxLayer.
int m_Axis
Axis to reduce across the input tensor.
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
Base class for all descriptors.
A BatchMatMulDescriptor for the BatchMatMul operator.
bool m_AdjointX
Adjoint the slices of each input tensor Transpose and Adjoint can not both be set to true for the sam...
bool m_TransposeX
Transpose the slices of each input tensor Transpose and Adjoint can not both be set to true for the s...
DataLayout m_DataLayoutX
Data layout of each input tensor, such as NHWC/NDHWC (leave as default for arbitrary layout)
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
std::vector< unsigned int > m_BlockShape
Block shape values.
std::vector< std::pair< unsigned int, unsigned int > > m_Crops
The values to crop from the input dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A ChannelShuffleDescriptor for the ChannelShuffle operator.
uint32_t m_NumGroups
Number of groups for the channel shuffle operation.
uint32_t m_Axis
Axis to apply channel shuffle operation on.
A ComparisonDescriptor for the ComparisonLayer.
ComparisonOperation m_Operation
Specifies the comparison operation to execute.
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_DilationY
Dilation along y axis.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A Convolution3dDescriptor for the Convolution3dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_PadBack
Padding back value in the depth dimension.
uint32_t m_DilationZ
Dilation along z axis.
uint32_t m_DilationY
Dilation along y axis.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NDHWC, NCDHW).
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_DilationY
Dilation factor value for height dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationX
Dilation factor value for width dimension.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_NumClasses
Number of classes.
float m_NmsScoreThreshold
NMS score threshold.
float m_NmsIouThreshold
Intersection over union threshold.
float m_ScaleY
Center size encoding scale y.
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
bool m_UseRegularNms
Use Regular NMS.
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
float m_ScaleH
Center size encoding scale height.
float m_ScaleW
Center size encoding scale weight.
float m_ScaleX
Center size encoding scale x.
uint32_t m_MaxDetections
Maximum numbers of detections.
A ElementwiseBinaryDescriptor for the ElementwiseBinaryLayer.
BinaryOperation m_Operation
Specifies the elementwiseBinary operation to execute.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
UnaryOperation m_Operation
Specifies the elementwiseUnary operation to execute.
A FillDescriptor for the FillLayer.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
bool m_ConstantWeights
Enable/disable constant weights and biases.
bool m_BiasEnabled
Enable/disable bias.
A GatherDescriptor for the GatherLayer.
int32_t m_Axis
The axis in params to gather indices from.
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
float m_Eps
Epsilon, small scalar value added to variance to avoid dividing by zero. Defaults to 1e-12f.
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0.
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.
A L2NormalizationDescriptor for the L2NormalizationLayer.
float m_Eps
Used to avoid dividing by zero.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
LogicalBinaryOperation m_Operation
Specifies the logical operation to execute.
An LstmDescriptor for the LstmLayer.
bool m_PeepholeEnabled
Enable/disable peephole.
bool m_TimeMajor
Enable/disable time major.
bool m_LayerNormEnabled
Enable/disable layer normalization.
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
uint32_t m_ActivationFunc
The activation function to use.
A MeanDescriptor for the MeanLayer.
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
bool m_KeepDims
Enable/disable keep dimensions. If true, then the reduced dimensions that are of length 1 are kept.
A NormalizationDescriptor for the NormalizationLayer.
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
float m_Alpha
Alpha value for the normalization equation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_Beta
Beta value for the normalization equation.
float m_K
Kappa value used for the across channel normalization equation.
uint32_t m_NormSize
Depth radius value.
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
An OriginsDescriptor for the ConcatLayer.
uint32_t GetNumViews() const
Get the number of views.
unsigned int GetConcatAxis() const
Get the concatenation axis value.
uint32_t GetNumDimensions() const
Get the number of dimensions.
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.
A PadDescriptor for the PadLayer.
float m_PadValue
Optional value to use for padding, defaults to 0.
PaddingMode m_PaddingMode
Specifies the Padding mode (Constant, Reflect or Symmetric)
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
A PermuteDescriptor for the PermuteLayer.
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination,...
A Pooling2dDescriptor for the Pooling2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PoolWidth
Pooling width value.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
A Pooling3dDescriptor for the Pooling3dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_PadBack
Padding back value in the depth dimension.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PadFront
Padding front value in the depth dimension.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_PoolDepth
Pooling depth value.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
A QLstmDescriptor for the QLstmLayer.
float m_CellIntermediateScale
Cell intermediate quantization scale.
float m_InputIntermediateScale
Input intermediate quantization scale.
bool m_PeepholeEnabled
Enable/disable peephole.
int32_t m_HiddenStateZeroPoint
Hidden State zero point.
bool m_LayerNormEnabled
Enable/disable layer normalization.
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_OutputIntermediateScale
Output intermediate quantization scale.
float m_ProjectionClip
Clipping threshold value for the projection.
float m_CellClip
Clipping threshold value for the cell state.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
float m_HiddenStateScale
Hidden State quantization scale.
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
A ReduceDescriptor for the REDUCE operators.
bool m_KeepDims
if true then output shape has no change.
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
ReduceOperation m_ReduceOperation
Specifies the reduction operation to execute.
A ReshapeDescriptor for the ReshapeLayer.
TensorShape m_TargetShape
Target shape value.
A ResizeDescriptor for the ResizeLayer.
bool m_HalfPixelCenters
Half Pixel Centers.
uint32_t m_TargetHeight
Target height value.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
uint32_t m_TargetWidth
Target width value.
bool m_AlignCorners
Aligned corners.
A ScatterNdDescriptor for the ScatterNdLayer.
bool m_InputEnabled
Flag to show if input tensor is accepted.
ScatterNdFunction m_Function
Specify if the function is update, add, sub, max or min.
int32_t m_Axis
Extra attribute for ScatterElement, will be set to 0 by default, we do not support axis !...
bool m_AxisEnabled
Flag for ScatterElement, will be set to false by default, we do not support m_AxisEnable = true for n...
A SliceDescriptor for the SliceLayer.
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
A SoftmaxDescriptor for the SoftmaxLayer.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
float m_Beta
Exponentiation value.
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
std::vector< unsigned int > m_BlockShape
Block shape value.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left,...
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
A StackDescriptor for the StackLayer.
TensorShape m_InputShape
Required shape of all input tensors.
uint32_t m_Axis
0-based axis along which to stack the input tensors.
uint32_t m_NumInputs
Number of input tensors.
A StandInDescriptor for the StandIn layer.
uint32_t m_NumOutputs
Number of output tensors.
uint32_t m_NumInputs
Number of input tensors.
A StridedSliceDescriptor for the StridedSliceLayer.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::vector< int > m_Begin
Begin values for the input that will be sliced.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
int32_t m_BeginMask
Begin mask value.
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1.
int32_t m_NewAxisMask
New axis mask value.
std::vector< int > m_End
End values for the input that will be sliced.
int32_t m_EndMask
End mask value.
int32_t m_EllipsisMask
Ellipsis mask value.
std::vector< uint32_t > m_Multiples
The vector to multiply the input shape by.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A TransposeDescriptor for the TransposeLayer.
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination,...
A ViewsDescriptor for the SplitterLayer.
bool HasAxis() const
Returns true if an axis has been set.
int32_t GetAxis() const
Get the axis value.
uint32_t GetNumViews() const
Get the number of views.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
uint32_t GetNumDimensions() const
Get the number of dimensions.
const OriginsDescriptor & GetOrigins() const
Get the View Origins.
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.