aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/Resize.cpp
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2020-01-08 10:25:24 +0000
committermike.kelly <mike.kelly@arm.com>2020-02-07 11:08:02 +0000
commit820eb141a7a5d0eef200ccf9554a37eabade3264 (patch)
tree2f4301b02cc47cbade8e723765822847d87d79e4 /src/backends/reference/workloads/Resize.cpp
parent7e75281e9f8d8dd49c33dd61d50da2a434816b2b (diff)
downloadarmnn-820eb141a7a5d0eef200ccf9554a37eabade3264.tar.gz
MLCE-139: add capability to align corners for bilinear resize
* Add parsing of the related parameter to TfLiteParser * Update ResizeDescriptor to store the additional parameter * Update NEON/CL workload to pass the additional parameter. * Update Reference workload to pass and handle the additional parameter. !ComputeLibrary:2538 !ComputeLibrary:2569 !armnn:2612 Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com> Change-Id: Id149e1c24c2abed7e9dd81939acf54dfabfcdfd2
Diffstat (limited to 'src/backends/reference/workloads/Resize.cpp')
-rw-r--r--src/backends/reference/workloads/Resize.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backends/reference/workloads/Resize.cpp b/src/backends/reference/workloads/Resize.cpp
index 3050bae870..a26e34a1ff 100644
--- a/src/backends/reference/workloads/Resize.cpp
+++ b/src/backends/reference/workloads/Resize.cpp
@@ -37,7 +37,8 @@ void Resize(Decoder<float>& in,
Encoder<float>& out,
const TensorInfo& outputInfo,
DataLayoutIndexed dataLayout,
- armnn::ResizeMethod resizeMethod)
+ armnn::ResizeMethod resizeMethod,
+ bool alignCorners)
{
// We follow the definition of TensorFlow and AndroidNN: the top-left corner of a texel in the output
// image is projected into the input image to figure out the interpolants and weights. Note that this
@@ -51,10 +52,14 @@ void Resize(Decoder<float>& in,
const unsigned int outputHeight = outputInfo.GetShape()[dataLayout.GetHeightIndex()];
const unsigned int outputWidth = outputInfo.GetShape()[dataLayout.GetWidthIndex()];
+ const unsigned int sizeOffset = resizeMethod == armnn::ResizeMethod::Bilinear && alignCorners ? 1 : 0;
+
// How much to scale pixel coordinates in the output image, to get the corresponding pixel coordinates
// in the input image.
- const float scaleY = boost::numeric_cast<float>(inputHeight) / boost::numeric_cast<float>(outputHeight);
- const float scaleX = boost::numeric_cast<float>(inputWidth) / boost::numeric_cast<float>(outputWidth);
+ const float scaleY = boost::numeric_cast<float>(inputHeight - sizeOffset)
+ / boost::numeric_cast<float>(outputHeight - sizeOffset);
+ const float scaleX = boost::numeric_cast<float>(inputWidth - sizeOffset)
+ / boost::numeric_cast<float>(outputWidth - sizeOffset);
TensorShape inputShape = inputInfo.GetShape();
TensorShape outputShape = outputInfo.GetShape();