diff options
Diffstat (limited to 'src/backends/reference/workloads/Resize.cpp')
-rw-r--r-- | src/backends/reference/workloads/Resize.cpp | 11 |
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(); |