21 #include <doctest/doctest.h> 25 using namespace armnn;
33 template<
typename Workload>
34 std::unique_ptr<Workload> MakeAndCheckWorkload(
Layer& layer,
38 std::unique_ptr<IWorkload> workload = layer.
CreateWorkload(factory);
39 CHECK_MESSAGE(workload.get() == PolymorphicDowncast<Workload*>(workload.get()),
40 "Cannot convert to derived class");
41 std::string reasonIfUnsupported;
44 return std::unique_ptr<Workload>(
static_cast<Workload*
>(workload.release()));
65 template <
typename ActivationWorkload, armnn::DataType DataType>
73 layerDesc.
m_B = -10.0f;
84 Connect(input, layer, tensorInfo);
85 Connect(layer, output, tensorInfo);
87 CreateTensorHandles(graph, factory);
90 auto workload = MakeAndCheckWorkload<ActivationWorkload>(*layer, factory);
93 CHECK(queueDescriptor.m_Inputs.size() == 1);
94 CHECK(queueDescriptor.m_Outputs.size() == 1);
95 CHECK(queueDescriptor.m_Parameters.m_A == 3.5f);
96 CHECK(queueDescriptor.m_Parameters.m_B == -10.0f);
103 template <
typename WorkloadType,
104 typename DescriptorType,
120 Connect(input1, layer, tensorInfo, 0, 0);
121 Connect(input2, layer, tensorInfo, 0, 1);
122 Connect(layer, output, tensorInfo);
123 CreateTensorHandles(graph, factory);
126 auto workload = MakeAndCheckWorkload<WorkloadType>(*layer, factory);
128 DescriptorType queueDescriptor = workload->GetData();
129 CHECK(queueDescriptor.m_Inputs.size() == 2);
130 CHECK(queueDescriptor.m_Outputs.size() == 1);
136 template<
typename WorkloadType,
137 typename DescriptorType,
145 auto activationDesc = std::make_shared<ActivationDescriptor>();
146 activationDesc->m_A = 10.0f;
147 activationDesc->m_B = 5.0f;
159 Connect(input1, layer, tensorInfo, 0, 0);
160 Connect(input2, layer, tensorInfo, 0, 1);
161 Connect(layer, output, tensorInfo);
162 CreateTensorHandles(graph, factory);
165 std::shared_ptr<ActivationDescriptor>
168 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
169 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
175 auto workload = MakeAndCheckWorkload<WorkloadType>(*layer, factory);
177 DescriptorType queueDescriptor = workload->GetData();
180 queueDescriptor.template GetAdditionalInformation<ActivationDescriptor>();
188 CHECK(queueDescriptor.m_Inputs.size() == 2);
189 CHECK(queueDescriptor.m_Outputs.size() == 1);
194 template<
typename WorkloadType,
195 typename DescriptorType,
203 auto activationDesc = std::make_shared<ActivationDescriptor>();
204 activationDesc->m_A = 10.0f;
205 activationDesc->m_B = 5.0f;
217 Connect(input1, layer, tensorInfo, 0, 0);
218 Connect(input2, layer, tensorInfo, 0, 1);
219 Connect(layer, output, tensorInfo);
220 CreateTensorHandles(graph, factory);
223 std::shared_ptr<ActivationDescriptor>
226 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
227 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
233 auto workload = MakeAndCheckWorkload<WorkloadType>(*layer, factory);
235 DescriptorType queueDescriptor = workload->GetData();
236 CHECK(queueDescriptor.m_Inputs.size() == 2);
237 CHECK(queueDescriptor.m_Outputs.size() == 1);
239 queueDescriptor.template GetAdditionalInformation<ActivationDescriptor>();
241 ARMNN_ASSERT(static_cast<float>(queueDescBlobPtr->m_A) == 10.0f);
242 ARMNN_ASSERT(static_cast<float>(queueDescBlobPtr->m_B) == 5.0f);
250 template<
typename WorkloadType,
251 typename DescriptorType,
259 auto activationDesc = std::make_shared<ActivationDescriptor>();
260 activationDesc->m_A = 10.0f;
261 activationDesc->m_B = 5.0f;
273 Connect(input1, layer, tensorInfo, 0, 0);
274 Connect(input2, layer, tensorInfo, 0, 1);
275 Connect(layer, output, tensorInfo);
276 CreateTensorHandles(graph, factory);
279 std::shared_ptr<ActivationDescriptor>
280 activationDescPtr = layer->template GetAdditionalInformation<ActivationDescriptor>();
282 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
283 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
289 auto workload = MakeAndCheckWorkload<WorkloadType>(*layer, factory);
291 DescriptorType queueDescriptor = workload->GetData();
293 queueDescriptor.template GetAdditionalInformation<ActivationDescriptor>();
295 CHECK(queueDescriptor.m_Inputs.size() == 2);
296 CHECK(queueDescriptor.m_Outputs.size() == 1);
306 template <
typename WorkloadType,
307 typename DescriptorType,
320 Connect(input, layer, tensorInfo, 0, 0);
321 Connect(layer, output, tensorInfo, 0, 0);
322 CreateTensorHandles(graph, factory);
324 auto workload = MakeAndCheckWorkload<WorkloadType>(*layer, factory);
325 DescriptorType queueDescriptor = workload->GetData();
327 CHECK(queueDescriptor.m_Inputs.size() == 1);
328 CHECK(queueDescriptor.m_Outputs.size() == 1);
333 template <
typename BatchNormalizationWorkloadType, armnn::DataType DataType>
334 std::unique_ptr<BatchNormalizationWorkloadType> CreateBatchNormalizationWorkloadTest(
341 tensorShape = { 2, 4, 4, 3 };
345 tensorShape = { 2, 3, 4, 4 };
350 layerDesc.
m_Eps = 0.05f;
356 layer->
m_Mean = std::make_unique<ScopedTensorHandle>(weightInfo);
357 layer->
m_Variance = std::make_unique<ScopedTensorHandle>(weightInfo);
358 layer->
m_Beta = std::make_unique<ScopedTensorHandle>(weightInfo);
359 layer->
m_Gamma = std::make_unique<ScopedTensorHandle>(weightInfo);
360 layer->
m_Mean->Allocate();
362 layer->
m_Beta->Allocate();
371 Connect(input, layer, tensorInfo);
372 Connect(layer, output, tensorInfo);
373 CreateTensorHandles(graph, factory);
376 auto workload = MakeAndCheckWorkload<BatchNormalizationWorkloadType>(*layer, factory);
378 CHECK(queueDescriptor.m_Parameters.m_Eps == 0.05f);
379 CHECK(queueDescriptor.m_Inputs.size() == 1);
380 CHECK(queueDescriptor.m_Outputs.size() == 1);
385 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
391 template <
typename BatchNormalizationWorkloadType, armnn::DataType DataType>
392 std::unique_ptr<BatchNormalizationWorkloadType> CreateBatchNormalizationWithBlobWorkloadTest(
399 tensorShape = { 2, 4, 4, 3 };
403 tensorShape = { 2, 3, 4, 4 };
408 layerDesc.
m_Eps = 0.05f;
414 layer->
m_Mean = std::make_unique<ScopedTensorHandle>(weightInfo);
415 layer->
m_Variance = std::make_unique<ScopedTensorHandle>(weightInfo);
416 layer->
m_Beta = std::make_unique<ScopedTensorHandle>(weightInfo);
417 layer->
m_Gamma = std::make_unique<ScopedTensorHandle>(weightInfo);
418 layer->
m_Mean->Allocate();
420 layer->
m_Beta->Allocate();
423 auto activationDesc = std::make_shared<ActivationDescriptor>();
424 activationDesc->m_A = 10.0f;
425 activationDesc->m_B = 5.0f;
432 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
433 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
444 Connect(input, layer, tensorInfo);
445 Connect(layer, output, tensorInfo);
446 CreateTensorHandles(graph, factory);
449 auto workload = MakeAndCheckWorkload<BatchNormalizationWorkloadType>(*layer, factory);
459 CHECK(queueDescriptor.m_Parameters.m_Eps == 0.05f);
460 CHECK(queueDescriptor.m_Inputs.size() == 1);
461 CHECK(queueDescriptor.m_Outputs.size() == 1);
466 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
472 template <
typename Convolution2dWorkload, armnn::DataType DataType>
499 layer->
m_Bias->Allocate();
508 CreateTensorHandles(graph, factory);
511 auto workload = MakeAndCheckWorkload<Convolution2dWorkload>(*layer, factory, modelOptions);
514 CHECK(queueDescriptor.m_Parameters.m_StrideX == 2);
515 CHECK(queueDescriptor.m_Parameters.m_StrideY == 4);
516 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 3);
517 CHECK(queueDescriptor.m_Parameters.m_PadRight == 3);
518 CHECK(queueDescriptor.m_Parameters.m_PadTop == 1);
519 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 1);
520 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled);
521 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
523 CHECK(queueDescriptor.m_Inputs.size() == 1);
524 CHECK(queueDescriptor.m_Outputs.size() == 1);
525 CHECK((queueDescriptor.m_Weight->GetTensorInfo() ==
TensorInfo(weightShape,
DataType)));
526 CHECK((queueDescriptor.m_Bias->GetTensorInfo() ==
533 template<
typename Convolution2dWorkload, armnn::DataType DataType>
534 std::unique_ptr<Convolution2dWorkload> CreateConvolution2dFusedActivationWithBlobWorkloadTest(
562 layer->
m_Bias->Allocate();
564 auto activationDesc = std::make_shared<ActivationDescriptor>();
565 activationDesc->m_A = 10.0f;
566 activationDesc->m_B = 5.0f;
574 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
575 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
587 CreateTensorHandles(graph, factory);
590 auto workload = MakeAndCheckWorkload<Convolution2dWorkload>(*layer, factory, modelOptions);
601 CHECK(queueDescriptor.m_Parameters.m_StrideX == 2);
602 CHECK(queueDescriptor.m_Parameters.m_StrideY == 4);
603 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 3);
604 CHECK(queueDescriptor.m_Parameters.m_PadRight == 3);
605 CHECK(queueDescriptor.m_Parameters.m_PadTop == 1);
606 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 1);
607 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled);
608 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
609 CHECK(queueDescriptor.m_Outputs.size() == 1);
610 CHECK((queueDescriptor.m_Weight->GetTensorInfo() ==
TensorInfo(weightShape,
DataType)));
611 CHECK((queueDescriptor.m_Bias->GetTensorInfo() ==
613 CHECK(queueDescriptor.m_Inputs.size() == 1);
619 template <
typename Convolution2dWorkload, armnn::DataType DataType>
620 std::unique_ptr<Convolution2dWorkload> CreateConvolution2dWorkloadFastMathTest(
armnn::IWorkloadFactory& factory,
646 layer->
m_Bias->Allocate();
655 CreateTensorHandles(graph, factory);
658 auto workload = MakeAndCheckWorkload<Convolution2dWorkload>(*layer, factory, modelOptions);
661 CHECK(queueDescriptor.m_Parameters.m_StrideX == 1);
662 CHECK(queueDescriptor.m_Parameters.m_StrideY == 1);
663 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 0);
664 CHECK(queueDescriptor.m_Parameters.m_PadRight == 0);
665 CHECK(queueDescriptor.m_Parameters.m_PadTop == 0);
666 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 0);
667 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
669 CHECK(queueDescriptor.m_Inputs.size() == 1);
670 CHECK(queueDescriptor.m_Outputs.size() == 1);
671 CHECK((queueDescriptor.m_Weight->GetTensorInfo() ==
TensorInfo(weightShape,
DataType)));
677 template <
typename LstmWorkload>
690 unsigned int batchSize = 2;
691 unsigned int inputSize = 2;
692 unsigned int numUnits = 4;
693 unsigned int outputSize = 4;
725 if (layerDesc.m_PeepholeEnabled)
748 armnn::TensorInfo lstmTensorInfoScratchBuff({ batchSize, numUnits * (layerDesc.m_CifgEnabled ? 3 : 4) },
750 Connect(input, layer, lstmTensorInfo1, 0, 0);
751 Connect(cellStateIn, layer, lstmTensorInfo2, 0, 1);
752 Connect(outputStateIn, layer, lstmTensorInfo3, 0, 2);
753 Connect(layer, scratchBuffer, lstmTensorInfoScratchBuff, 0, 0);
754 Connect(layer, outputStateOut, lstmTensorInfo3, 1, 0);
755 Connect(layer, cellStateOut, lstmTensorInfo2, 2, 0);
756 Connect(layer, output, lstmTensorInfo3, 3, 0);
758 CreateTensorHandles(graph, factory);
761 auto workload = MakeAndCheckWorkload<LstmWorkload>(*layer, factory);
763 CHECK(queueDescriptor.m_Parameters.m_ActivationFunc == 4);
764 CHECK(queueDescriptor.m_Parameters.m_ClippingThresCell == 0.0f);
765 CHECK(queueDescriptor.m_Parameters.m_ClippingThresProj == 0.0f);
766 CHECK(queueDescriptor.m_Inputs.size() == 3);
767 CHECK(queueDescriptor.m_Outputs.size() == 4);
769 CHECK((queueDescriptor.m_InputToForgetWeights->GetTensorInfo() ==
TensorInfo({ numUnits, inputSize },
771 CHECK((queueDescriptor.m_OutputGateBias->GetTensorInfo() ==
TensorInfo({ numUnits },
777 template <
typename QuantizedLstmWorkload>
782 unsigned int numBatches = 2;
783 unsigned int inputSize = 2;
784 unsigned int outputSize = 4;
787 float inputOutputScale = 0.0078125f;
788 int32_t inputOutputOffset = 128;
790 float cellStateScale = 0.00048828125f;
791 int32_t cellStateOffset = 0;
793 float weightsScale = 0.00408021f;
794 int32_t weightsOffset = 100;
796 float biasScale = 3.1876640625e-05f;
797 int32_t biasOffset = 0;
816 layer->m_QuantizedLstmParameters.m_InputToInputWeights =
817 std::make_unique<ScopedTensorHandle>(inputWeightsInfo);
818 layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
819 std::make_unique<ScopedTensorHandle>(inputWeightsInfo);
820 layer->m_QuantizedLstmParameters.m_InputToCellWeights =
821 std::make_unique<ScopedTensorHandle>(inputWeightsInfo);
822 layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
823 std::make_unique<ScopedTensorHandle>(inputWeightsInfo);
825 layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
826 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
827 layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
828 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
829 layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
830 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
831 layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
832 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
834 layer->m_QuantizedLstmParameters.m_InputGateBias = std::make_unique<ScopedTensorHandle>(biasInfo);
835 layer->m_QuantizedLstmParameters.m_ForgetGateBias = std::make_unique<ScopedTensorHandle>(biasInfo);
836 layer->m_QuantizedLstmParameters.m_CellBias = std::make_unique<ScopedTensorHandle>(biasInfo);
837 layer->m_QuantizedLstmParameters.m_OutputGateBias = std::make_unique<ScopedTensorHandle>(biasInfo);
840 layer->m_QuantizedLstmParameters.m_InputToInputWeights->Allocate();
841 layer->m_QuantizedLstmParameters.m_InputToForgetWeights->Allocate();
842 layer->m_QuantizedLstmParameters.m_InputToCellWeights->Allocate();
843 layer->m_QuantizedLstmParameters.m_InputToOutputWeights->Allocate();
845 layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights->Allocate();
846 layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights->Allocate();
847 layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights->Allocate();
848 layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights->Allocate();
850 layer->m_QuantizedLstmParameters.m_InputGateBias->Allocate();
851 layer->m_QuantizedLstmParameters.m_ForgetGateBias->Allocate();
852 layer->m_QuantizedLstmParameters.m_CellBias->Allocate();
853 layer->m_QuantizedLstmParameters.m_OutputGateBias->Allocate();
880 Connect(input, layer, inputInfo, 0, 0);
881 Connect(cellStateIn, layer, cellStateInfo, 0, 1);
882 Connect(outputStateIn, layer, outputStateInfo, 0, 2);
884 Connect(layer, cellStateOut, cellStateInfo, 0, 0);
885 Connect(layer, outputStateOut, outputStateInfo, 1, 0);
887 CreateTensorHandles(graph, factory);
890 auto workload = MakeAndCheckWorkload<QuantizedLstmWorkload>(*layer, factory);
894 CHECK(queueDescriptor.m_Inputs.size() == 3);
895 CHECK(queueDescriptor.m_Outputs.size() == 2);
898 CHECK((queueDescriptor.m_InputToInputWeights->GetTensorInfo() == inputWeightsInfo));
899 CHECK((queueDescriptor.m_InputToForgetWeights->GetTensorInfo() == inputWeightsInfo));
900 CHECK((queueDescriptor.m_InputToCellWeights->GetTensorInfo() == inputWeightsInfo));
901 CHECK((queueDescriptor.m_InputToOutputWeights->GetTensorInfo() == inputWeightsInfo));
903 CHECK((queueDescriptor.m_RecurrentToInputWeights->GetTensorInfo() == recurrentWeightsInfo));
904 CHECK((queueDescriptor.m_RecurrentToForgetWeights->GetTensorInfo() == recurrentWeightsInfo));
905 CHECK((queueDescriptor.m_RecurrentToCellWeights->GetTensorInfo() == recurrentWeightsInfo));
906 CHECK((queueDescriptor.m_RecurrentToOutputWeights->GetTensorInfo() == recurrentWeightsInfo));
908 CHECK((queueDescriptor.m_InputGateBias->GetTensorInfo() == biasInfo));
909 CHECK((queueDescriptor.m_ForgetGateBias->GetTensorInfo() == biasInfo));
910 CHECK((queueDescriptor.m_CellBias->GetTensorInfo() == biasInfo));
911 CHECK((queueDescriptor.m_OutputGateBias->GetTensorInfo() == biasInfo));
916 template <
typename QLstmWorkload>
939 unsigned int numBatches = 2;
940 unsigned int inputSize = 4;
941 unsigned int numUnits = 4;
942 unsigned int outputSize = 4;
945 float inputScale = 0.0078125f;
946 int32_t inputOffset = 0;
949 float outputScale = layerDesc.m_HiddenStateScale;
950 int32_t outputOffset = layerDesc.m_HiddenStateZeroPoint;
952 float cellStateScale = 3.05176e-05f;
953 int32_t cellStateOffset = 0;
955 float weightsScale = 0.00784314f;
956 int32_t weightsOffset = 0;
958 float layerNormScale = 3.05182e-05f;
959 int32_t layerNormOffset = 0;
961 float biasScale = layerNormScale / 1024;
962 int32_t biasOffset = 0;
985 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
987 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
989 std::make_unique<ScopedTensorHandle>(recurrentWeightsInfo);
996 std::make_unique<ScopedTensorHandle>(layerNormWeightsInfo);
998 std::make_unique<ScopedTensorHandle>(layerNormWeightsInfo);
1000 std::make_unique<ScopedTensorHandle>(layerNormWeightsInfo);
1044 Connect(input, layer, inputInfo, 0, 0);
1045 Connect(outputStateIn, layer, outputStateInfo, 0, 1);
1046 Connect(cellStateIn, layer, cellStateInfo, 0, 2);
1048 Connect(layer, outputStateOut, outputStateInfo, 0, 0);
1049 Connect(layer, cellStateOut, cellStateInfo, 1, 0);
1050 Connect(layer, output, outputStateInfo, 2, 0);
1052 CreateTensorHandles(graph, factory);
1055 auto workload = MakeAndCheckWorkload<QLstmWorkload>(*layer, factory);
1057 CHECK(queueDescriptor.m_Parameters.m_CellClip == 0.0f);
1058 CHECK(queueDescriptor.m_Parameters.m_ProjectionClip == 0.0f);
1059 CHECK(queueDescriptor.m_Inputs.size() == 3);
1060 CHECK(queueDescriptor.m_Outputs.size() == 3);
1062 CHECK((queueDescriptor.m_InputToForgetWeights->GetTensorInfo() == inputWeightsInfo));
1063 CHECK((queueDescriptor.m_InputToCellWeights->GetTensorInfo() == inputWeightsInfo));
1064 CHECK((queueDescriptor.m_InputToOutputWeights->GetTensorInfo() == inputWeightsInfo));
1066 CHECK((queueDescriptor.m_RecurrentToForgetWeights->GetTensorInfo() == recurrentWeightsInfo));
1067 CHECK((queueDescriptor.m_RecurrentToCellWeights->GetTensorInfo() == recurrentWeightsInfo));
1068 CHECK((queueDescriptor.m_RecurrentToOutputWeights->GetTensorInfo() == recurrentWeightsInfo));
1070 CHECK((queueDescriptor.m_ForgetGateBias->GetTensorInfo() == biasInfo));
1071 CHECK((queueDescriptor.m_CellBias->GetTensorInfo() == biasInfo));
1072 CHECK((queueDescriptor.m_OutputGateBias->GetTensorInfo() == biasInfo));
1077 template <
typename Convolution2dWorkload, armnn::DataType DataType>
1078 std::unique_ptr<Convolution2dWorkload> CreateDirectConvolution2dWorkloadTest(
armnn::IWorkloadFactory& factory,
1093 float inputsQScale =
DataType == armnn::DataType::QAsymmU8 ? 1.0f : 0.0;
1094 float outputQScale =
DataType == armnn::DataType::QAsymmU8 ? 2.0f : 0.0;
1097 layer->
m_Bias = std::make_unique<ScopedTensorHandle>
1100 layer->
m_Bias->Allocate();
1109 CreateTensorHandles(graph, factory);
1112 auto workload = MakeAndCheckWorkload<Convolution2dWorkload>(*layer, factory);
1115 CHECK(queueDescriptor.m_Parameters.m_StrideX == 1);
1116 CHECK(queueDescriptor.m_Parameters.m_StrideY == 1);
1117 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 1);
1118 CHECK(queueDescriptor.m_Parameters.m_PadRight == 1);
1119 CHECK(queueDescriptor.m_Parameters.m_PadTop == 1);
1120 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 1);
1121 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled ==
true);
1123 CHECK(queueDescriptor.m_Inputs.size() == 1);
1124 CHECK(queueDescriptor.m_Outputs.size() == 1);
1125 CHECK((queueDescriptor.m_Weight->GetTensorInfo() ==
TensorInfo({2, 3, 3, 3},
1127 CHECK((queueDescriptor.m_Bias->GetTensorInfo()
1134 template <
typename DepthwiseConvolution2dFloat32Workload, armnn::DataType DataType>
1135 std::unique_ptr<DepthwiseConvolution2dFloat32Workload> CreateDepthwiseConvolution2dWorkloadTest(
1166 CreateTensorHandles(graph, factory);
1169 auto workload = MakeAndCheckWorkload<DepthwiseConvolution2dFloat32Workload>(*layer, factory);
1172 CHECK(queueDescriptor.m_Parameters.m_StrideX == 1);
1173 CHECK(queueDescriptor.m_Parameters.m_StrideY == 1);
1174 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 1);
1175 CHECK(queueDescriptor.m_Parameters.m_PadRight == 2);
1176 CHECK(queueDescriptor.m_Parameters.m_PadTop == 1);
1177 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 2);
1178 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled ==
false);
1179 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
1181 CHECK(queueDescriptor.m_Inputs.size() == 1);
1182 CHECK(queueDescriptor.m_Outputs.size() == 1);
1183 CHECK((queueDescriptor.m_Weight->GetTensorInfo() ==
TensorInfo({1, 4, 4, 2},
DataType)));
1189 template <
typename FullyConnectedWorkload, armnn::DataType DataType>
1200 float inputsQScale =
DataType == armnn::DataType::QAsymmU8 ? 1.0f : 0.0;
1201 float outputQScale =
DataType == armnn::DataType::QAsymmU8 ? 2.0f : 0.0;
1215 weights->m_LayerOutput = std::make_unique<ScopedTensorHandle>(weightsTensorInfo);
1216 weights->m_LayerOutput->Allocate();
1220 Connect(weights, layer, weightsTensorInfo, 0, 1);
1222 CreateTensorHandles(graph, factory);
1225 auto workload = MakeAndCheckWorkload<FullyConnectedWorkload>(*layer, factory);
1228 CHECK(queueDescriptor.m_Parameters.m_TransposeWeightMatrix ==
true);
1230 CHECK(queueDescriptor.m_Inputs.size() == 2);
1231 CHECK(queueDescriptor.m_Outputs.size() == 1);
1237 template <
typename FullyConnectedWorkload, armnn::DataType DataType>
1238 std::unique_ptr<FullyConnectedWorkload> CreateFullyConnectedWithBlobWorkloadTest
1249 float inputsQScale =
DataType == armnn::DataType::QAsymmU8 ? 1.0f : 0.0;
1250 float outputQScale =
DataType == armnn::DataType::QAsymmU8 ? 2.0f : 0.0;
1256 layer->
m_Bias->Allocate();
1261 biasesTensorInfo.SetConstant();
1263 auto activationDesc = std::make_shared<ActivationDescriptor>();
1264 activationDesc->m_A = 10.0f;
1265 activationDesc->m_B = 5.0f;
1272 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_A) == 10.0f);
1273 ARMNN_ASSERT(static_cast<float>(activationDescPtr->m_B) == 5.0f);
1274 ARMNN_ASSERT(static_cast<ActivationFunction>(activationDescPtr->m_Function) ==
1283 weights->m_LayerOutput = std::make_unique<ScopedTensorHandle>(weightsTensorInfo);
1284 weights->m_LayerOutput->Allocate();
1285 biases->
m_LayerOutput = std::make_unique<ScopedTensorHandle>(biasesTensorInfo);
1290 Connect(weights, layer, weightsTensorInfo, 0, 1);
1291 Connect(biases, layer, biasesTensorInfo, 0, 2);
1293 CreateTensorHandles(graph, factory);
1296 auto workload = MakeAndCheckWorkload<FullyConnectedWorkload>(*layer, factory);
1309 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled ==
true);
1310 CHECK(queueDescriptor.m_Parameters.m_TransposeWeightMatrix ==
true);
1311 CHECK(queueDescriptor.m_Inputs.size() == 3);
1312 CHECK(queueDescriptor.m_Outputs.size() == 1);
1318 template <
typename FullyConnectedWorkload, armnn::DataType DataType>
1319 std::unique_ptr<FullyConnectedWorkload> CreateFullyConnectedWorkloadWeightsBiasesAsInputsTest
1331 float inputsQScale =
DataType == armnn::DataType::QAsymmU8 ? 1.0f : 0.0;
1332 float outputQScale =
DataType == armnn::DataType::QAsymmU8 ? 2.0f : 0.0;
1345 CreateTensorHandles(graph, factory);
1348 auto workload = MakeAndCheckWorkload<FullyConnectedWorkload>(*layer, factory);
1352 CHECK(queueDescriptor.m_Parameters.m_BiasEnabled ==
true);
1353 CHECK(queueDescriptor.m_Parameters.m_TransposeWeightMatrix ==
true);
1354 CHECK(queueDescriptor.m_Parameters.m_ConstantWeights ==
false);
1355 CHECK(queueDescriptor.m_Inputs.size() == 3);
1356 CHECK(queueDescriptor.m_Outputs.size() == 1);
1363 template <
typename NormalizationWorkload, armnn::DataType DataType>
1374 layerDesc.
m_Beta = -1.0f;
1375 layerDesc.
m_K = 0.2f;
1392 Connect(input, layer, inputTensorInfo);
1393 Connect(layer, output, outputTensorInfo);
1394 CreateTensorHandles(graph, factory);
1397 auto workload = MakeAndCheckWorkload<NormalizationWorkload>(*layer, factory);
1402 CHECK(queueDescriptor.m_Parameters.m_NormSize == 3);
1403 CHECK(queueDescriptor.m_Parameters.m_Alpha == 0.5f);
1404 CHECK(queueDescriptor.m_Parameters.m_Beta == -1.0f);
1405 CHECK(queueDescriptor.m_Parameters.m_K == 0.2f);
1406 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
1408 CHECK(queueDescriptor.m_Inputs.size() == 1);
1409 CHECK(queueDescriptor.m_Outputs.size() == 1);
1415 template <
typename Pooling2dWorkload, armnn::DataType DataType>
1446 CreateTensorHandles(graph, factory);
1449 auto workload = MakeAndCheckWorkload<Pooling2dWorkload>(*layer, factory);
1454 CHECK(queueDescriptor.m_Parameters.m_PoolWidth == 3);
1455 CHECK(queueDescriptor.m_Parameters.m_PoolHeight == 3);
1456 CHECK(queueDescriptor.m_Parameters.m_StrideX == 2);
1457 CHECK(queueDescriptor.m_Parameters.m_StrideY == 3);
1458 CHECK(queueDescriptor.m_Parameters.m_PadLeft == 2);
1459 CHECK(queueDescriptor.m_Parameters.m_PadRight == 2);
1460 CHECK(queueDescriptor.m_Parameters.m_PadTop == 1);
1461 CHECK(queueDescriptor.m_Parameters.m_PadBottom == 1);
1462 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
1464 CHECK(queueDescriptor.m_Inputs.size() == 1);
1465 CHECK(queueDescriptor.m_Outputs.size() == 1);
1471 template <
typename SoftmaxWorkload, armnn::DataType DataType>
1480 softmaxDescriptor.
m_Axis = -1;
1490 if (
DataType == armnn::DataType::QAsymmU8)
1493 tensorInfo.SetQuantizationScale(1.f / 256);
1495 else if (
DataType == armnn::DataType::QAsymmS8)
1497 tensorInfo.SetQuantizationOffset(-128);
1498 tensorInfo.SetQuantizationScale(1.f / 256);
1501 Connect(input, layer, tensorInfo);
1502 Connect(layer, output, tensorInfo);
1503 CreateTensorHandles(graph, factory);
1506 auto workload = MakeAndCheckWorkload<SoftmaxWorkload>(*layer, factory);
1509 CHECK(queueDescriptor.m_Inputs.size() == 1);
1510 CHECK(queueDescriptor.m_Outputs.size() == 1);
1516 template<
typename SplitterWorkload, armnn::DataType DataType>
1517 std::unique_ptr<SplitterWorkload>
1528 layerDesc.SetViewOriginCoord(0, 0, 0);
1529 layerDesc.SetViewOriginCoord(1, 0, 1);
1530 layerDesc.SetViewOriginCoord(2, 0, 3);
1542 Connect(input, layer, tensorInfo);
1548 Connect(layer, output0, output0Info, 0, 0);
1549 Connect(layer, output1, output1Info, 1, 0);
1550 Connect(layer, output2, output2Info, 2, 0);
1552 CreateTensorHandles(graph, factory);
1555 auto workload = MakeAndCheckWorkload<SplitterWorkload>(*layer, factory);
1558 CHECK(queueDescriptor.m_Inputs.size() == 1);
1559 CHECK(queueDescriptor.m_Outputs.size() == 3);
1560 CHECK(queueDescriptor.m_ViewOrigins.size() == 3);
1562 CHECK(queueDescriptor.m_ViewOrigins[0].m_Origin[0] == 0);
1563 CHECK(queueDescriptor.m_ViewOrigins[1].m_Origin[0] == 1);
1564 CHECK(queueDescriptor.m_ViewOrigins[2].m_Origin[0] == 3);
1565 CHECK(queueDescriptor.m_ViewOrigins[0].m_Origin[1] == 0);
1566 CHECK(queueDescriptor.m_ViewOrigins[1].m_Origin[1] == 0);
1567 CHECK(queueDescriptor.m_ViewOrigins[2].m_Origin[1] == 0);
1568 CHECK(queueDescriptor.m_ViewOrigins[0].m_Origin[2] == 0);
1569 CHECK(queueDescriptor.m_ViewOrigins[1].m_Origin[2] == 0);
1570 CHECK(queueDescriptor.m_ViewOrigins[2].m_Origin[2] == 0);
1577 template<
typename SplitterWorkload,
typename ConcatWorkload, armnn::DataType DataType>
1578 std::pair<std::unique_ptr<SplitterWorkload>, std::unique_ptr<ConcatWorkload>>
1590 splitterViews.SetViewOriginCoord(0, 0, 0);
1591 splitterViews.SetViewOriginCoord(0, 1, 0);
1592 splitterViews.SetViewOriginCoord(0, 2, 0);
1593 splitterViews.SetViewOriginCoord(0, 3, 0);
1595 splitterViews.SetViewOriginCoord(1, 0, 0);
1596 splitterViews.SetViewOriginCoord(1, 1, 1);
1597 splitterViews.SetViewOriginCoord(1, 2, 0);
1598 splitterViews.SetViewOriginCoord(1, 3, 0);
1605 concatViews.SetViewOriginCoord(0, 0, 0);
1606 concatViews.SetViewOriginCoord(0, 1, 1);
1607 concatViews.SetViewOriginCoord(0, 2, 0);
1608 concatViews.SetViewOriginCoord(0, 3, 0);
1610 concatViews.SetViewOriginCoord(1, 0, 0);
1611 concatViews.SetViewOriginCoord(1, 1, 0);
1612 concatViews.SetViewOriginCoord(1, 2, 0);
1613 concatViews.SetViewOriginCoord(1, 3, 0);
1623 Connect(input, splitter, inputTensorInfo, 0, 0);
1625 Connect(splitter, concat, splitTensorInfo1, 0, 1);
1627 Connect(splitter, concat, splitTensorInfo2, 1, 0);
1629 Connect(concat, output, inputTensorInfo, 0, 0);
1632 CreateTensorHandles(graph, factory);
1635 auto workloadSplitter = MakeAndCheckWorkload<SplitterWorkload>(*splitter, factory);
1636 CHECK(workloadSplitter);
1638 auto workloadConcat = MakeAndCheckWorkload<ConcatWorkload>(*concat, factory);
1639 CHECK(workloadConcat);
1641 return {std::move(workloadSplitter), std::move(workloadConcat)};
1647 template<
typename SplitterWorkload,
typename ActivationWorkload, armnn::DataType DataType>
1649 std::unique_ptr<SplitterWorkload>& wlSplitter,
1650 std::unique_ptr<ActivationWorkload>& wlActiv0_0,
1651 std::unique_ptr<ActivationWorkload>& wlActiv0_1,
1652 std::unique_ptr<ActivationWorkload>& wlActiv1_0,
1653 std::unique_ptr<ActivationWorkload>& wlActiv1_1)
1664 splitterViews.SetViewOriginCoord(0, 0, 0);
1665 splitterViews.SetViewOriginCoord(0, 1, 0);
1666 splitterViews.SetViewOriginCoord(0, 2, 0);
1667 splitterViews.SetViewOriginCoord(0, 3, 0);
1669 splitterViews.SetViewOriginCoord(1, 0, 0);
1670 splitterViews.SetViewOriginCoord(1, 1, 1);
1671 splitterViews.SetViewOriginCoord(1, 2, 0);
1672 splitterViews.SetViewOriginCoord(1, 3, 0);
1689 Connect(input, splitter, inputTensorInfo, 0, 0);
1690 Connect(splitter, activ0_0, splitTensorInfo1, 0, 0);
1691 Connect(splitter, activ0_1, splitTensorInfo1, 0, 0);
1693 Connect(splitter, activ1_0, splitTensorInfo2, 1, 0);
1694 Connect(splitter, activ1_1, splitTensorInfo2, 1, 0);
1696 Connect(activ0_0, output1, splitTensorInfo1, 0, 0);
1697 Connect(activ0_1, output2, splitTensorInfo1, 0, 0);
1698 Connect(activ1_0, output3, splitTensorInfo2, 0, 0);
1699 Connect(activ1_1, output4, splitTensorInfo2, 0, 0);
1701 CreateTensorHandles(graph, factory);
1703 auto workloadSplitter = MakeAndCheckWorkload<SplitterWorkload>(*splitter, factory);
1704 auto workloadActiv0_0 = MakeAndCheckWorkload<ActivationWorkload>(*activ0_0, factory);
1705 auto workloadActiv0_1 = MakeAndCheckWorkload<ActivationWorkload>(*activ0_1, factory);
1706 auto workloadActiv1_0 = MakeAndCheckWorkload<ActivationWorkload>(*activ1_0, factory);
1707 auto workloadActiv1_1 = MakeAndCheckWorkload<ActivationWorkload>(*activ1_1, factory);
1709 wlSplitter = std::move(workloadSplitter);
1710 wlActiv0_0 = std::move(workloadActiv0_0);
1711 wlActiv0_1 = std::move(workloadActiv0_1);
1712 wlActiv1_0 = std::move(workloadActiv1_0);
1713 wlActiv1_1 = std::move(workloadActiv1_1);
1716 template <
typename ResizeWorkload, armnn::DataType DataType>
1724 switch (dataLayout) {
1726 inputShape = { 2, 4, 4, 3 };
1727 outputShape = { 2, 2, 2, 3 };
1731 inputShape = { 2, 3, 4, 4 };
1732 outputShape = { 2, 3, 2, 2 };
1751 Connect(input, layer, inputTensorInfo);
1752 Connect(layer, output, outputTensorInfo);
1753 CreateTensorHandles(graph, factory);
1756 auto workload = MakeAndCheckWorkload<ResizeWorkload>(*layer, factory);
1758 auto queueDescriptor = workload->GetData();
1759 CHECK(queueDescriptor.m_Inputs.size() == 1);
1760 CHECK(queueDescriptor.m_Outputs.size() == 1);
1761 CHECK(queueDescriptor.m_Parameters.m_DataLayout == dataLayout);
1767 template <
typename BatchToSpaceNdWorkload, armnn::DataType DataType>
1781 Connect(input, layer, tensorInfo);
1782 Connect(layer, output, tensorInfo);
1784 CreateTensorHandles(graph, factory);
1787 auto workload = MakeAndCheckWorkload<BatchToSpaceNdWorkload>(*layer, factory);
1790 CHECK(queueDescriptor.m_Inputs.size() == 1);
1791 CHECK(queueDescriptor.m_Outputs.size() == 1);
1796 template <
typename LogSoftmaxWorkload, armnn::DataType DataType>
1805 logSoftmaxDescriptor.
m_Axis = -1;
1816 Connect(input, layer, tensorInfo);
1817 Connect(layer, output, tensorInfo);
1818 CreateTensorHandles(graph, factory);
1821 auto workload = MakeAndCheckWorkload<LogSoftmaxWorkload>(*layer, factory);
1824 CHECK(queueDescriptor.m_Inputs.size() == 1);
1825 CHECK(queueDescriptor.m_Outputs.size() == 1);
1831 template <
typename L2NormalizationWorkload, armnn::DataType DataType>
1853 Connect(input, layer, inputTensorInfo);
1854 Connect(layer, output, outputTensorInfo);
1855 CreateTensorHandles(graph, factory);
1858 auto workload = MakeAndCheckWorkload<L2NormalizationWorkload>(*layer, factory);
1861 CHECK((queueDescriptor.m_Parameters.m_DataLayout == dataLayout));
1862 CHECK(queueDescriptor.m_Inputs.size() == 1);
1863 CHECK(queueDescriptor.m_Outputs.size() == 1);
1869 template <
typename ReshapeWorkload, armnn::DataType DataType>
1886 Connect(input, layer, inputTensorInfo);
1887 Connect(layer, output, outputTensorInfo);
1888 CreateTensorHandles(graph, factory);
1891 auto workload = MakeAndCheckWorkload<ReshapeWorkload>(*layer, factory);
1894 CHECK(queueDescriptor.m_Inputs.size() == 1);
1895 CHECK(queueDescriptor.m_Outputs.size() == 1);
1901 template <
typename ConvertFp16ToFp32Float32Workload>
1902 std::unique_ptr<ConvertFp16ToFp32Float32Workload> CreateConvertFp16ToFp32WorkloadTest(
1915 Connect(input, layer, inputTensorInfo);
1916 Connect(layer, output, outputTensorInfo);
1917 CreateTensorHandles(graph, factory);
1920 auto workload = MakeAndCheckWorkload<ConvertFp16ToFp32Float32Workload>(*layer, factory);
1923 CHECK(queueDescriptor.m_Inputs.size() == 1);
1924 CHECK(queueDescriptor.m_Outputs.size() == 1);
1930 template <
typename ConvertFp32ToFp16Float16Workload>
1931 std::unique_ptr<ConvertFp32ToFp16Float16Workload> CreateConvertFp32ToFp16WorkloadTest(
1944 Connect(input, layer, inputTensorInfo);
1945 Connect(layer, output, outputTensorInfo);
1946 CreateTensorHandles(graph, factory);
1949 auto workload = MakeAndCheckWorkload<ConvertFp32ToFp16Float16Workload>(*layer, factory);
1952 CHECK(queueDescriptor.m_Inputs.size() == 1);
1953 CHECK(queueDescriptor.m_Outputs.size() == 1);
1959 template <
typename MeanWorkload, armnn::DataType DataType>
1975 Connect(input, layer, inputTensorInfo);
1976 Connect(layer, output, outputTensorInfo);
1977 CreateTensorHandles(graph, factory);
1980 auto workload = MakeAndCheckWorkload<MeanWorkload>(*layer, factory);
1983 CHECK(queueDescriptor.m_Parameters.m_Axis == descriptor.m_Axis);
1984 CHECK(queueDescriptor.m_Parameters.m_KeepDims == descriptor.m_KeepDims);
1985 CHECK(queueDescriptor.m_Inputs.size() == 1);
1986 CHECK(queueDescriptor.m_Outputs.size() == 1);
1992 template<
typename ConcatWorkload, armnn::DataType DataType>
1996 unsigned int concatAxis)
2006 std::vector<armnn::TensorShape> inputShapes{{ 2, 3, 2, 5 }, { 2, 3, 2, 5 }};
2020 Connect(input0, concat, inputTensorInfo, 0, 0);
2022 Connect(input1, concat, inputTensorInfo, 0, 1);
2024 Connect(concat, output, outputTensorInfo, 0, 0);
2027 CreateTensorHandles(graph, factory);
2030 auto workloadConcat = MakeAndCheckWorkload<ConcatWorkload>(*concat, factory);
2031 CHECK(workloadConcat);
2033 return workloadConcat;
2036 template <
typename PreCompiledWorkload, armnn::DataType dataType>
2037 std::pair<armnn::IOptimizedNetworkPtr, std::unique_ptr<PreCompiledWorkload>> CreatePreCompiledWorkloadTest(
2040 bool biasEnabled =
false)
2055 unsigned int weightsLength = weightsTensorInfo.GetNumElements();
2058 std::vector<WeightType> convWeightsData(weightsLength);
2059 for (
unsigned int i = 0; i < weightsLength; ++i)
2061 convWeightsData[i] =
static_cast<WeightType
>(i);
2074 const std::string convLayerName(
"conv layer");
2082 unsigned int biasLength = biasTensorInfo.GetNumElements();
2085 std::vector<BiasType> biasData(biasLength);
2086 std::fill(biasData.begin(), biasData.end(),
static_cast<BiasType
>(0));
2091 convLayer = net->AddConvolution2dLayer(convDesc2d,
2094 convLayerName.c_str());
2099 convLayer = net->AddConvolution2dLayer(convDesc2d,
2102 convLayerName.c_str());
2113 if (dataType == armnn::DataType::QAsymmU8)
2115 inputTensorInfo.SetQuantizationOffset(0);
2116 inputTensorInfo.SetQuantizationScale(0.9f);
2120 if (dataType == armnn::DataType::QAsymmU8)
2122 outputTensorInfo.SetQuantizationOffset(0);
2123 outputTensorInfo.SetQuantizationScale(0.9f);
2134 std::vector<armnn::BackendId> backends = {factory.
GetBackendId()};
2140 CHECK(optimizedNet !=
nullptr);
2144 Layer* preCompiledLayer =
nullptr;
2145 for (
auto& layer : optimisedGraph)
2149 preCompiledLayer = layer;
2152 CHECK(preCompiledLayer !=
nullptr);
2155 CreateTensorHandles(optimisedGraph, factory);
2158 auto workload = MakeAndCheckWorkload<PreCompiledWorkload>(*preCompiledLayer, factory);
2161 CHECK(queueDescriptor.m_Inputs.size() == 1);
2162 CHECK(queueDescriptor.m_Outputs.size() == 1);
2167 return std::make_pair(std::move(optimizedNet), std::move(workload));
2170 template<
typename ConstantWorkload, armnn::DataType DataType>
2180 constant->m_LayerOutput = std::make_unique<ScopedTensorHandle>(outputTensorInfo);
2186 Connect(constant, output, outputTensorInfo, 0, 0);
2189 CreateTensorHandles(graph, factory);
2192 auto workloadConstant = MakeAndCheckWorkload<ConstantWorkload>(*constant, factory);
2193 CHECK(workloadConstant);
2195 return workloadConstant;
2198 template <
typename PreluWorkload>
2208 CHECK(layer !=
nullptr);
2214 CHECK(input !=
nullptr);
2215 CHECK(alpha !=
nullptr);
2216 CHECK(output !=
nullptr);
2222 Connect(input, layer, inputTensorInfo, 0, 0);
2223 Connect(alpha, layer, alphaTensorInfo, 0, 1);
2224 Connect(layer, output, outputTensorInfo, 0, 0);
2225 CreateTensorHandles(graph, factory);
2228 auto workload = MakeAndCheckWorkload<PreluWorkload>(*layer, factory);
2231 CHECK(queueDescriptor.m_Inputs.size() == 2);
2232 CHECK(queueDescriptor.m_Outputs.size() == 1);
2238 template <
typename SpaceToDepthWorkload, armnn::DataType DataType>
2254 Connect(input, layer, inputTensorInfo);
2255 Connect(layer, output, outputTensorInfo);
2257 CreateTensorHandles(graph, factory);
2260 auto workload = MakeAndCheckWorkload<SpaceToDepthWorkload>(*layer, factory);
2263 CHECK(queueDescriptor.m_Inputs.size() == 1);
2264 CHECK(queueDescriptor.m_Outputs.size() == 1);
2269 template <
typename StackWorkload, armnn::DataType DataType>
2275 unsigned int numInputs)
2283 CHECK(stackLayer !=
nullptr);
2286 std::vector<Layer*> inputs;
2287 for (
unsigned int i=0; i<numInputs; ++i)
2290 static_cast<int>(i),
2291 (
"input" + std::to_string(i)).c_str()
2293 CHECK(inputs[i] !=
nullptr);
2296 CHECK(output !=
nullptr);
2299 for (
unsigned int i=0; i<numInputs; ++i)
2301 Connect(inputs[i], stackLayer, inputTensorInfo, 0, i);
2303 Connect(stackLayer, output, outputTensorInfo, 0, 0);
2305 CreateTensorHandles(graph, factory);
2307 auto stackWorkload = MakeAndCheckWorkload<StackWorkload>(*stackLayer, factory);
2309 CHECK(queueDescriptor.m_Inputs.size() == numInputs);
2310 CHECK(queueDescriptor.m_Outputs.size() == 1);
2312 return stackWorkload;
A layer that the constant data can be bound to.
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
bool m_ProjectionEnabled
Enable/disable the projection layer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer represents a split operation.
static IRuntimePtr Create(const CreationOptions &options)
virtual const BackendId & GetBackendId() const =0
LstmBasicParameters m_BasicParameters
This layer represents a batch normalization operation.
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
unsigned int GetWidthIndex() const
float m_K
Kappa value used for the across channel normalization equation.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
float m_ClippingThresProj
Clipping threshold value for the projection.
A ReshapeDescriptor for the ReshapeLayer.
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer represents a depthwise convolution 2d operation.
std::shared_ptr< ConstTensorHandle > m_LayerOutput
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
std::vector< BackendOptions > ModelOptions
uint32_t m_PoolWidth
Pooling width value.
bool m_PeepholeEnabled
Enable/disable peephole.
A Convolution2dDescriptor for the Convolution2dLayer.
float m_Alpha
Alpha value for the normalization equation.
uint32_t m_PadLeft
Padding left value in the width dimension.
This layer converts data type Float 16 to Float 32.
float m_HiddenStateScale
Hidden State quantization scale.
float m_OutputIntermediateScale
Output intermediate quantization scale.
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
This layer represents a SpaceToDepth operation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer represents a reshape operation.
typename ResolveTypeImpl< DT >::Type ResolveType
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
This layer represents an activation operation with the specified activation function.
uint32_t m_PadTop
Padding top value in the height dimension.
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
uint32_t m_PadRight
Padding right value in the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Copyright (c) 2021 ARM Limited and Contributors.
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
This layer represents a LSTM operation.
void IgnoreUnused(Ts &&...)
void SetBackendId(const BackendId &id)
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
std::shared_ptr< ConstTensorHandle > m_Beta
A unique pointer to store Beta values.
unsigned int GetHeightIndex() const
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
QLstmOptLayerNormParameters m_LayerNormParameters
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
This layer represents a elementwiseUnary operation.
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A StackDescriptor for the StackLayer.
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
TensorShape m_TargetShape
Target shape value.
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A layer user-provided data can be bound to (e.g. inputs, outputs).
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
bool m_LayerNormEnabled
Enable/disable layer normalization.
This layer represents a fully connected operation.
An LstmDescriptor for the LstmLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
uint32_t m_PadTop
Padding top value in the height dimension.
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
This layer represents a QuantizedLstm operation.
This layer represents a log softmax operation.
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
A L2NormalizationDescriptor for the L2NormalizationLayer.
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
An OriginsDescriptor for the ConcatLayer.
float m_ProjectionClip
Clipping threshold value for the projection.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_BiasEnabled
Enable/disable bias.
This layer represents a stack operation.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
float m_InputIntermediateScale
Input intermediate quantization scale.
This layer represents a merge operation.
This layer represents a softmax operation.
uint32_t m_TargetWidth
Target width value.
bool m_PeepholeEnabled
Enable/disable peephole.
This layer represents a BatchToSpaceNd operation.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
#define ARMNN_ASSERT(COND)
A QLstmDescriptor for the QLstmLayer.
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_Gamma
A unique pointer to store Gamma values.
GPU Execution: OpenCL: ArmCompute.
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
ArmNN performs an optimization on each model/network before it gets loaded for execution.
An ActivationDescriptor for the ActivationLayer.
min(a, max(b, input)) ReLu1 & ReLu6.
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_Variance
A unique pointer to store Variance values.
uint32_t m_TargetHeight
Target height value.
uint32_t m_ActivationFunc
The activation function to use.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
This layer represents a normalization operation.
This layer represents a pooling 2d operation.
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
float m_ClippingThresCell
Clipping threshold value for the cell state.
This layer converts data type Float 32 to Float 16.
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataType GetBiasDataType(DataType inputDataType)
void SetAdditionalInfoForObject(const AdditionalInfoObjectPtr &additionalInfo)
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer represents an addition operation.
QLstmBasicParameters m_BasicParameters
LstmOptPeepholeParameters m_PeepholeParameters
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Graph & GetGraphForTesting(IOptimizedNetwork *optNet)
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
This layer represents a QLstm operation.
float m_CellClip
Clipping threshold value for the cell state.
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH, Elu).
This layer represents a subtraction operation.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
This layer represents a L2 normalization operation.
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
CPU Execution: NEON: ArmCompute.
bool m_ProjectionEnabled
Enable/disable the projection layer.
OutputShapeRounding m_OutputShapeRounding
The rounding method for the output shape. (Floor, Ceiling).
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A MeanDescriptor for the MeanLayer.
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
DataType GetDataType() const
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
This layer represents a convolution 2d operation.
void SetQuantizationOffset(int32_t offset)
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
Graph & TopologicalSort()
Sorts layers in topological order and return this.
This layer represents a mean operation.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
virtual int Connect(IInputSlot &destination)=0
Krichevsky 2012: Local Brightness Normalization.
A Pooling2dDescriptor for the Pooling2dLayer.
A NormalizationDescriptor for the NormalizationLayer.
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
This layer represents a multiplication operation.
virtual void CreateTensorHandles(const TensorHandleFactoryRegistry ®istry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const =0
float m_CellIntermediateScale
Cell intermediate quantization scale.
static INetworkPtr Create(NetworkOptions networkOptions={})
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
A SoftmaxDescriptor for the SoftmaxLayer.
float m_Beta
Beta value for the normalization equation.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
uint32_t m_NormSize
Depth radius value.
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
Depthwise Convolution 2D layer workload data.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
uint32_t m_PadLeft
Padding left value in the width dimension.
std::shared_ptr< T > GetAdditionalInformation() const
This layer represents a resize operation.
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
uint32_t m_PadRight
Padding right value in the width dimension.
int32_t m_HiddenStateZeroPoint
Hidden State zero point.
bool m_ConstantWeights
Enable/disable constant weights and biases.