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/armnn | |
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/armnn')
-rw-r--r-- | src/armnn/InternalTypes.cpp | 12 | ||||
-rw-r--r-- | src/armnn/test/CreateWorkload.hpp | 21 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/armnn/InternalTypes.cpp b/src/armnn/InternalTypes.cpp index fce1e95429..67c596eec7 100644 --- a/src/armnn/InternalTypes.cpp +++ b/src/armnn/InternalTypes.cpp @@ -48,4 +48,16 @@ char const* GetLayerTypeAsCString(LayerType type) } } +// Definition in include/armnn/Types.hpp +bool operator==(const DataLayout& dataLayout, const DataLayoutIndexed& indexed) +{ + return dataLayout == indexed.GetDataLayout(); +} + +// Definition in include/armnn/Types.hpp +bool operator==(const DataLayoutIndexed& indexed, const DataLayout& dataLayout) +{ + return indexed.GetDataLayout() == dataLayout; +} + } diff --git a/src/armnn/test/CreateWorkload.hpp b/src/armnn/test/CreateWorkload.hpp index b9735f4f2f..a33189efeb 100644 --- a/src/armnn/test/CreateWorkload.hpp +++ b/src/armnn/test/CreateWorkload.hpp @@ -820,31 +820,26 @@ void CreateSplitterMultipleInputsOneOutputWorkloadTest(armnn::IWorkloadFactory& template <typename ResizeBilinearWorkload, armnn::DataType DataType> std::unique_ptr<ResizeBilinearWorkload> CreateResizeBilinearWorkloadTest(armnn::IWorkloadFactory& factory, armnn::Graph& graph, - DataLayout dataLayout = DataLayout::NCHW) + DataLayoutIndexed dataLayout = + DataLayout::NCHW) { TensorShape inputShape; TensorShape outputShape; - unsigned int heightIndex; - unsigned int widthIndex; - switch (dataLayout) { + switch (dataLayout.GetDataLayout()) { case DataLayout::NHWC: - inputShape = { 2, 4, 4, 3 }; + inputShape = { 2, 4, 4, 3 }; outputShape = { 2, 2, 2, 3 }; - heightIndex = 1; - widthIndex = 2; break; default: // NCHW - inputShape = { 2, 3, 4, 4 }; + inputShape = { 2, 3, 4, 4 }; outputShape = { 2, 3, 2, 2 }; - heightIndex = 2; - widthIndex = 3; } // Creates the layer we're testing. ResizeBilinearDescriptor resizeDesc; - resizeDesc.m_TargetWidth = outputShape[widthIndex]; - resizeDesc.m_TargetHeight = outputShape[heightIndex]; + resizeDesc.m_TargetWidth = outputShape[dataLayout.GetWidthIndex()]; + resizeDesc.m_TargetHeight = outputShape[dataLayout.GetHeightIndex()]; resizeDesc.m_DataLayout = dataLayout; Layer* const layer = graph.AddLayer<ResizeBilinearLayer>(resizeDesc, "layer"); @@ -865,7 +860,7 @@ std::unique_ptr<ResizeBilinearWorkload> CreateResizeBilinearWorkloadTest(armnn:: ResizeBilinearQueueDescriptor queueDescriptor = workload->GetData(); BOOST_TEST(queueDescriptor.m_Inputs.size() == 1); BOOST_TEST(queueDescriptor.m_Outputs.size() == 1); - BOOST_TEST((queueDescriptor.m_Parameters.m_DataLayout == dataLayout)); + BOOST_TEST((queueDescriptor.m_Parameters.m_DataLayout.GetDataLayout() == dataLayout)); // Returns so we can do extra, backend-specific tests. return workload; |