diff options
author | James Conroy <james.conroy@arm.com> | 2018-10-11 12:39:05 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-22 16:57:53 +0100 |
commit | 595408218a0e17f04d91ff131a8227a4f352ff61 (patch) | |
tree | 515316e28abbed3dce388bc99be5ff52bc042765 /src/backends/reference/workloads/ResizeBilinear.cpp | |
parent | a0944791e87902b35e06c306c7b1a6f0f5bbfbd7 (diff) | |
download | armnn-595408218a0e17f04d91ff131a8227a4f352ff61.tar.gz |
IVGCVSW-1978: Support NHWC for ResizeBilinear CpuRef
* Adds implementation to plumb DataLayout parameter
for ResizeBilinear on CpuRef.
* Adds unit tests to execute ResizeBilinear on CpuRef
using the NHWC data layout.
* Adds DataLayoutIndexed API, allowing easy access to
the Channels, Height and Width of a tensor based on
its data layout. This reduces code duplication.
* Refactors original ResizeBilinear implementation and
tests to use the DataLayoutIndexed API when required.
Change-Id: Ic2b8916cdd2e370d070175547079d774daf6d7bf
Diffstat (limited to 'src/backends/reference/workloads/ResizeBilinear.cpp')
-rw-r--r-- | src/backends/reference/workloads/ResizeBilinear.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backends/reference/workloads/ResizeBilinear.cpp b/src/backends/reference/workloads/ResizeBilinear.cpp index 0bce3c7ed8..e098c6c20d 100644 --- a/src/backends/reference/workloads/ResizeBilinear.cpp +++ b/src/backends/reference/workloads/ResizeBilinear.cpp @@ -25,27 +25,31 @@ inline float Lerp(float a, float b, float w) } -void ResizeBilinear(const float* in, const TensorInfo& inputInfo, float* out, const TensorInfo& outputInfo) +void ResizeBilinear(const float* in, + const TensorInfo& inputInfo, + float* out, + const TensorInfo& outputInfo, + DataLayoutIndexed dataLayout) { // 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 // will yield different results than if projecting the centre of output texels. const unsigned int batchSize = inputInfo.GetShape()[0]; - const unsigned int channelCount = inputInfo.GetShape()[1]; + const unsigned int channelCount = inputInfo.GetShape()[dataLayout.GetChannelsIndex()]; - const unsigned int inputHeight = inputInfo.GetShape()[2]; - const unsigned int inputWidth = inputInfo.GetShape()[3]; - const unsigned int outputHeight = outputInfo.GetShape()[2]; - const unsigned int outputWidth = outputInfo.GetShape()[3]; + const unsigned int inputHeight = inputInfo.GetShape()[dataLayout.GetHeightIndex()]; + const unsigned int inputWidth = inputInfo.GetShape()[dataLayout.GetWidthIndex()]; + const unsigned int outputHeight = outputInfo.GetShape()[dataLayout.GetHeightIndex()]; + const unsigned int outputWidth = outputInfo.GetShape()[dataLayout.GetWidthIndex()]; // 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); - TensorBufferArrayView<const float> input(inputInfo.GetShape(), in); - TensorBufferArrayView<float> output(outputInfo.GetShape(), out); + TensorBufferArrayView<const float> input(inputInfo.GetShape(), in, dataLayout); + TensorBufferArrayView<float> output(outputInfo.GetShape(), out, dataLayout); for (unsigned int n = 0; n < batchSize; ++n) { |