aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference
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
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')
-rw-r--r--src/backends/reference/workloads/RefResizeWorkload.cpp8
-rw-r--r--src/backends/reference/workloads/Resize.cpp11
-rw-r--r--src/backends/reference/workloads/Resize.hpp3
3 files changed, 17 insertions, 5 deletions
diff --git a/src/backends/reference/workloads/RefResizeWorkload.cpp b/src/backends/reference/workloads/RefResizeWorkload.cpp
index 26225f8823..624b426cbf 100644
--- a/src/backends/reference/workloads/RefResizeWorkload.cpp
+++ b/src/backends/reference/workloads/RefResizeWorkload.cpp
@@ -29,7 +29,13 @@ void RefResizeWorkload::Execute() const
std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputInfo, m_Data.m_Outputs[0]->Map());
Encoder<float> &encoder = *encoderPtr;
- Resize(decoder, inputInfo, encoder, outputInfo, m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_Method);
+ Resize(decoder,
+ inputInfo,
+ encoder,
+ outputInfo,
+ m_Data.m_Parameters.m_DataLayout,
+ m_Data.m_Parameters.m_Method,
+ m_Data.m_Parameters.m_BilinearAlignCorners);
}
} //namespace armnn
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();
diff --git a/src/backends/reference/workloads/Resize.hpp b/src/backends/reference/workloads/Resize.hpp
index 4c357946d9..cd8835fa08 100644
--- a/src/backends/reference/workloads/Resize.hpp
+++ b/src/backends/reference/workloads/Resize.hpp
@@ -19,6 +19,7 @@ void Resize(Decoder<float>& in,
Encoder<float>& out,
const TensorInfo& outputInfo,
armnnUtils::DataLayoutIndexed dataLayout = DataLayout::NCHW,
- ResizeMethod resizeMethod = ResizeMethod::NearestNeighbor);
+ ResizeMethod resizeMethod = ResizeMethod::NearestNeighbor,
+ bool alignConers = false);
} // namespace armnn