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/TensorBufferArrayView.hpp | |
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/TensorBufferArrayView.hpp')
-rw-r--r-- | src/backends/reference/workloads/TensorBufferArrayView.hpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/backends/reference/workloads/TensorBufferArrayView.hpp b/src/backends/reference/workloads/TensorBufferArrayView.hpp index e19810ca87..aba44e4593 100644 --- a/src/backends/reference/workloads/TensorBufferArrayView.hpp +++ b/src/backends/reference/workloads/TensorBufferArrayView.hpp @@ -15,28 +15,33 @@ template <typename DataType> class TensorBufferArrayView { public: - TensorBufferArrayView(const TensorShape& shape, DataType* data) + TensorBufferArrayView(const TensorShape& shape, DataType* data, DataLayoutIndexed dataLayout = DataLayout::NCHW) : m_Shape(shape) , m_Data(data) + , m_DataLayout(dataLayout) { } DataType& Get(unsigned int b, unsigned int c, unsigned int h, unsigned int w) const { - BOOST_ASSERT( b < m_Shape[0] || (m_Shape[0] == 0 && b == 0) ); - BOOST_ASSERT( c < m_Shape[1] || (m_Shape[1] == 0 && c == 0) ); - BOOST_ASSERT( h < m_Shape[2] || (m_Shape[2] == 0 && h == 0) ); - BOOST_ASSERT( w < m_Shape[3] || (m_Shape[3] == 0 && w == 0) ); + BOOST_ASSERT( b < m_Shape[0] || ( m_Shape[0] == 0 && b == 0 ) ); + BOOST_ASSERT( c < m_Shape[m_DataLayout.GetChannelsIndex()] || + ( m_Shape[m_DataLayout.GetChannelsIndex()] == 0 && c == 0) ); + BOOST_ASSERT( h < m_Shape[m_DataLayout.GetHeightIndex()] || + ( m_Shape[m_DataLayout.GetHeightIndex()] == 0 && h == 0) ); + BOOST_ASSERT( w < m_Shape[m_DataLayout.GetWidthIndex()] || + ( m_Shape[m_DataLayout.GetWidthIndex()] == 0 && w == 0) ); return m_Data[b * m_Shape[1] * m_Shape[2] * m_Shape[3] - + c * m_Shape[2] * m_Shape[3] - + h * m_Shape[3] + + c * m_Shape[m_DataLayout.GetHeightIndex()] * m_Shape[m_DataLayout.GetWidthIndex()] + + h * m_Shape[m_DataLayout.GetWidthIndex()] + w]; } private: const TensorShape m_Shape; - DataType* m_Data; + DataType* m_Data; + DataLayoutIndexed m_DataLayout; }; } //namespace armnn |