14 #include <boost/core/ignore_unused.hpp> 15 #include <boost/numeric/conversion/cast.hpp> 16 #include <flatbuffers/util.h> 20 using namespace armnn;
21 namespace fb = flatbuffers;
32 return serializer::ActivationFunction::ActivationFunction_Sigmoid;
34 return serializer::ActivationFunction::ActivationFunction_TanH;
36 return serializer::ActivationFunction::ActivationFunction_Linear;
38 return serializer::ActivationFunction::ActivationFunction_ReLu;
40 return serializer::ActivationFunction::ActivationFunction_BoundedReLu;
42 return serializer::ActivationFunction::ActivationFunction_LeakyReLu;
44 return serializer::ActivationFunction::ActivationFunction_Abs;
46 return serializer::ActivationFunction::ActivationFunction_Sqrt;
48 return serializer::ActivationFunction::ActivationFunction_Square;
50 return serializer::ActivationFunction::ActivationFunction_Sigmoid;
59 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Max;
62 return serializer::ArgMinMaxFunction::ArgMinMaxFunction_Min;
68 if (m_guidMap.empty())
70 m_guidMap.insert(std::make_pair(guid, m_layerId));
72 else if (m_guidMap.find(guid) == m_guidMap.end())
75 m_guidMap.insert(std::make_pair(guid, m_layerId));
79 return m_guidMap[guid];
85 boost::ignore_unused(name);
88 auto flatBufferInputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Input);
91 auto flatBufferInputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
92 flatBufferInputBaseLayer,
95 m_inputIds.push_back(
id);
98 auto flatBufferInputLayer = serializer::CreateInputLayer(m_flatBufferBuilder, flatBufferInputBindableBaseLayer);
101 CreateAnyLayer(flatBufferInputLayer.o, serializer::Layer::Layer_InputLayer);
107 boost::ignore_unused(name);
110 auto flatBufferOutputBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Output);
113 auto flatBufferOutputBindableBaseLayer = serializer::CreateBindableLayerBase(m_flatBufferBuilder,
114 flatBufferOutputBaseLayer,
117 m_outputIds.push_back(
id);
120 auto flatBufferOutputLayer = serializer::CreateOutputLayer(m_flatBufferBuilder, flatBufferOutputBindableBaseLayer);
122 CreateAnyLayer(flatBufferOutputLayer.o, serializer::Layer::Layer_OutputLayer);
127 boost::ignore_unused(name);
128 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Abs);
129 auto flatBufferAbsLayer = serializer::CreateAbsLayer(m_flatBufferBuilder, flatBufferBaseLayer);
131 CreateAnyLayer(flatBufferAbsLayer.o, serializer::Layer::Layer_AbsLayer);
139 boost::ignore_unused(name);
142 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Activation);
145 auto flatBufferDescriptor = CreateActivationDescriptor(m_flatBufferBuilder,
151 auto flatBufferAdditionLayer = CreateActivationLayer(m_flatBufferBuilder,
153 flatBufferDescriptor);
156 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_ActivationLayer);
162 boost::ignore_unused(name);
165 auto flatBufferAdditionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Addition);
168 auto flatBufferAdditionLayer = serializer::CreateAdditionLayer(m_flatBufferBuilder, flatBufferAdditionBaseLayer);
171 CreateAnyLayer(flatBufferAdditionLayer.o, serializer::Layer::Layer_AdditionLayer);
179 boost::ignore_unused(name);
182 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ArgMinMax);
185 auto flatBufferDescriptor = CreateArgMinMaxDescriptor(m_flatBufferBuilder,
190 auto flatBufferLayer = CreateArgMinMaxLayer(m_flatBufferBuilder,
192 flatBufferDescriptor);
194 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ArgMinMaxLayer);
202 boost::ignore_unused(name);
205 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchToSpaceNd);
207 std::vector<unsigned int> crops;
208 crops.reserve(descriptor.
m_Crops.size() * 2);
209 for (
auto& crop : descriptor.
m_Crops)
211 crops.push_back(crop.first);
212 crops.push_back(crop.second);
215 auto flatBufferDescriptor =
216 CreateBatchToSpaceNdDescriptor(m_flatBufferBuilder,
217 m_flatBufferBuilder.CreateVector(descriptor.
m_BlockShape),
218 m_flatBufferBuilder.CreateVector(crops),
221 auto flatBufferLayer = serializer::CreateBatchToSpaceNdLayer(m_flatBufferBuilder,
223 flatBufferDescriptor);
225 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_BatchToSpaceNdLayer);
236 boost::ignore_unused(name);
238 auto fbBatchNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_BatchNormalization);
239 auto fbBatchNormalizationDescriptor = serializer::CreateBatchNormalizationDescriptor(
241 batchNormDescriptor.
m_Eps,
244 auto fbMeanConstTensorInfo = CreateConstTensorInfo(mean);
245 auto fbVarianceConstTensorInfo = CreateConstTensorInfo(variance);
246 auto fbBetaConstTensorInfo = CreateConstTensorInfo(beta);
247 auto fbGammaConstTensorInfo = CreateConstTensorInfo(gamma);
248 auto fbBatchNormalizationLayer = serializer::CreateBatchNormalizationLayer(m_flatBufferBuilder,
249 fbBatchNormalizationBaseLayer,
250 fbBatchNormalizationDescriptor,
251 fbMeanConstTensorInfo,
252 fbVarianceConstTensorInfo,
253 fbBetaConstTensorInfo,
254 fbGammaConstTensorInfo);
256 CreateAnyLayer(fbBatchNormalizationLayer.o, serializer::Layer::Layer_BatchNormalizationLayer);
263 boost::ignore_unused(name);
265 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Comparison);
266 auto fbDescriptor = serializer::CreateComparisonDescriptor(
270 auto fbLayer = serializer::CreateComparisonLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
271 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ComparisonLayer);
279 boost::ignore_unused(name);
282 auto flatBufferConstantBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Constant);
284 auto flatBufferConstTensorInfo = CreateConstTensorInfo(input);
287 auto flatBufferLayer = CreateConstantLayer(m_flatBufferBuilder,
288 flatBufferConstantBaseLayer,
289 flatBufferConstTensorInfo);
292 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConstantLayer);
302 boost::ignore_unused(name);
305 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
307 auto flatBufferDescriptor = CreateConvolution2dDescriptor(m_flatBufferBuilder,
318 auto flatBufferWeightsConstTensorInfo = CreateConstTensorInfo(weights);
319 flatbuffers::Offset<serializer::ConstTensor> flatBufferBiasesConstTensorInfo;
323 flatBufferBiasesConstTensorInfo = CreateConstTensorInfo(biases.
value());
327 auto flatBufferLayer = CreateConvolution2dLayer(m_flatBufferBuilder,
329 flatBufferDescriptor,
330 flatBufferWeightsConstTensorInfo,
331 flatBufferBiasesConstTensorInfo);
334 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_Convolution2dLayer);
341 boost::ignore_unused(name);
343 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthToSpace);
344 auto fbDescriptor = CreateDepthToSpaceDescriptor(m_flatBufferBuilder,
348 auto fbLayer = serializer::CreateDepthToSpaceLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
350 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_DepthToSpaceLayer);
359 boost::ignore_unused(name);
361 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DepthwiseConvolution2d);
362 auto fbDescriptor = CreateDepthwiseConvolution2dDescriptor(m_flatBufferBuilder,
374 flatbuffers::Offset<serializer::ConstTensor> fbWeightsConstTensorInfo = CreateConstTensorInfo(weights);
375 flatbuffers::Offset<serializer::ConstTensor> fbBiasesConstTensorInfo;
378 fbBiasesConstTensorInfo = CreateConstTensorInfo(biases.
value());
381 auto flatBufferLayer = CreateDepthwiseConvolution2dLayer(m_flatBufferBuilder,
384 fbWeightsConstTensorInfo,
385 fbBiasesConstTensorInfo);
387 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DepthwiseConvolution2dLayer);
393 boost::ignore_unused(name);
395 auto fbDequantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Dequantize);
396 auto fbDequantizeLayer = serializer::CreateDequantizeLayer(m_flatBufferBuilder, fbDequantizeBaseLayer);
398 CreateAnyLayer(fbDequantizeLayer.o, serializer::Layer::Layer_DequantizeLayer);
406 boost::ignore_unused(name);
408 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_DetectionPostProcess);
409 auto fbDescriptor = CreateDetectionPostProcessDescriptor(m_flatBufferBuilder,
422 flatbuffers::Offset<serializer::ConstTensor> fbAnchorsConstTensorInfo = CreateConstTensorInfo(anchors);
424 auto flatBufferLayer = CreateDetectionPostProcessLayer(m_flatBufferBuilder,
427 fbAnchorsConstTensorInfo);
429 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_DetectionPostProcessLayer);
434 boost::ignore_unused(name);
436 auto fbDivisionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Division);
437 auto fbDivisionLayer = serializer::CreateDivisionLayer(m_flatBufferBuilder, fbDivisionBaseLayer);
439 CreateAnyLayer(fbDivisionLayer.o, serializer::Layer::Layer_DivisionLayer);
446 boost::ignore_unused(name);
448 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ElementwiseUnary);
449 auto fbDescriptor = serializer::CreateElementwiseUnaryDescriptor(
453 auto fbLayer = serializer::CreateElementwiseUnaryLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
454 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseUnaryLayer);
459 boost::ignore_unused(name);
461 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Equal);
462 auto fbEqualLayer = serializer::CreateEqualLayer(m_flatBufferBuilder, fbBaseLayer);
464 CreateAnyLayer(fbEqualLayer.o, serializer::Layer::Layer_EqualLayer);
469 boost::ignore_unused(name);
471 auto flatBufferFloorBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Floor);
472 auto flatBufferFloorLayer = serializer::CreateFloorLayer(m_flatBufferBuilder, flatBufferFloorBaseLayer);
474 CreateAnyLayer(flatBufferFloorLayer.o, serializer::Layer::Layer_FloorLayer);
479 boost::ignore_unused(name);
481 auto fbGatherBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Gather);
482 auto flatBufferLayer = serializer::CreateGatherLayer(m_flatBufferBuilder, fbGatherBaseLayer);
484 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherLayer);
489 boost::ignore_unused(name);
491 auto fbGreaterBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Greater);
492 auto fbGreaterLayer = serializer::CreateGreaterLayer(m_flatBufferBuilder, fbGreaterBaseLayer);
494 CreateAnyLayer(fbGreaterLayer.o, serializer::Layer::Layer_GreaterLayer);
497 void SerializerVisitor::VisitInstanceNormalizationLayer(
502 boost::ignore_unused(name);
504 auto fbDescriptor = serializer::CreateInstanceNormalizationDescriptor(
506 instanceNormalizationDescriptor.
m_Gamma,
507 instanceNormalizationDescriptor.
m_Beta,
508 instanceNormalizationDescriptor.
m_Eps,
511 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_InstanceNormalization);
512 auto fbLayer = serializer::CreateInstanceNormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
514 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_InstanceNormalizationLayer);
521 boost::ignore_unused(name);
524 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_L2Normalization);
527 auto fbDescriptor = serializer::CreateL2NormalizationDescriptor(
530 l2NormalizationDescriptor.
m_Eps);
533 auto fbLayer = serializer::CreateL2NormalizationLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
535 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_L2NormalizationLayer);
542 boost::ignore_unused(name);
545 auto flatBufferLogSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_LogSoftmax);
548 auto flatBufferLogSoftmaxDesc =
549 serializer::CreateLogSoftmaxDescriptor(m_flatBufferBuilder,
550 logSoftmaxDescriptor.
m_Beta,
551 logSoftmaxDescriptor.
m_Axis);
554 auto flatBufferLogSoftmaxLayer =
555 serializer::CreateLogSoftmaxLayer(m_flatBufferBuilder,
556 flatBufferLogSoftmaxBaseLayer,
557 flatBufferLogSoftmaxDesc);
559 CreateAnyLayer(flatBufferLogSoftmaxLayer.o, serializer::Layer::Layer_LogSoftmaxLayer);
567 boost::ignore_unused(name);
569 auto fbLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Lstm);
571 auto fbLstmDescriptor = serializer::CreateLstmDescriptor(
589 auto cellBias = CreateConstTensorInfo(*params.
m_CellBias);
593 flatbuffers::Offset<serializer::ConstTensor> inputToInputWeights;
594 flatbuffers::Offset<serializer::ConstTensor> recurrentToInputWeights;
595 flatbuffers::Offset<serializer::ConstTensor> cellToInputWeights;
596 flatbuffers::Offset<serializer::ConstTensor> inputGateBias;
597 flatbuffers::Offset<serializer::ConstTensor> projectionWeights;
598 flatbuffers::Offset<serializer::ConstTensor> projectionBias;
599 flatbuffers::Offset<serializer::ConstTensor> cellToForgetWeights;
600 flatbuffers::Offset<serializer::ConstTensor> cellToOutputWeights;
601 flatbuffers::Offset<serializer::ConstTensor> inputLayerNormWeights;
602 flatbuffers::Offset<serializer::ConstTensor> forgetLayerNormWeights;
603 flatbuffers::Offset<serializer::ConstTensor> cellLayerNormWeights;
604 flatbuffers::Offset<serializer::ConstTensor> outputLayerNormWeights;
637 auto fbLstmParams = serializer::CreateLstmInputParams(
639 inputToForgetWeights,
641 inputToOutputWeights,
642 recurrentToForgetWeights,
643 recurrentToCellWeights,
644 recurrentToOutputWeights,
649 recurrentToInputWeights,
656 inputLayerNormWeights,
657 forgetLayerNormWeights,
658 cellLayerNormWeights,
659 outputLayerNormWeights);
661 auto fbLstmLayer = serializer::CreateLstmLayer(
667 CreateAnyLayer(fbLstmLayer.o, serializer::Layer::Layer_LstmLayer);
672 boost::ignore_unused(name);
674 auto fbMaximumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Maximum);
675 auto fbMaximumLayer = serializer::CreateMaximumLayer(m_flatBufferBuilder, fbMaximumBaseLayer);
677 CreateAnyLayer(fbMaximumLayer.o, serializer::Layer::Layer_MaximumLayer);
684 boost::ignore_unused(name);
686 auto fbMeanBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Mean);
687 auto fbMeanDescriptor = serializer::CreateMeanDescriptor(m_flatBufferBuilder,
688 m_flatBufferBuilder.CreateVector(descriptor.
m_Axis),
691 auto fbMeanLayer = serializer::CreateMeanLayer(m_flatBufferBuilder,
695 CreateAnyLayer(fbMeanLayer.o, serializer::Layer::Layer_MeanLayer);
700 boost::ignore_unused(name);
702 auto fbMinimumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Minimum);
703 auto fbMinimumLayer = serializer::CreateMinimumLayer(m_flatBufferBuilder, fbMinimumBaseLayer);
705 CreateAnyLayer(fbMinimumLayer.o, serializer::Layer::Layer_MinimumLayer);
710 boost::ignore_unused(name);
712 auto fbMergeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Merge);
713 auto fbMergeLayer = serializer::CreateMergeLayer(m_flatBufferBuilder, fbMergeBaseLayer);
715 CreateAnyLayer(fbMergeLayer.o, serializer::Layer::Layer_MergeLayer);
722 VisitConcatLayer(layer, mergerDescriptor, name);
729 boost::ignore_unused(name);
731 auto flatBufferConcatBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Concat);
733 std::vector<flatbuffers::Offset<UintVector>> views;
734 for (
unsigned int v = 0; v < concatDescriptor.
GetNumViews(); ++v)
737 std::vector<uint32_t> origins;
740 origins.push_back(origin[d]);
742 auto view = m_flatBufferBuilder.CreateVector(origins);
743 auto uintVector = CreateUintVector(m_flatBufferBuilder, view);
744 views.push_back(uintVector);
747 auto flatBufferConcatDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
751 m_flatBufferBuilder.CreateVector(views));
753 auto flatBufferLayer = CreateConcatLayer(m_flatBufferBuilder,
754 flatBufferConcatBaseLayer,
755 flatBufferConcatDescriptor);
757 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ConcatLayer);
762 boost::ignore_unused(name);
764 auto fbMultiplicationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Multiplication);
765 auto fbMultiplicationLayer = serializer::CreateMultiplicationLayer(m_flatBufferBuilder,
766 fbMultiplicationBaseLayer);
768 CreateAnyLayer(fbMultiplicationLayer.o, serializer::Layer::Layer_MultiplicationLayer);
775 boost::ignore_unused(name);
777 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pad);
779 std::vector<unsigned int> padList;
782 padList.push_back(p.first);
783 padList.push_back(p.second);
786 auto flatBufferPadDesc = serializer::CreatePadDescriptor(m_flatBufferBuilder,
787 m_flatBufferBuilder.CreateVector(padList),
790 auto flatBufferPadLayer = serializer::CreatePadLayer(m_flatBufferBuilder,
794 CreateAnyLayer(flatBufferPadLayer.o, serializer::Layer::Layer_PadLayer);
801 boost::ignore_unused(name);
804 auto flatBufferPermuteBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Permute);
806 std::vector<unsigned int> dimMappings;
812 auto flatBufferPermuteDesc = serializer::CreatePermuteDescriptor(m_flatBufferBuilder,
813 m_flatBufferBuilder.CreateVector(dimMappings));
816 auto flatBufferPermuteLayer = serializer::CreatePermuteLayer(m_flatBufferBuilder,
817 flatBufferPermuteBaseLayer,
818 flatBufferPermuteDesc);
821 CreateAnyLayer(flatBufferPermuteLayer.o, serializer::Layer::Layer_PermuteLayer);
829 boost::ignore_unused(name);
832 auto flatBufferReshapeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Reshape);
834 std::vector<unsigned int> targetShape;
840 auto flatBufferReshapeDesc = serializer::CreateReshapeDescriptor(m_flatBufferBuilder,
841 m_flatBufferBuilder.CreateVector(targetShape));
844 auto flatBufferReshapeLayer = serializer::CreateReshapeLayer(m_flatBufferBuilder, flatBufferReshapeBaseLayer,
845 flatBufferReshapeDesc);
848 CreateAnyLayer(flatBufferReshapeLayer.o, serializer::Layer::Layer_ReshapeLayer);
855 boost::ignore_unused(name);
857 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ResizeBilinear);
859 auto flatBufferDescriptor =
860 CreateResizeBilinearDescriptor(m_flatBufferBuilder,
865 auto flatBufferLayer = serializer::CreateResizeBilinearLayer(m_flatBufferBuilder,
867 flatBufferDescriptor);
869 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeBilinearLayer);
876 boost::ignore_unused(name);
878 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Resize);
880 auto flatBufferDescriptor =
881 CreateResizeDescriptor(m_flatBufferBuilder,
887 auto flatBufferLayer = serializer::CreateResizeLayer(m_flatBufferBuilder,
889 flatBufferDescriptor);
891 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeLayer);
896 boost::ignore_unused(name);
898 auto fbRsqrtBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Rsqrt);
899 auto fbRsqrtLayer = serializer::CreateRsqrtLayer(m_flatBufferBuilder, fbRsqrtBaseLayer);
901 CreateAnyLayer(fbRsqrtLayer.o, serializer::Layer::Layer_RsqrtLayer);
908 boost::ignore_unused(name);
910 auto fbSliceBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Slice);
911 auto fbSliceDescriptor = CreateSliceDescriptor(m_flatBufferBuilder,
912 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Begin),
913 m_flatBufferBuilder.CreateVector(sliceDescriptor.
m_Size));
915 auto fbSliceLayer = serializer::CreateSliceLayer(m_flatBufferBuilder, fbSliceBaseLayer, fbSliceDescriptor);
917 CreateAnyLayer(fbSliceLayer.o, serializer::Layer::Layer_SliceLayer);
925 boost::ignore_unused(name);
928 auto flatBufferSoftmaxBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Softmax);
931 auto flatBufferSoftmaxDesc =
932 serializer::CreateSoftmaxDescriptor(m_flatBufferBuilder, softmaxDescriptor.
m_Beta);
935 auto flatBufferSoftmaxLayer =
936 serializer::CreateSoftmaxLayer(m_flatBufferBuilder,
937 flatBufferSoftmaxBaseLayer,
938 flatBufferSoftmaxDesc);
940 CreateAnyLayer(flatBufferSoftmaxLayer.o, serializer::Layer::Layer_SoftmaxLayer);
947 boost::ignore_unused(name);
949 auto fbPooling2dBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Pooling2d);
950 auto fbPooling2dDescriptor = serializer::CreatePooling2dDescriptor(
965 auto fbPooling2dLayer = serializer::CreatePooling2dLayer(m_flatBufferBuilder,
966 fbPooling2dBaseLayer,
967 fbPooling2dDescriptor);
969 CreateAnyLayer(fbPooling2dLayer.o, serializer::Layer::Layer_Pooling2dLayer);
975 boost::ignore_unused(name);
978 auto flatBufferPreluBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Prelu);
981 auto flatBufferPreluLayer = serializer::CreatePreluLayer(m_flatBufferBuilder, flatBufferPreluBaseLayer);
984 CreateAnyLayer(flatBufferPreluLayer.o, serializer::Layer::Layer_PreluLayer);
989 boost::ignore_unused(name);
991 auto fbQuantizeBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Quantize);
992 auto fbQuantizeLayer = serializer::CreateQuantizeLayer(m_flatBufferBuilder,
993 fbQuantizeBaseLayer);
994 CreateAnyLayer(fbQuantizeLayer.o, serializer::Layer::Layer_QuantizeLayer);
1004 boost::ignore_unused(name);
1007 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_FullyConnected);
1010 auto flatBufferDescriptor =
1011 serializer::CreateFullyConnectedDescriptor(m_flatBufferBuilder,
1016 auto flatBufferWeights = CreateConstTensorInfo(weights);
1019 flatbuffers::Offset<serializer::ConstTensor> flatBufferBiases;
1022 flatBufferBiases = CreateConstTensorInfo(biases.
value());
1026 auto flatBufferLayer = serializer::CreateFullyConnectedLayer(m_flatBufferBuilder,
1027 flatBufferBaseLayer,
1028 flatBufferDescriptor,
1033 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_FullyConnectedLayer);
1041 boost::ignore_unused(name);
1044 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToBatchNd);
1046 std::vector<unsigned int> padList;
1047 padList.reserve(spaceToBatchNdDescriptor.
m_PadList.size()*2);
1048 for (
auto& pad : spaceToBatchNdDescriptor.
m_PadList)
1050 padList.push_back(pad.first);
1051 padList.push_back(pad.second);
1054 auto flatBufferDescriptor =
1055 CreateSpaceToBatchNdDescriptor(m_flatBufferBuilder,
1056 m_flatBufferBuilder.CreateVector(spaceToBatchNdDescriptor.
m_BlockShape),
1057 m_flatBufferBuilder.CreateVector(padList),
1060 auto flatBufferLayer = serializer::CreateSpaceToBatchNdLayer(m_flatBufferBuilder,
1061 flatBufferBaseLayer,
1062 flatBufferDescriptor);
1064 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToBatchNdLayer);
1072 boost::ignore_unused(name);
1074 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_SpaceToDepth);
1075 auto flatBufferDescriptor =
1076 CreateSpaceToDepthDescriptor(m_flatBufferBuilder,
1080 auto flatBufferLayer = serializer::CreateSpaceToDepthLayer(m_flatBufferBuilder,
1081 flatBufferBaseLayer,
1082 flatBufferDescriptor);
1084 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_SpaceToDepthLayer);
1092 boost::ignore_unused(name);
1095 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewOrigins;
1096 flatBufferViewOrigins.reserve(viewsDescriptor.
GetNumViews());
1098 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1100 std::vector<uint32_t> viewOrigin;
1104 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1106 viewOrigin.push_back(viewsDescriptor.
GetViewOrigin(vIdx)[dIdx]);
1109 flatBufferViewOrigins.push_back(CreateUintVector(m_flatBufferBuilder,
1110 m_flatBufferBuilder.CreateVector(viewOrigin)));
1114 auto flatBufferOriginDescriptor = CreateOriginsDescriptor(m_flatBufferBuilder,
1118 m_flatBufferBuilder.CreateVector(flatBufferViewOrigins));
1121 std::vector<flatbuffers::Offset<UintVector>> flatBufferViewSizes;
1122 flatBufferViewSizes.reserve(viewsDescriptor.
GetNumViews());
1124 for(
unsigned int vIdx = 0; vIdx < viewsDescriptor.
GetNumViews(); ++vIdx)
1126 std::vector<uint32_t> viewSize;
1130 for(
unsigned int dIdx = 0; dIdx < viewsDescriptor.
GetNumDimensions(); ++dIdx)
1132 viewSize.push_back(viewsDescriptor.
GetViewSizes(vIdx)[dIdx]);
1135 flatBufferViewSizes.push_back(CreateUintVector(m_flatBufferBuilder,
1136 m_flatBufferBuilder.CreateVector(viewSize)));
1140 auto flatBufferViewsDescriptor = CreateViewsDescriptor(m_flatBufferBuilder,
1141 flatBufferOriginDescriptor,
1142 m_flatBufferBuilder.CreateVector(flatBufferViewSizes));
1145 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Splitter);
1147 auto flatBufferSplitterLayer = serializer::CreateSplitterLayer(m_flatBufferBuilder,
1148 flatBufferBaseLayer,
1149 flatBufferViewsDescriptor);
1151 CreateAnyLayer(flatBufferSplitterLayer.o, serializer::Layer::Layer_SplitterLayer);
1158 boost::ignore_unused(name);
1160 auto fbNormalizationBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Normalization);
1162 auto fbNormalizationDescriptor = serializer::CreateNormalizationDescriptor(
1163 m_flatBufferBuilder,
1172 auto flatBufferLayer = serializer::CreateNormalizationLayer(m_flatBufferBuilder,
1173 fbNormalizationBaseLayer,
1174 fbNormalizationDescriptor);
1176 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_NormalizationLayer);
1183 boost::ignore_unused(name);
1185 auto stackBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Stack);
1187 std::vector<unsigned int> inputShape;
1193 auto flatBufferStackDescriptor = CreateStackDescriptor(m_flatBufferBuilder,
1196 m_flatBufferBuilder.CreateVector(inputShape));
1198 auto stackLayer = serializer::CreateStackLayer(m_flatBufferBuilder, stackBaseLayer, flatBufferStackDescriptor);
1199 CreateAnyLayer(stackLayer.o, serializer::Layer::Layer_StackLayer);
1206 boost::ignore_unused(name);
1208 auto fbDescriptor = serializer::CreateStandInDescriptor(m_flatBufferBuilder,
1212 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StandIn);
1213 auto fbLayer = serializer::CreateStandInLayer(m_flatBufferBuilder, fbBaseLayer, fbDescriptor);
1215 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_StandInLayer);
1222 boost::ignore_unused(name);
1224 auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_StridedSlice);
1226 auto flatBufferDescriptor =
1227 CreateStridedSliceDescriptor(m_flatBufferBuilder,
1228 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Begin),
1229 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_End),
1230 m_flatBufferBuilder.CreateVector(stridedSliceDescriptor.
m_Stride),
1238 auto flatBufferLayer = serializer::CreateStridedSliceLayer(m_flatBufferBuilder,
1239 flatBufferBaseLayer,
1240 flatBufferDescriptor);
1242 CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_StridedSliceLayer);
1247 boost::ignore_unused(name);
1249 auto fbSubtractionBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Subtraction);
1250 auto fbSubtractionLayer = serializer::CreateSubtractionLayer(m_flatBufferBuilder, fbSubtractionBaseLayer);
1252 CreateAnyLayer(fbSubtractionLayer.o, serializer::Layer::Layer_SubtractionLayer);
1257 boost::ignore_unused(name);
1259 auto fbSwitchBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Switch);
1260 auto fbSwitchLayer = serializer::CreateSwitchLayer(m_flatBufferBuilder, fbSwitchBaseLayer);
1262 CreateAnyLayer(fbSwitchLayer.o, serializer::Layer::Layer_SwitchLayer);
1265 void SerializerVisitor::VisitTransposeConvolution2dLayer(
1272 boost::ignore_unused(name);
1274 auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Convolution2d);
1275 auto fbDescriptor = CreateTransposeConvolution2dDescriptor(m_flatBufferBuilder,
1286 auto fbWeightsConstTensorInfo = CreateConstTensorInfo(weights);
1287 flatbuffers::Offset<serializer::ConstTensor> fbBiasesConstTensorInfo;
1290 fbBiasesConstTensorInfo = CreateConstTensorInfo(biases.
value());
1293 auto fbLayer = CreateTransposeConvolution2dLayer(m_flatBufferBuilder,
1296 fbWeightsConstTensorInfo,
1297 fbBiasesConstTensorInfo);
1299 CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_TransposeConvolution2dLayer);
1306 boost::ignore_unused(name);
1308 auto fbQuantizedLstmBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_QuantizedLstm);
1323 auto cellBias = CreateConstTensorInfo(params.
GetCellBias());
1326 auto fbQuantizedLstmParams = serializer::CreateQuantizedLstmInputParams(
1327 m_flatBufferBuilder,
1328 inputToInputWeights,
1329 inputToForgetWeights,
1331 inputToOutputWeights,
1332 recurrentToInputWeights,
1333 recurrentToForgetWeights,
1334 recurrentToCellWeights,
1335 recurrentToOutputWeights,
1341 auto fbQuantizedLstmLayer = serializer::CreateQuantizedLstmLayer(
1342 m_flatBufferBuilder,
1343 fbQuantizedLstmBaseLayer,
1344 fbQuantizedLstmParams);
1346 CreateAnyLayer(fbQuantizedLstmLayer.o, serializer::Layer::Layer_QuantizedLstmLayer);
1349 fb::Offset<serializer::LayerBase> SerializerVisitor::CreateLayerBase(
const IConnectableLayer* layer,
1353 uint32_t fbIndex = GetSerializedId(layer->
GetGuid());
1355 std::vector<fb::Offset<serializer::InputSlot>> inputSlots = CreateInputSlots(layer);
1356 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots = CreateOutputSlots(layer);
1358 return serializer::CreateLayerBase(m_flatBufferBuilder,
1360 m_flatBufferBuilder.CreateString(layer->
GetName()),
1362 m_flatBufferBuilder.CreateVector(inputSlots),
1363 m_flatBufferBuilder.CreateVector(outputSlots));
1366 void SerializerVisitor::CreateAnyLayer(
const flatbuffers::Offset<void>& layer,
const serializer::Layer serializerLayer)
1369 auto anyLayer = armnnSerializer::CreateAnyLayer(m_flatBufferBuilder, serializerLayer, layer);
1370 m_serializedLayers.push_back(anyLayer);
1373 template <
typename T>
1374 flatbuffers::Offset<flatbuffers::Vector<T>> SerializerVisitor::CreateDataVector(
const void* memory,
unsigned int size)
1376 const T* buffer =
reinterpret_cast<const T*
>(memory);
1377 std::vector<T> vector(buffer, buffer + (size /
sizeof(T)));
1378 auto fbVector = m_flatBufferBuilder.CreateVector(vector);
1382 flatbuffers::Offset<serializer::ConstTensor>
1388 std::vector<unsigned int> shape;
1392 shape.push_back(tensorInfo.
GetShape()[dim]);
1396 auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder,
1397 m_flatBufferBuilder.CreateVector(shape),
1401 flatbuffers::Offset<void> fbPayload;
1409 flatbuffers::Offset<serializer::IntData> flatBuffersData = serializer::CreateIntData(
1410 m_flatBufferBuilder,
1412 fbPayload = flatBuffersData.o;
1418 flatbuffers::Offset<serializer::ShortData> flatBuffersData = serializer::CreateShortData(
1419 m_flatBufferBuilder,
1421 fbPayload = flatBuffersData.o;
1427 flatbuffers::Offset<serializer::ShortData> flatBuffersData = serializer::CreateShortData(
1428 m_flatBufferBuilder,
1430 fbPayload = flatBuffersData.o;
1438 flatbuffers::Offset<serializer::ByteData> flatBuffersData = serializer::CreateByteData(
1439 m_flatBufferBuilder,
1441 fbPayload = flatBuffersData.o;
1444 flatbuffers::Offset<serializer::ConstTensor> flatBufferConstTensor = serializer::CreateConstTensor(
1445 m_flatBufferBuilder,
1446 flatBufferTensorInfo,
1449 return flatBufferConstTensor;
1452 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> SerializerVisitor::GetVersionTable()
1454 flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> versionsTable =
1455 serializer::CreateFeatureCompatibilityVersions(
1456 m_flatBufferBuilder,
1459 return versionsTable;
1462 std::vector<fb::Offset<serializer::InputSlot>>
1465 std::vector<fb::Offset<serializer::InputSlot>> inputSlots;
1468 for (
unsigned int slotIndex = 0; slotIndex<layer->
GetNumInputSlots(); ++slotIndex)
1479 inputSlots.push_back(serializer::CreateInputSlot(m_flatBufferBuilder, slotIndex, &conn));
1484 std::vector<fb::Offset<serializer::OutputSlot>>
1487 std::vector<fb::Offset<serializer::OutputSlot>> outputSlots;
1490 for (
unsigned int slotIndex = 0; slotIndex < layer->
GetNumOutputSlots(); ++slotIndex)
1496 std::vector<unsigned int> shape;
1499 shape.push_back(tensorInfo.
GetShape()[dim]);
1503 auto flatBufferTensorInfo = serializer::CreateTensorInfo(m_flatBufferBuilder,
1504 m_flatBufferBuilder.CreateVector(shape),
1510 outputSlots.push_back(serializer::CreateOutputSlot(m_flatBufferBuilder,
1512 flatBufferTensorInfo));
1536 inNetwork.
Accept(m_SerializerVisitor);
1537 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerVisitor.GetFlatBufferBuilder();
1540 auto serializedGraph = serializer::CreateSerializedGraph(
1542 fbBuilder.CreateVector(m_SerializerVisitor.GetSerializedLayers()),
1543 fbBuilder.CreateVector(m_SerializerVisitor.GetInputIds()),
1544 fbBuilder.CreateVector(m_SerializerVisitor.GetOutputIds()),
1545 m_SerializerVisitor.GetVersionTable());
1548 fbBuilder.Finish(serializedGraph);
1551 bool Serializer::SaveSerializedToStream(std::ostream& stream)
1553 flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerVisitor.GetFlatBufferBuilder();
1555 auto bytesToWrite = boost::numeric_cast<std::streamsize>(fbBuilder.GetSize());
1556 stream.write(reinterpret_cast<const char*>(fbBuilder.GetBufferPointer()), bytesToWrite);
1557 return !stream.bad();
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH).
bool m_ProjectionEnabled
Enable/disable the projection layer.
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).
virtual LayerGuid GetGuid() const =0
float m_ScaleX
Center size encoding scale x.
const OriginsDescriptor & GetOrigins() const
Get the View Origins.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int GetNumBytes() const
uint32_t m_PadBottom
Padding bottom value in the height dimension.
UnaryOperation m_Operation
Specifies the elementwiseUnary operation to execute.
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
uint32_t m_Axis
0-based axis along which to stack the input tensors.
int32_t GetQuantizationOffset() const
unsigned int GetNumDimensions() const
uint32_t m_PadRight
Padding right value in the width dimension.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
uint32_t m_NumClasses
Number of classes.
uint32_t m_DilationX
Dilation factor value for width dimension.
A NormalizationDescriptor for the NormalizationLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
armnnSerializer::OutputShapeRounding GetFlatBufferOutputShapeRounding(armnn::OutputShapeRounding outputShapeRounding)
virtual const TensorInfo & GetTensorInfo() const =0
float m_Alpha
Alpha value for the normalization equation.
float m_ScaleW
Center size encoding scale weight.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_NumOutputs
Number of output tensors.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
float m_ClippingThresCell
Clipping threshold value for the cell state.
uint32_t m_PadLeft
Padding left value in the width dimension.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
armnnSerializer::ConstTensorData GetFlatBufferConstTensorData(armnn::DataType dataType)
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_TargetHeight
Target height value.
int32_t m_NewAxisMask
New axis mask value. If set, the begin, end and stride is disregarded and a new 1 dimension is insert...
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0. ...
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
serializer::ArgMinMaxFunction GetFlatBufferArgMinMaxFunction(armnn::ArgMinMaxFunction function)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadTop
Padding top value in the height dimension.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
A PadDescriptor for the PadLayer.
TensorShape m_InputShape
Required shape of all input tensors.
An ActivationDescriptor for the ActivationLayer.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_ScaleY
Center size encoding scale y.
std::vector< int > m_Begin
Begin values for the input that will be sliced.
uint32_t m_TargetWidth
Target width value.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< unsigned int > m_BlockShape
Block shape value.
bool m_KeepDims
Enable/disable keep dimensions. If true, then the reduced dimensions that are of length 1 are kept...
uint32_t m_PadTop
Padding top value in the height dimension.
std::unique_ptr< ISerializer, void(*)(ISerializer *serializer)> ISerializerPtr
A L2NormalizationDescriptor for the L2NormalizationLayer.
bool m_BiasEnabled
Enable/disable bias.
A ViewsDescriptor for the SplitterLayer. Descriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
virtual LayerGuid GetOwningLayerGuid() const =0
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
armnnSerializer::PaddingMethod GetFlatBufferPaddingMethod(armnn::PaddingMethod paddingMethod)
virtual const char * GetName() const =0
float m_Beta
Exponentiation value.
float m_Beta
Beta, the offset scalar value applied for the normalized tensor. Defaults to 1.0. ...
bool m_UseRegularNms
Use Regular NMS.
A ReshapeDescriptor for the ReshapeLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
TensorShape m_TargetShape
Target shape value.
uint32_t m_PadLeft
Padding left value in the width dimension.
int m_Axis
Axis to reduce across the input tensor.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
armnnSerializer::PoolingAlgorithm GetFlatBufferPoolingAlgorithm(armnn::PoolingAlgorithm poolingAlgorithm)
uint32_t m_PoolWidth
Pooling width value.
bool m_PeepholeEnabled
Enable/disable peephole.
uint32_t m_NumInputs
Number of input tensors.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t GetNumDimensions() const
Get the number of dimensions.
float m_NmsIouThreshold
Intersection over union threshold.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
uint32_t m_NormSize
Depth radius value.
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
const uint32_t * GetViewOrigin(uint32_t idx) const
Return the view origin at the int value idx.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
uint32_t GetNumViews() const
Get the number of views.
An LstmDescriptor for the LstmLayer.
std::vector< int > m_End
End values for the input that will be sliced.
uint32_t GetNumDimensions() const
Get the number of dimensions.
unsigned int GetConcatAxis() const
Get the concatenation axis value.
virtual unsigned int GetNumOutputSlots() const =0
uint32_t m_PadLeft
Padding left value in the width dimension.
float m_Beta
Beta value for the normalization equation.
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
float m_NmsScoreThreshold
NMS score threshold.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
armnnSerializer::ResizeMethod GetFlatBufferResizeMethod(armnn::ResizeMethod method)
float m_Eps
Epsilon, small scalar value added to variance to avoid dividing by zero. Defaults to 1e-12f...
uint32_t m_PadRight
Padding right value in the width dimension.
bool m_BiasEnabled
Enable/disable bias.
armnnSerializer::NormalizationAlgorithmChannel GetFlatBufferNormalizationAlgorithmChannel(armnn::NormalizationAlgorithmChannel normalizationAlgorithmChannel)
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. {0U, 3U, 1U, 2U}.
virtual void Accept(ILayerVisitor &visitor) const =0
const TensorInfo & GetInfo() const
int32_t m_EllipsisMask
Ellipsis mask value.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
A StackDescriptor for the StackLayer.
int32_t m_BeginMask
Begin mask value. If set, then the begin is disregarded and the fullest range is used for the dimensi...
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
float m_PadValue
Optional value to use for padding, defaults to 0.
uint32_t m_NumInputs
Number of input tensors.
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square).
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
A SoftmaxDescriptor for the SoftmaxLayer.
An output connection slot for a layer. The output slot may be connected to 1 or more input slots of s...
uint32_t m_TargetWidth
Target width value.
armnnSerializer::ComparisonOperation GetFlatBufferComparisonOperation(armnn::ComparisonOperation comparisonOperation)
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
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.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
ComparisonOperation m_Operation
Specifies the comparison operation to execute.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension. First is the number of values to add before the tensor in ...
armnnSerializer::DataType GetFlatBufferDataType(armnn::DataType dataType)
bool m_BiasEnabled
Enable/disable bias.
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
float m_K
Kappa value used for the across channel normalization equation.
std::vector< float > anchors({ 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 100.5f, 1.0f, 1.0f })
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
DataType GetDataType() const
MemoryType GetMemoryArea() const
A Pooling2dDescriptor for the Pooling2dLayer.
uint32_t m_ActivationFunc
The activation function to use. 0: None, 1: Relu, 3: Relu6, 4: Tanh, 6: Sigmoid.
virtual unsigned int GetNumInputSlots() const =0
uint32_t m_DilationY
Dilation along y axis.
A StandInDescriptor for the StandIn layer.
serializer::ActivationFunction GetFlatBufferActivationFunction(armnn::ActivationFunction function)
A SliceDescriptor for the SliceLayer.
bool m_LayerNormEnabled
Enable/disable layer normalization.
bool m_BiasEnabled
Enable/disable bias.
virtual unsigned int CalculateIndexOnOwner() const =0
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
A PermuteDescriptor for the PermuteLayer.
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t m_TargetHeight
Target height value.
A MeanDescriptor for the MeanLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationX
Dilation along x axis.
armnnSerializer::DataLayout GetFlatBufferDataLayout(armnn::DataLayout dataLayout)
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
std::vector< std::pair< unsigned int, unsigned int > > m_Crops
The values to crop from the input dimension.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
const TensorShape & GetShape() const
armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperation comparisonOperation)
float m_ClippingThresProj
Clipping threshold value for the projection.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
An ArgMinMaxDescriptor for ArgMinMaxLayer.
bool has_value() const noexcept
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
float m_ScaleH
Center size encoding scale height.
int32_t m_EndMask
End mask value. If set, then the end is disregarded and the fullest range is used for the dimension...
A ResizeDescriptor for the ResizeLayer.
armnnSerializer::NormalizationAlgorithmMethod GetFlatBufferNormalizationAlgorithmMethod(armnn::NormalizationAlgorithmMethod normalizationAlgorithmMethod)
float m_Eps
Used to avoid dividing by zero.
A ComparisonDescriptor for the ComparisonLayer.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
std::vector< unsigned int > m_BlockShape
Block shape values.
uint32_t GetNumViews() const
Get the number of views.
float GetQuantizationScale() const
An OriginsDescriptor for the ConcatLayer. Descriptor to configure the concatenation process...
uint32_t m_DilationY
Dilation factor value for height dimension.
uint32_t m_MaxDetections
Maximum numbers of detections.
A StridedSliceDescriptor for the StridedSliceLayer.
uint32_t m_PadRight
Padding right value in the width dimension.