aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaCommon/test/TosaTestUtils.hpp
diff options
context:
space:
mode:
authorTeresa Charlin <teresa.charlinreyes@arm.com>2023-11-21 15:44:13 +0000
committerTeresaARM <teresa.charlinreyes@arm.com>2023-12-13 14:33:54 +0000
commitce65588484ed1e553bdebf24123a30b5575f1bce (patch)
treeba5229241cdeee6d9c6ed0c0db9ffbd510574b34 /src/backends/tosaCommon/test/TosaTestUtils.hpp
parent1685bcca5dae227d90be62b36d66e9897298ce84 (diff)
downloadarmnn-ce65588484ed1e553bdebf24123a30b5575f1bce.tar.gz
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
Diffstat (limited to 'src/backends/tosaCommon/test/TosaTestUtils.hpp')
-rw-r--r--src/backends/tosaCommon/test/TosaTestUtils.hpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/backends/tosaCommon/test/TosaTestUtils.hpp b/src/backends/tosaCommon/test/TosaTestUtils.hpp
index e24055371f..87ff5ff532 100644
--- a/src/backends/tosaCommon/test/TosaTestUtils.hpp
+++ b/src/backends/tosaCommon/test/TosaTestUtils.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -125,16 +125,65 @@ inline void VerifyTosaAttribute(const BaseDescriptor& descriptor,
break;
}
+ case LayerType::Resize:
+ {
+ auto resizeDesc = PolymorphicDowncast<const ResizeDescriptor*>(&descriptor);
+ TosaResizeAttribute resizeAttribute(attribute);
+
+ // Check output shape
+ uint32_t outputHeight = resizeDesc->m_TargetHeight;
+ uint32_t outputWidth = resizeDesc->m_TargetWidth;
+
+ CHECK((outputShape.size() == 4));
+ if (resizeDesc->m_DataLayout == DataLayout::NHWC)
+ {
+ //Check output is not dynamic
+ CHECK((outputShape[1] > 0));
+ CHECK((outputShape[2] > 0));
+
+ CHECK((outputHeight == static_cast<uint32_t>(outputShape[1])));
+ CHECK((outputWidth == static_cast<uint32_t>(outputShape[2])));
+ }
+ else if (resizeDesc->m_DataLayout == DataLayout::NCHW)
+ {
+ //Check output is not dynamic
+ CHECK((outputShape[2] > 0));
+ CHECK((outputShape[3] > 0));
+
+ CHECK((outputHeight == static_cast<uint32_t>(outputShape[2])));
+ CHECK((outputWidth == static_cast<uint32_t>(outputShape[3])));
+ }
+ else
+ {
+ throw armnn::Exception("VerifyTosaAttribute: Invalid DataLayout in Resize.");
+ }
+
+ // Check Resize mode/method
+ if (resizeDesc->m_Method == ResizeMethod::NearestNeighbor)
+ {
+ CHECK((resizeAttribute.mode() == tosa::ResizeMode_NEAREST));
+ }
+ else if (resizeDesc->m_Method == ResizeMethod::Bilinear)
+ {
+ CHECK((resizeAttribute.mode() == tosa::ResizeMode_BILINEAR));
+ }
+ else
+ {
+ throw armnn::Exception("VerifyTosaAttribute: Unsupported Resize method.");
+ }
+
+ break;
+ }
case LayerType::Slice:
{
auto sliceDesc = PolymorphicDowncast<const SliceDescriptor*>(&descriptor);
- TosaSliceAttribute reshapeAttribute(attribute);
+ TosaSliceAttribute sliceAttribute(attribute);
std::vector<int32_t> begin(sliceDesc->m_Begin.begin(), sliceDesc->m_Begin.end());
std::vector<int32_t> size(sliceDesc->m_Size.begin(), sliceDesc->m_Size.end());
- CHECK(begin == reshapeAttribute.start());
- CHECK(size == reshapeAttribute.size());
+ CHECK(begin == sliceAttribute.start());
+ CHECK(size == sliceAttribute.size());
CHECK(begin.size() == inputShape.size());
CHECK(size.size() == inputShape.size());