6 #include "../Serializer.hpp" 20 #include <doctest/doctest.h> 27 TEST_CASE(
"SerializeAddition")
29 const std::string layerName(
"addition");
48 CHECK(deserializedNetwork);
56 const std::string layerName(
"argminmax");
62 descriptor.m_Axis = 1;
76 CHECK(deserializedNetwork);
85 TEST_CASE(
"SerializeArgMinMaxSigned32")
90 TEST_CASE(
"SerializeArgMinMaxSigned64")
95 TEST_CASE(
"SerializeBatchNormalization")
97 const std::string layerName(
"batchNormalization");
107 descriptor.
m_Eps = 0.0010000000475f;
110 std::vector<float> meanData({5.0});
111 std::vector<float> varianceData({2.0});
112 std::vector<float> betaData({1.0});
113 std::vector<float> gammaData({0.0});
115 std::vector<armnn::ConstTensor> constants;
124 network->AddBatchNormalizationLayer(descriptor,
139 CHECK(deserializedNetwork);
142 layerName, {inputInfo}, {outputInfo}, descriptor, constants);
146 TEST_CASE(
"SerializeBatchToSpaceNd")
148 const std::string layerName(
"spaceToBatchNd");
154 desc.m_BlockShape = {2, 2};
155 desc.m_Crops = {{0, 0}, {0, 0}};
169 CHECK(deserializedNetwork);
178 TEST_CASE(
"SerializeCast")
180 const std::string layerName(
"cast");
199 CHECK(deserializedNetwork);
205 TEST_CASE(
"SerializeChannelShuffle")
207 const std::string layerName(
"channelShuffle");
216 network->AddChannelShuffleLayer(descriptor, layerName.c_str());
226 CHECK(deserializedNetwork);
229 layerName, {inputInfo}, {outputInfo}, descriptor);
233 TEST_CASE(
"SerializeComparison")
235 const std::string layerName(
"comparison");
259 CHECK(deserializedNetwork);
262 { inputInfo, inputInfo },
268 TEST_CASE(
"SerializeConstant")
273 ConstantLayerVerifier(
const std::string& layerName,
274 const std::vector<armnn::TensorInfo>& inputInfos,
275 const std::vector<armnn::TensorInfo>& outputInfos,
276 const std::vector<armnn::ConstTensor>& constants)
278 , m_Constants(constants) {}
282 const std::vector<armnn::ConstTensor>& constants,
297 for (std::size_t i = 0; i < constants.size(); i++)
306 const std::vector<armnn::ConstTensor> m_Constants;
309 const std::string layerName(
"constant");
312 std::vector<float> constantData = GenerateRandomData<float>(info.GetNumElements());
330 CHECK(deserializedNetwork);
332 ConstantLayerVerifier verifier(layerName, {}, {info}, {constTensor});
333 deserializedNetwork->ExecuteStrategy(verifier);
340 Convolution2dLayerVerifier(
const std::string& layerName,
341 const std::vector<armnn::TensorInfo>& inputInfos,
342 const std::vector<armnn::TensorInfo>& outputInfos,
343 const Convolution2dDescriptor& descriptor)
348 const std::vector<armnn::ConstTensor>& constants,
360 VerifyNameAndConnections(layer, name);
361 const Convolution2dDescriptor& layerDescriptor =
362 static_cast<const Convolution2dDescriptor&
>(descriptor);
363 CHECK(layerDescriptor.m_BiasEnabled == m_Descriptor.m_BiasEnabled);
369 TEST_CASE(
"SerializeConvolution2d")
371 const std::string layerName(
"convolution2d");
378 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
381 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
400 network->AddConvolution2dLayer(descriptor,
408 convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
411 convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
414 CHECK(deserializedNetwork);
416 Convolution2dLayerVerifier verifier(layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor);
417 deserializedNetwork->ExecuteStrategy(verifier);
420 TEST_CASE(
"SerializeConvolution2dWithPerAxisParamsTestDeprecatedMethod")
422 using namespace armnn;
424 const std::string layerName(
"convolution2dWithPerAxis");
425 const TensorInfo inputInfo ({ 1, 3, 1, 2 }, DataType::QAsymmU8, 0.55f, 128);
426 const TensorInfo outputInfo({ 1, 3, 1, 3 }, DataType::QAsymmU8, 0.75f, 128);
428 const std::vector<float> quantScales{ 0.75f, 0.65f, 0.85f };
429 constexpr
unsigned int quantDimension = 0;
431 const TensorInfo kernelInfo({ 3, 1, 1, 2 }, DataType::QSymmS8, quantScales, quantDimension,
true);
433 const std::vector<float> biasQuantScales{ 0.25f, 0.50f, 0.75f };
434 const TensorInfo biasInfo({ 3 }, DataType::Signed32, biasQuantScales, quantDimension,
true);
436 std::vector<int8_t> kernelData = GenerateRandomData<int8_t>(kernelInfo.GetNumElements());
438 std::vector<int32_t> biasData = GenerateRandomData<int32_t>(biasInfo.GetNumElements());
441 Convolution2dDescriptor descriptor;
442 descriptor.m_StrideX = 1;
443 descriptor.m_StrideY = 1;
444 descriptor.m_PadLeft = 0;
445 descriptor.m_PadRight = 0;
446 descriptor.m_PadTop = 0;
447 descriptor.m_PadBottom = 0;
448 descriptor.m_BiasEnabled =
true;
455 network->AddConvolution2dLayer(descriptor,
463 convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
466 convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
469 CHECK(deserializedNetwork);
471 Convolution2dLayerVerifier verifier(layerName, {inputInfo, kernelInfo, biasInfo}, {outputInfo}, descriptor);
473 deserializedNetwork->ExecuteStrategy(verifier);
476 TEST_CASE(
"SerializeConvolution2dWeightsAndBiasesAsConstantLayers")
478 const std::string layerName(
"convolution2d");
485 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
488 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
522 CHECK(deserializedNetwork);
524 const std::vector<armnn::ConstTensor>& constants {weights, biases};
526 layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor, constants);
531 TEST_CASE(
"SerializeConvolution3d")
533 const std::string layerName(
"convolution3d");
540 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
543 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
580 CHECK(deserializedNetwork);
583 layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor);
587 TEST_CASE(
"SerializeDepthToSpace")
589 const std::string layerName(
"depthToSpace");
610 CHECK(deserializedNetwork);
616 TEST_CASE(
"SerializeDepthwiseConvolution2d")
618 const std::string layerName(
"depwiseConvolution2d");
625 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
628 std::vector<int32_t> biasesData = GenerateRandomData<int32_t>(biasesInfo.GetNumElements());
664 CHECK(deserializedNetwork);
666 const std::vector<armnn::ConstTensor>& constants {weights, biases};
668 layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor, constants);
672 TEST_CASE(
"SerializeDepthwiseConvolution2dWithPerAxisParams")
674 using namespace armnn;
676 const std::string layerName(
"depwiseConvolution2dWithPerAxis");
677 const TensorInfo inputInfo ({ 1, 3, 3, 2 }, DataType::QAsymmU8, 0.55f, 128);
678 const TensorInfo outputInfo({ 1, 2, 2, 4 }, DataType::QAsymmU8, 0.75f, 128);
680 const std::vector<float> quantScales{ 0.75f, 0.80f, 0.90f, 0.95f };
681 const unsigned int quantDimension = 0;
682 TensorInfo kernelInfo({ 2, 2, 2, 2 }, DataType::QSymmS8, quantScales, quantDimension,
true);
684 const std::vector<float> biasQuantScales{ 0.25f, 0.35f, 0.45f, 0.55f };
685 constexpr
unsigned int biasQuantDimension = 0;
686 TensorInfo biasInfo({ 4 }, DataType::Signed32, biasQuantScales, biasQuantDimension,
true);
688 std::vector<int8_t> kernelData = GenerateRandomData<int8_t>(kernelInfo.GetNumElements());
690 std::vector<int32_t> biasData = GenerateRandomData<int32_t>(biasInfo.GetNumElements());
726 CHECK(deserializedNetwork);
728 const std::vector<armnn::ConstTensor>& constants {weights, biases};
730 layerName, {inputInfo, kernelInfo, biasInfo}, {outputInfo}, descriptor, constants);
734 TEST_CASE(
"SerializeDepthwiseConvolution2dWeightsAndBiasesAsConstantLayers")
736 const std::string layerName(
"depthwiseConvolution2d");
743 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
746 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
780 CHECK(deserializedNetwork);
782 const std::vector<armnn::ConstTensor>& constants {weights, biases};
784 layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor, constants);
789 TEST_CASE(
"SerializeDequantize")
791 const std::string layerName(
"dequantize");
807 CHECK(deserializedNetwork);
813 TEST_CASE(
"SerializeDeserializeDetectionPostProcess")
815 const std::string layerName(
"detectionPostProcess");
817 const std::vector<armnn::TensorInfo> inputInfos({
822 const std::vector<armnn::TensorInfo> outputInfos({
843 const std::vector<float> anchorsData({
844 0.5f, 0.5f, 1.0f, 1.0f,
845 0.5f, 0.5f, 1.0f, 1.0f,
846 0.5f, 0.5f, 1.0f, 1.0f,
847 0.5f, 10.5f, 1.0f, 1.0f,
848 0.5f, 10.5f, 1.0f, 1.0f,
849 0.5f, 100.5f, 1.0f, 1.0f
855 network->AddDetectionPostProcessLayer(descriptor, anchors, layerName.c_str());
857 for (
unsigned int i = 0; i < 2; i++)
864 for (
unsigned int i = 0; i < 4; i++)
872 CHECK(deserializedNetwork);
874 const std::vector<armnn::ConstTensor>& constants {anchors};
876 layerName, inputInfos, outputInfos, descriptor, constants);
877 deserializedNetwork->ExecuteStrategy(verifier);
880 TEST_CASE(
"SerializeDivision")
882 const std::string layerName(
"division");
900 CHECK(deserializedNetwork);
906 TEST_CASE(
"SerializeDeserializeComparisonEqual")
908 const std::string layerName(
"EqualLayer");
928 CHECK(deserializedNetwork);
930 LayerVerifierBase verifier(layerName, {inputTensorInfo1, inputTensorInfo2}, {outputTensorInfo});
948 network->AddElementwiseUnaryLayer(descriptor, layerName);
959 CHECK(deserializedNetwork);
962 verifier(layerName, { inputInfo }, { outputInfo }, descriptor);
967 TEST_CASE(
"SerializeElementwiseUnary")
970 std::initializer_list<op> allUnaryOperations = {op::Abs, op::Exp, op::Sqrt, op::Rsqrt, op::Neg,
971 op::LogicalNot, op::Log, op::Sin};
973 for (
auto unaryOperation : allUnaryOperations)
975 SerializeElementwiseUnaryTest(unaryOperation);
979 TEST_CASE(
"SerializeFill")
981 const std::string layerName(
"fill");
999 CHECK(deserializedNetwork);
1006 TEST_CASE(
"SerializeFloor")
1008 const std::string layerName(
"floor");
1023 CHECK(deserializedNetwork);
1033 FullyConnectedLayerVerifier(
const std::string& layerName,
1034 const std::vector<armnn::TensorInfo>& inputInfos,
1035 const std::vector<armnn::TensorInfo>& outputInfos,
1041 const std::vector<armnn::ConstTensor>& constants,
1053 VerifyNameAndConnections(layer, name);
1057 CHECK(layerDescriptor.
m_BiasEnabled == m_Descriptor.m_BiasEnabled);
1064 TEST_CASE(
"SerializeFullyConnected")
1066 const std::string layerName(
"fullyConnected");
1072 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
1073 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
1087 network->AddFullyConnectedLayer(descriptor,
1102 CHECK(deserializedNetwork);
1104 FullyConnectedLayerVerifier verifier(layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor);
1105 deserializedNetwork->ExecuteStrategy(verifier);
1108 TEST_CASE(
"SerializeFullyConnectedWeightsAndBiasesAsInputs")
1110 const std::string layerName(
"fullyConnected_weights_as_inputs");
1130 network->AddFullyConnectedLayer(descriptor,
1145 CHECK(deserializedNetwork);
1147 const std::vector<armnn::ConstTensor> constants {};
1149 layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor, constants);
1153 TEST_CASE(
"SerializeFullyConnectedWeightsAndBiasesAsConstantLayers")
1155 const std::string layerName(
"fullyConnected_weights_as_inputs");
1162 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
1163 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
1176 armnn::IConnectableLayer*
const fullyConnectedLayer = network->AddFullyConnectedLayer(descriptor,layerName.c_str());
1190 CHECK(deserializedNetwork);
1192 FullyConnectedLayerVerifier verifier(layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor);
1193 deserializedNetwork->ExecuteStrategy(verifier);
1196 TEST_CASE(
"SerializeGather")
1202 GatherLayerVerifier(
const std::string& layerName,
1203 const std::vector<armnn::TensorInfo>& inputInfos,
1204 const std::vector<armnn::TensorInfo>& outputInfos,
1210 const std::vector<armnn::ConstTensor>& constants,
1222 VerifyNameAndConnections(layer, name);
1224 CHECK(layerDescriptor.
m_Axis == m_Descriptor.m_Axis);
1230 const std::string layerName(
"gather");
1237 paramsInfo.SetQuantizationScale(1.0f);
1238 paramsInfo.SetQuantizationOffset(0);
1239 outputInfo.SetQuantizationScale(1.0f);
1240 outputInfo.SetQuantizationOffset(0);
1242 const std::vector<int32_t>& indicesData = {7, 6, 5};
1260 CHECK(deserializedNetwork);
1262 GatherLayerVerifier verifier(layerName, {paramsInfo, indicesInfo}, {outputInfo}, descriptor);
1263 deserializedNetwork->ExecuteStrategy(verifier);
1266 TEST_CASE(
"SerializeGatherNd")
1271 GatherNdLayerVerifier(
const std::string& layerName,
1272 const std::vector<armnn::TensorInfo>& inputInfos,
1273 const std::vector<armnn::TensorInfo>& outputInfos)
1278 const std::vector<armnn::ConstTensor>& constants,
1291 VerifyNameAndConnections(layer, name);
1297 const std::string layerName(
"gatherNd");
1303 paramsInfo.SetQuantizationOffset(0);
1304 outputInfo.SetQuantizationScale(1.0f);
1305 outputInfo.SetQuantizationOffset(0);
1307 const std::vector<int32_t>& indicesData = {5, 1, 0};
1325 CHECK(deserializedNetwork);
1327 GatherNdLayerVerifier verifier(layerName, {paramsInfo, indicesInfo}, {outputInfo});
1328 deserializedNetwork->ExecuteStrategy(verifier);
1331 TEST_CASE(
"SerializeComparisonGreater")
1333 const std::string layerName(
"greater");
1356 CHECK(deserializedNetwork);
1358 LayerVerifierBase verifier(layerName, { inputInfo, inputInfo }, { outputInfo });
1363 TEST_CASE(
"SerializeInstanceNormalization")
1365 const std::string layerName(
"instanceNormalization");
1370 descriptor.m_Beta = 0.1f;
1371 descriptor.m_Eps = 0.0001f;
1377 network->AddInstanceNormalizationLayer(descriptor, layerName.c_str());
1387 CHECK(deserializedNetwork);
1390 layerName, {
info}, {
info}, descriptor);
1394 TEST_CASE(
"SerializeL2Normalization")
1396 const std::string l2NormLayerName(
"l2Normalization");
1401 desc.m_Eps = 0.0001f;
1415 CHECK(deserializedNetwork);
1418 l2NormLayerName, {
info}, {
info}, desc);
1422 TEST_CASE(
"EnsureL2NormalizationBackwardCompatibility")
1429 const std::vector<uint8_t> l2NormalizationModel =
1431 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1432 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1433 0x3C, 0x01, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1434 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xE8, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
1435 0x04, 0x00, 0x00, 0x00, 0xD6, 0xFE, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00,
1436 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x9E, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00,
1437 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1439 0x4C, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
1440 0x00, 0x20, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1441 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
1442 0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
1443 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x20, 0x00,
1444 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x6C, 0x32, 0x4E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74,
1445 0x69, 0x6F, 0x6E, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00,
1446 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1447 0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
1448 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1449 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1450 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
1451 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0A, 0x00,
1452 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00, 0x00, 0x00,
1453 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
1454 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1455 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00, 0x00, 0x00,
1456 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00,
1457 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
1458 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1459 0x05, 0x00, 0x00, 0x00, 0x00
1463 DeserializeNetwork(std::string(l2NormalizationModel.begin(), l2NormalizationModel.end()));
1464 CHECK(deserializedNetwork);
1466 const std::string layerName(
"l2Normalization");
1472 desc.m_Eps = 1e-12f;
1475 layerName, {inputInfo}, {inputInfo}, desc);
1479 TEST_CASE(
"SerializeLogicalBinary")
1481 const std::string layerName(
"logicalBinaryAnd");
1493 armnn::IConnectableLayer*
const logicalBinaryLayer = network->AddLogicalBinaryLayer(descriptor, layerName.c_str());
1505 CHECK(deserializedNetwork);
1508 layerName, { inputInfo, inputInfo }, { outputInfo }, descriptor);
1512 TEST_CASE(
"SerializeLogSoftmax")
1514 const std::string layerName(
"log_softmax");
1518 descriptor.
m_Beta = 1.0f;
1519 descriptor.m_Axis = -1;
1533 CHECK(deserializedNetwork);
1539 TEST_CASE(
"SerializeMaximum")
1541 const std::string layerName(
"maximum");
1559 CHECK(deserializedNetwork);
1565 TEST_CASE(
"SerializeMean")
1567 const std::string layerName(
"mean");
1572 descriptor.
m_Axis = { 2 };
1573 descriptor.m_KeepDims =
true;
1587 CHECK(deserializedNetwork);
1593 TEST_CASE(
"SerializeMerge")
1595 const std::string layerName(
"merge");
1613 CHECK(deserializedNetwork);
1622 MergerLayerVerifier(
const std::string& layerName,
1623 const std::vector<armnn::TensorInfo>& inputInfos,
1624 const std::vector<armnn::TensorInfo>& outputInfos,
1630 const std::vector<armnn::ConstTensor>& constants,
1641 throw armnn::Exception(
"MergerLayer should have translated to ConcatLayer");
1646 VerifyNameAndConnections(layer, name);
1649 VerifyDescriptor(layerDescriptor);
1660 TEST_CASE(
"EnsureMergerLayerBackwardCompatibility")
1667 const std::vector<uint8_t> mergerModel =
1669 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1670 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1671 0x38, 0x02, 0x00, 0x00, 0x8C, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00,
1672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1673 0xF4, 0xFD, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x92, 0xFE, 0xFF, 0xFF, 0x04, 0x00,
1674 0x00, 0x00, 0x9A, 0xFE, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x7E, 0xFE, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
1675 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1676 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1677 0xF8, 0xFE, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xFE, 0xFF, 0xFF, 0x00, 0x00,
1678 0x00, 0x1F, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1679 0x68, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00,
1680 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1681 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x22, 0xFF, 0xFF, 0xFF, 0x04, 0x00,
1682 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1683 0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
1684 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0xFF, 0xFF, 0xFF,
1685 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1C, 0x00,
1686 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x72, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1687 0x5C, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x34, 0xFF,
1688 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x92, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
1689 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
1690 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1691 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00,
1692 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00,
1693 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
1694 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00,
1695 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1696 0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
1697 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00,
1698 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1699 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
1700 0x00, 0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1701 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00,
1702 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
1703 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0A, 0x00,
1704 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00, 0x00, 0x00,
1705 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
1706 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1707 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00, 0x00, 0x00,
1708 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00,
1709 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
1710 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1711 0x02, 0x00, 0x00, 0x00
1715 CHECK(deserializedNetwork);
1720 const std::vector<armnn::TensorShape> shapes({inputInfo.
GetShape(), inputInfo.
GetShape()});
1725 MergerLayerVerifier verifier(
"merger", { inputInfo, inputInfo }, { outputInfo }, descriptor);
1726 deserializedNetwork->ExecuteStrategy(verifier);
1729 TEST_CASE(
"SerializeConcat")
1731 const std::string layerName(
"concat");
1735 const std::vector<armnn::TensorShape> shapes({inputInfo.
GetShape(), inputInfo.
GetShape()});
1756 CHECK(deserializedNetwork);
1760 MergerLayerVerifier verifier(layerName, {inputInfo, inputInfo}, {outputInfo}, descriptor);
1761 deserializedNetwork->ExecuteStrategy(verifier);
1764 TEST_CASE(
"SerializeMinimum")
1766 const std::string layerName(
"minimum");
1784 CHECK(deserializedNetwork);
1790 TEST_CASE(
"SerializeMultiplication")
1792 const std::string layerName(
"multiplication");
1810 CHECK(deserializedNetwork);
1816 TEST_CASE(
"SerializePrelu")
1818 const std::string layerName(
"prelu");
1839 CHECK(deserializedNetwork);
1841 LayerVerifierBase verifier(layerName, {inputTensorInfo, alphaTensorInfo}, {outputTensorInfo});
1845 TEST_CASE(
"SerializeNormalization")
1847 const std::string layerName(
"normalization");
1852 desc.m_NormSize = 3;
1869 CHECK(deserializedNetwork);
1875 TEST_CASE(
"SerializePad")
1877 const std::string layerName(
"pad");
1895 CHECK(deserializedNetwork);
1904 TEST_CASE(
"SerializePadReflect")
1906 const std::string layerName(
"padReflect");
1925 CHECK(deserializedNetwork);
1934 TEST_CASE(
"EnsurePadBackwardCompatibility")
1942 const std::vector<uint8_t> padModel =
1944 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1945 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1946 0x54, 0x01, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1947 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xD0, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
1948 0x04, 0x00, 0x00, 0x00, 0x96, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x9E, 0xFF, 0xFF, 0xFF, 0x04, 0x00,
1949 0x00, 0x00, 0x72, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1950 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
1951 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
1952 0x00, 0x00, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x16, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00,
1953 0x0E, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
1954 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00,
1955 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1956 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
1957 0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
1958 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00,
1959 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x70, 0x61, 0x64, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
1960 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00,
1961 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
1962 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00,
1963 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
1964 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00,
1965 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00,
1966 0x00, 0x00, 0x06, 0x00, 0x0A, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1967 0x0E, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00,
1968 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
1969 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
1970 0x08, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
1971 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00, 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1972 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
1973 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00
1977 CHECK(deserializedNetwork);
1988 TEST_CASE(
"SerializePermute")
1990 const std::string layerName(
"permute");
2008 CHECK(deserializedNetwork);
2011 layerName, {inputTensorInfo}, {outputTensorInfo}, descriptor);
2015 TEST_CASE(
"SerializePooling2d")
2017 const std::string layerName(
"pooling2d");
2024 desc.m_PadBottom = 0;
2026 desc.m_PadRight = 0;
2030 desc.m_PoolHeight = 2;
2031 desc.m_PoolWidth = 2;
2047 CHECK(deserializedNetwork);
2050 layerName, {inputInfo}, {outputInfo}, desc);
2054 TEST_CASE(
"SerializePooling3d")
2056 const std::string layerName(
"pooling3d");
2062 desc.m_PadFront = 0;
2065 desc.m_PadBottom = 0;
2067 desc.m_PadRight = 0;
2071 desc.m_PoolHeight = 2;
2072 desc.m_PoolWidth = 2;
2073 desc.m_PoolDepth = 2;
2090 CHECK(deserializedNetwork);
2093 layerName, {inputInfo}, {outputInfo}, desc);
2097 TEST_CASE(
"SerializeQuantize")
2099 const std::string layerName(
"quantize");
2114 CHECK(deserializedNetwork);
2120 TEST_CASE(
"SerializeRank")
2122 const std::string layerName(
"rank");
2138 CHECK(deserializedNetwork);
2144 TEST_CASE(
"SerializeReduceSum")
2146 const std::string layerName(
"Reduce_Sum");
2166 CHECK(deserializedNetwork);
2172 TEST_CASE(
"SerializeReshape")
2174 const std::string layerName(
"reshape");
2192 CHECK(deserializedNetwork);
2195 layerName, {inputInfo}, {outputInfo}, descriptor);
2199 TEST_CASE(
"SerializeResize")
2201 const std::string layerName(
"resize");
2207 desc.m_TargetHeight = 2;
2209 desc.m_AlignCorners =
true;
2210 desc.m_HalfPixelCenters =
true;
2224 CHECK(deserializedNetwork);
2233 ResizeBilinearLayerVerifier(
const std::string& layerName,
2234 const std::vector<armnn::TensorInfo>& inputInfos,
2235 const std::vector<armnn::TensorInfo>& outputInfos,
2238 layerName, inputInfos, outputInfos, descriptor) {}
2242 const std::vector<armnn::ConstTensor>& constants,
2253 VerifyNameAndConnections(layer, name);
2257 CHECK(layerDescriptor.
m_TargetWidth == m_Descriptor.m_TargetWidth);
2258 CHECK(layerDescriptor.
m_TargetHeight == m_Descriptor.m_TargetHeight);
2259 CHECK(layerDescriptor.
m_DataLayout == m_Descriptor.m_DataLayout);
2260 CHECK(layerDescriptor.
m_AlignCorners == m_Descriptor.m_AlignCorners);
2266 throw armnn::Exception(
"Unexpected layer type in test model. ResizeBiliniar " 2267 "should have translated to Resize");
2273 TEST_CASE(
"SerializeResizeBilinear")
2275 const std::string layerName(
"resizeBilinear");
2281 desc.m_TargetWidth = 4u;
2282 desc.m_TargetHeight = 2u;
2283 desc.m_AlignCorners =
true;
2284 desc.m_HalfPixelCenters =
true;
2298 CHECK(deserializedNetwork);
2300 ResizeBilinearLayerVerifier verifier(layerName, {inputInfo}, {outputInfo}, desc);
2301 deserializedNetwork->ExecuteStrategy(verifier);
2304 TEST_CASE(
"EnsureResizeBilinearBackwardCompatibility")
2311 const std::vector<uint8_t> resizeBilinearModel =
2313 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
2314 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2315 0x50, 0x01, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
2316 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xD4, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
2317 0x04, 0x00, 0x00, 0x00, 0xC2, 0xFE, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00,
2318 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x8A, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00,
2319 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
2320 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2321 0x38, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
2322 0x00, 0x1A, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
2323 0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x12, 0x00, 0x08, 0x00, 0x0C, 0x00,
2324 0x07, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2325 0x00, 0x00, 0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00,
2326 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00,
2327 0x20, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x69, 0x7A, 0x65, 0x42, 0x69, 0x6C, 0x69,
2328 0x6E, 0x65, 0x61, 0x72, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2329 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
2330 0x00, 0x00, 0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2331 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00,
2332 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2333 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
2334 0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
2335 0x0A, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00,
2336 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
2337 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00,
2339 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00,
2340 0x08, 0x00, 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
2341 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00,
2342 0x00, 0x00, 0x05, 0x00, 0x00, 0x00
2346 DeserializeNetwork(std::string(resizeBilinearModel.begin(), resizeBilinearModel.end()));
2347 CHECK(deserializedNetwork);
2354 descriptor.m_TargetHeight = 2u;
2356 ResizeBilinearLayerVerifier verifier(
"resizeBilinear", { inputInfo }, { outputInfo }, descriptor);
2357 deserializedNetwork->ExecuteStrategy(verifier);
2360 TEST_CASE(
"SerializeShape")
2362 const std::string layerName(
"shape");
2378 CHECK(deserializedNetwork);
2385 TEST_CASE(
"SerializeSlice")
2387 const std::string layerName{
"slice"};
2407 CHECK(deserializedNetwork);
2413 TEST_CASE(
"SerializeSoftmax")
2415 const std::string layerName(
"softmax");
2419 descriptor.
m_Beta = 1.0f;
2433 CHECK(deserializedNetwork);
2439 TEST_CASE(
"SerializeSpaceToBatchNd")
2441 const std::string layerName(
"spaceToBatchNd");
2447 desc.m_BlockShape = {2, 2};
2448 desc.m_PadList = {{0, 0}, {2, 0}};
2462 CHECK(deserializedNetwork);
2465 layerName, {inputInfo}, {outputInfo}, desc);
2469 TEST_CASE(
"SerializeSpaceToDepth")
2471 const std::string layerName(
"spaceToDepth");
2492 CHECK(deserializedNetwork);
2495 layerName, {inputInfo}, {outputInfo}, desc);
2499 TEST_CASE(
"SerializeSplitter")
2501 const unsigned int numViews = 3;
2502 const unsigned int numDimensions = 4;
2503 const unsigned int inputShape[] = {1, 18, 4, 4};
2504 const unsigned int outputShape[] = {1, 6, 4, 4};
2507 unsigned int splitterDimSizes[4] = {
static_cast<unsigned int>(inputShape[0]),
2508 static_cast<unsigned int>(inputShape[1]),
2509 static_cast<unsigned int>(inputShape[2]),
2510 static_cast<unsigned int>(inputShape[3])};
2511 splitterDimSizes[1] /= numViews;
2514 for (
unsigned int g = 0; g < numViews; ++g)
2518 for (
unsigned int dimIdx=0; dimIdx < 4; dimIdx++)
2520 desc.
SetViewSize(g, dimIdx, splitterDimSizes[dimIdx]);
2524 const std::string layerName(
"splitter");
2546 CHECK(deserializedNetwork);
2549 layerName, {inputInfo}, {outputInfo, outputInfo, outputInfo}, desc);
2553 TEST_CASE(
"SerializeStack")
2555 const std::string layerName(
"stack");
2577 CHECK(deserializedNetwork);
2580 layerName, {inputTensorInfo, inputTensorInfo}, {outputTensorInfo}, descriptor);
2584 TEST_CASE(
"SerializeStandIn")
2586 const std::string layerName(
"standIn");
2611 CHECK(deserializedNetwork);
2614 layerName, { tensorInfo, tensorInfo }, { tensorInfo, tensorInfo }, descriptor);
2618 TEST_CASE(
"SerializeStridedSlice")
2620 const std::string layerName(
"stridedSlice");
2624 armnn::StridedSliceDescriptor desc({0, 0, 1, 0}, {1, 1, 1, 1}, {1, 1, 1, 1});
2626 desc.m_ShrinkAxisMask = (1 << 1) | (1 << 2);
2641 CHECK(deserializedNetwork);
2644 layerName, {inputInfo}, {outputInfo}, desc);
2648 TEST_CASE(
"SerializeSubtraction")
2650 const std::string layerName(
"subtraction");
2668 CHECK(deserializedNetwork);
2674 TEST_CASE(
"SerializeSwitch")
2679 SwitchLayerVerifier(
const std::string& layerName,
2680 const std::vector<armnn::TensorInfo>& inputInfos,
2681 const std::vector<armnn::TensorInfo>& outputInfos)
2686 const std::vector<armnn::ConstTensor>& constants,
2698 VerifyNameAndConnections(layer, name);
2709 const std::string layerName(
"switch");
2712 std::vector<float> constantData = GenerateRandomData<float>(
info.GetNumElements());
2733 CHECK(deserializedNetwork);
2735 SwitchLayerVerifier verifier(layerName, {
info,
info}, {info, info});
2736 deserializedNetwork->ExecuteStrategy(verifier);
2739 TEST_CASE(
"SerializeTranspose")
2741 const std::string layerName(
"transpose");
2759 CHECK(deserializedNetwork);
2762 layerName, {inputTensorInfo}, {outputTensorInfo}, descriptor);
2766 TEST_CASE(
"SerializeTransposeConvolution2d")
2768 const std::string layerName(
"transposeConvolution2d");
2775 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
2778 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
2794 network->AddTransposeConvolution2dLayer(descriptor,
2807 CHECK(deserializedNetwork);
2809 const std::vector<armnn::ConstTensor> constants {weights, biases};
2811 layerName, {inputInfo}, {outputInfo}, descriptor, constants);
2815 TEST_CASE(
"SerializeDeserializeNonLinearNetwork")
2820 ConstantLayerVerifier(
const std::string& layerName,
2821 const std::vector<armnn::TensorInfo>& inputInfos,
2822 const std::vector<armnn::TensorInfo>& outputInfos,
2825 , m_LayerInput(layerInput) {}
2829 const std::vector<armnn::ConstTensor>& constants,
2841 VerifyNameAndConnections(layer, name);
2856 const std::string layerName(
"constant");
2859 std::vector<float> constantData = GenerateRandomData<float>(
info.GetNumElements());
2877 CHECK(deserializedNetwork);
2879 ConstantLayerVerifier verifier(layerName, {}, {
info}, constTensor);
2880 deserializedNetwork->ExecuteStrategy(verifier);
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
float m_ScaleW
Center size encoding scale weight.
bool m_BiasEnabled
Enable/disable bias.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
const TensorShape & GetShape() const
uint32_t m_PadBottom
Padding bottom value in the height dimension.
A ReshapeDescriptor for the ReshapeLayer.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
uint32_t m_PadBack
Padding back value in the depth dimension.
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A ComparisonDescriptor for the ComparisonLayer.
float m_ScaleX
Center size encoding scale x.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t m_PadLeft
Padding left value in the width dimension.
bool m_BiasEnabled
Enable/disable bias.
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0. ...
float m_Beta
Exponentiation value.
The padding fields don't count and are ignored.
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Copyright (c) 2021 ARM Limited and Contributors.
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
void IgnoreUnused(Ts &&...)
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_DilationY
Dilation along y axis.
int32_t m_EndMask
End mask value.
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_DilationY
Dilation factor value for height dimension.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
Base class for all descriptors.
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
A StackDescriptor for the StackLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
constexpr char const * GetUnaryOperationAsCString(UnaryOperation operation)
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_MaxDetections
Maximum numbers of detections.
A PadDescriptor for the PadLayer.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
float m_NmsIouThreshold
Intersection over union threshold.
#define ARMNN_NO_DEPRECATE_WARN_END
uint32_t m_DilationX
Dilation factor value for width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
Status SetViewSize(uint32_t view, uint32_t coord, uint32_t value)
Set the size of the views.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A L2NormalizationDescriptor for the L2NormalizationLayer.
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
An ArgMinMaxDescriptor for ArgMinMaxLayer.
An OriginsDescriptor for the ConcatLayer.
A ReduceDescriptor for the REDUCE operators.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_BiasEnabled
Enable/disable bias.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
uint32_t m_TargetWidth
Target width value.
A GatherDescriptor for the GatherLayer.
uint32_t m_NumClasses
Number of classes.
bool m_HalfPixelCenters
Half Pixel Centers.
uint32_t m_PadTop
Padding top value in the height dimension.
void SetQuantizationScale(float scale)
A StandInDescriptor for the StandIn layer.
LayerVerifierBase(const std::string &layerName, const std::vector< armnn::TensorInfo > &inputInfos, const std::vector< armnn::TensorInfo > &outputInfos)
bool m_UseRegularNms
Use Regular NMS.
uint32_t m_PadFront
Padding front value in the depth dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_TargetHeight
Target height value.
A SliceDescriptor for the SliceLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
A Convolution3dDescriptor for the Convolution3dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
PaddingMode m_PaddingMode
Specifies the Padding mode (Constant, Reflect or Symmetric)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A Pooling3dDescriptor for the Pooling3dLayer.
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
float m_ScaleH
Center size encoding scale height.
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
DataLayout m_DataLayout
The data layout to be used (NDHWC, NCDHW).
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_PadLeft
Padding left value in the width dimension.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
bool m_AlignCorners
Aligned corners.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
int32_t m_Axis
The axis in params to gather indices from.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
TEST_SUITE("SerializerTests")
Base class for all ArmNN exceptions so that users can filter to just those.
uint32_t m_PadTop
Padding top value in the height dimension.
void CompareConstTensor(const armnn::ConstTensor &tensor1, const armnn::ConstTensor &tensor2)
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A MeanDescriptor for the MeanLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
A TransposeDescriptor for the TransposeLayer.
A StridedSliceDescriptor for the StridedSliceLayer.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
float m_ScaleY
Center size encoding scale y.
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
float m_NmsScoreThreshold
NMS score threshold.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
virtual int Connect(IInputSlot &destination)=0
A Pooling2dDescriptor for the Pooling2dLayer.
std::string SerializeNetwork(const armnn::INetwork &network)
A NormalizationDescriptor for the NormalizationLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
A ChannelShuffleDescriptor for the ChannelShuffle operator.
static INetworkPtr Create(NetworkOptions networkOptions={})
uint32_t m_DilationZ
Dilation along z axis.
A SoftmaxDescriptor for the SoftmaxLayer.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
Status SetViewOriginCoord(uint32_t view, uint32_t coord, uint32_t value)
Set the view origin coordinates.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
uint32_t m_DilationY
Dilation along y axis.
A FillDescriptor for the FillLayer.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
uint32_t m_PadLeft
Padding left value in the width dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A PermuteDescriptor for the PermuteLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
bool m_ConstantWeights
Enable/disable constant weights and biases.