Add Resize Nearest Neighbour support to TOSA Reference Backend
* Add support for quantized data in TosaRefPreCompiledWorkloadGetOutput.
* Remove extra includes from all TOSA operators headers.
* Added positive and negative unit tests for resize.
* Resolves: IVGCVSW-7346
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: Ib6e30d018a7a1bf26b380fc794560aae108b26c3
diff --git a/src/backends/backendsCommon/WorkloadData.cpp b/src/backends/backendsCommon/WorkloadData.cpp
index 021435e..2d7a5fd 100644
--- a/src/backends/backendsCommon/WorkloadData.cpp
+++ b/src/backends/backendsCommon/WorkloadData.cpp
@@ -1592,6 +1592,7 @@
DataType::Float32,
DataType::QAsymmS8,
DataType::QAsymmU8,
+ DataType::QSymmS8,
DataType::QSymmS16
};
diff --git a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp
index f8d17a8..071daa7 100644
--- a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp
+++ b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017, 2019-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -37,7 +37,9 @@
template<armnn::DataType ArmnnType>
void ResizeEndToEnd(const std::vector<armnn::BackendId>& backends,
armnn::DataLayout dataLayout,
- armnn::ResizeMethod resizeMethod)
+ armnn::ResizeMethod resizeMethod,
+ bool alignCorners = false,
+ bool halfPixel = false)
{
using namespace armnn;
using T = ResolveType<ArmnnType>;
@@ -64,6 +66,11 @@
7.f, 8.f, 9.f
};
+ if (alignCorners && halfPixel)
+ {
+ throw InvalidArgumentException("alignCorners and halfPixel cannot be true simultaneously ");
+ }
+
std::vector<float> expectedOutputData;
switch(resizeMethod)
{
@@ -81,14 +88,42 @@
}
case ResizeMethod::NearestNeighbor:
{
- expectedOutputData =
+ if (alignCorners)
{
- 1.f, 1.f, 2.f, 2.f, 3.f,
- 1.f, 1.f, 2.f, 2.f, 3.f,
- 4.f, 4.f, 5.f, 5.f, 6.f,
- 4.f, 4.f, 5.f, 5.f, 6.f,
- 7.f, 7.f, 8.f, 8.f, 9.f
- };
+ expectedOutputData =
+ {
+ 1.f, 2.f, 2.f, 3.f, 3.f,
+ 4.f, 5.f, 5.f, 6.f, 6.f,
+ 4.f, 5.f, 5.f, 6.f, 6.f,
+ 7.f, 8.f, 8.f, 9.f, 9.f,
+ 7.f, 8.f, 8.f, 9.f, 9.f
+ };
+ }
+ else
+ {
+ if (halfPixel)
+ {
+ expectedOutputData =
+ {
+ 1.f, 1.f, 2.f, 3.f, 3.f,
+ 1.f, 1.f, 2.f, 3.f, 3.f,
+ 4.f, 4.f, 5.f, 6.f, 6.f,
+ 7.f, 7.f, 8.f, 9.f, 9.f,
+ 7.f, 7.f, 8.f, 9.f, 9.f
+ };
+ }
+ else
+ {
+ expectedOutputData =
+ {
+ 1.f, 1.f, 2.f, 2.f, 3.f,
+ 1.f, 1.f, 2.f, 2.f, 3.f,
+ 4.f, 4.f, 5.f, 5.f, 6.f,
+ 4.f, 4.f, 5.f, 5.f, 6.f,
+ 7.f, 7.f, 8.f, 8.f, 9.f
+ };
+ }
+ }
break;
}
default:
@@ -102,6 +137,9 @@
descriptor.m_TargetHeight = outputHeight;
descriptor.m_Method = resizeMethod;
descriptor.m_DataLayout = dataLayout;
+ descriptor.m_AlignCorners = alignCorners;
+ descriptor.m_HalfPixelCenters = halfPixel;
+
// swizzle data if needed
if (dataLayout == armnn::DataLayout::NHWC)
@@ -137,7 +175,9 @@
template<armnn::DataType ArmnnType>
void ResizeNearestNeighborEndToEnd(const std::vector<armnn::BackendId>& backends,
- armnn::DataLayout dataLayout)
+ armnn::DataLayout dataLayout,
+ bool alignCorners = false,
+ bool halfPixel = false)
{
- ResizeEndToEnd<ArmnnType>(backends, dataLayout, armnn::ResizeMethod::NearestNeighbor);
+ ResizeEndToEnd<ArmnnType>(backends, dataLayout, armnn::ResizeMethod::NearestNeighbor, alignCorners, halfPixel);
}