diff options
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/backendsCommon/WorkloadData.cpp | 4 | ||||
-rw-r--r-- | src/backends/backendsCommon/test/ReverseV2EndToEndTestImpl.hpp | 72 | ||||
-rw-r--r-- | src/backends/reference/RefLayerSupport.cpp | 6 | ||||
-rw-r--r-- | src/backends/reference/test/RefEndToEndTests.cpp | 37 |
4 files changed, 116 insertions, 3 deletions
diff --git a/src/backends/backendsCommon/WorkloadData.cpp b/src/backends/backendsCommon/WorkloadData.cpp index 7efca9de50..aa6bb848e5 100644 --- a/src/backends/backendsCommon/WorkloadData.cpp +++ b/src/backends/backendsCommon/WorkloadData.cpp @@ -1656,7 +1656,9 @@ void ReverseV2QueueDescriptor::Validate(const WorkloadInfo &workloadInfo) const DataType::Float32, DataType::QAsymmS8, DataType::QAsymmU8, - DataType::QSymmS16 + DataType::QSymmS8, + DataType::QSymmS16, + DataType::Signed32 }; ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName); diff --git a/src/backends/backendsCommon/test/ReverseV2EndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ReverseV2EndToEndTestImpl.hpp new file mode 100644 index 0000000000..b36d2eeb59 --- /dev/null +++ b/src/backends/backendsCommon/test/ReverseV2EndToEndTestImpl.hpp @@ -0,0 +1,72 @@ +// +// Copyright © 2023 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +namespace +{ + +armnn::INetworkPtr CreateReverseV2Network(const armnn::TensorInfo& inputInfo, + const armnn::TensorInfo& axisInfo, + const armnn::TensorInfo& outputInfo, + const std::vector<int32_t>& axisData) +{ + using namespace armnn; + + INetworkPtr network(INetwork::Create()); + + IConnectableLayer* inputLayer = network->AddInputLayer(0, "input"); + IConnectableLayer* axisLayer = network->AddConstantLayer(ConstTensor(axisInfo, axisData)); + IConnectableLayer* reverseLayer = network->AddReverseV2Layer("reverseV2"); + IConnectableLayer* outputLayer = network->AddOutputLayer(0, "output"); + + Connect(inputLayer, reverseLayer, inputInfo, 0, 0); + Connect(axisLayer, reverseLayer, axisInfo, 0, 1); + Connect(reverseLayer, outputLayer, outputInfo, 0, 0); + + return network; +} + +template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> +void ReverseV2EndToEnd(const std::vector<BackendId>& backends) +{ + float qScale = 1.0f; + int32_t qOffset = 0; + bool qConst = true; + + TensorInfo inputInfo ( { 2, 3, 4 }, ArmnnType, qScale, qOffset, qConst); + TensorInfo axisInfo ( { 1 } , DataType::Signed32, qScale, qOffset, qConst); + TensorInfo outputInfo ( { 2, 3, 4 }, ArmnnType, qScale, qOffset); + + std::vector<T> inputData = armnnUtils::QuantizedVector<T>({ + 1, 2, 3, 4, + 5, 6 , 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16, + 17, 18, 19, 20, + 21, 22, 23, 24 + }, qScale, qOffset); + + std::vector<int32_t> axisData = { 1 }; + + std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>({ + 9, 10, 11, 12, + 5, 6, 7 , 8, + 1, 2, 3, 4, + 21, 22, 23, 24, + 17, 18, 19, 20, + 13, 14, 15, 16 + }, qScale, qOffset); + + INetworkPtr network = CreateReverseV2Network(inputInfo, axisInfo, outputInfo, axisData); + + std::map<int, std::vector<T>> inputTensor = { { 0, inputData } }; + std::map<int, std::vector<T>> expectedOutputTensor = { { 0, expectedOutputData } }; + + EndToEndLayerTestImpl<ArmnnType, ArmnnType>(std::move(network), inputTensor, expectedOutputTensor, backends); +} + +} // anonymous namespace + diff --git a/src/backends/reference/RefLayerSupport.cpp b/src/backends/reference/RefLayerSupport.cpp index 9d396e5db9..2e845a8c51 100644 --- a/src/backends/reference/RefLayerSupport.cpp +++ b/src/backends/reference/RefLayerSupport.cpp @@ -2373,14 +2373,16 @@ bool RefLayerSupport::IsReverseV2Supported(const TensorInfo& input0, { bool supported = true; // ReverseV2 is data type agnostic so it can support all the types in the Reference backend - std::array<DataType,6> supportedTypes = + std::array<DataType,8> supportedTypes = { DataType::BFloat16, DataType::Float32, DataType::Float16, DataType::QAsymmS8, DataType::QAsymmU8, - DataType::QSymmS16 + DataType::QSymmS8, + DataType::QSymmS16, + DataType::Signed32 }; supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, diff --git a/src/backends/reference/test/RefEndToEndTests.cpp b/src/backends/reference/test/RefEndToEndTests.cpp index 6f05ba77cb..fc62a89dd7 100644 --- a/src/backends/reference/test/RefEndToEndTests.cpp +++ b/src/backends/reference/test/RefEndToEndTests.cpp @@ -32,6 +32,7 @@ #include <backendsCommon/test/ReduceEndToEndTestImpl.hpp> #include <backendsCommon/test/ReshapeEndToEndTestImpl.hpp> #include <backendsCommon/test/ResizeEndToEndTestImpl.hpp> +#include <backendsCommon/test/ReverseV2EndToEndTestImpl.hpp> #include <backendsCommon/test/SpaceToDepthEndToEndTestImpl.hpp> #include <backendsCommon/test/SplitterEndToEndTestImpl.hpp> #include <backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp> @@ -1322,6 +1323,42 @@ TEST_CASE("RefResizeNearestNeighborEndToEndInt16NhwcTest") ResizeNearestNeighborEndToEnd<armnn::DataType::QSymmS16>(defaultBackends, armnn::DataLayout::NHWC); } +// ReverseV2 +TEST_CASE("RefReverseV2EndToEndFloat16Test") +{ + ReverseV2EndToEnd<armnn::DataType::Float16>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndFloat32Test") +{ + ReverseV2EndToEnd<armnn::DataType::Float32>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndQAsymmS8Test") +{ + ReverseV2EndToEnd<armnn::DataType::QAsymmS8>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndQAsymmU8Test") +{ + ReverseV2EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndQSymmS8Test") +{ + ReverseV2EndToEnd<armnn::DataType::QSymmS8>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndQSymmS16Test") +{ + ReverseV2EndToEnd<armnn::DataType::QSymmS16>(defaultBackends); +} + +TEST_CASE("RefReverseV2EndToEndSigned32Test") +{ + ReverseV2EndToEnd<armnn::DataType::Signed32>(defaultBackends); +} + // InstanceNormalization TEST_CASE("RefInstanceNormalizationNhwcEndToEndTest1") { |