aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test/layerTests
diff options
context:
space:
mode:
authorAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-10-01 18:35:44 +0100
committerAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-10-02 15:00:53 +0100
commitf97f6da835802187da03f597dcc30386c7b9b15b (patch)
treec936cb6f4c38e19f39bfc935aadff0219d6a38b8 /src/backends/backendsCommon/test/layerTests
parent680f9911d9d9b369fe321ee2dad014012fb5b20f (diff)
downloadarmnn-f97f6da835802187da03f597dcc30386c7b9b15b.tar.gz
IVGCVSW-3738 Add end-to-end layer test for DepthToSpace
* Added end-to-end layer test implementation for DepthToSpace * Added test to reference, CL and NEON backends for all supported data types and data layouts * Extracted common data permutation code into new utility file and refactored some existing tests to reduce code duplication * Fixed EndToEndLayerTestImpl template to work with Float16 data Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> Change-Id: Iaf7a0012c520451052b20c37e36dc05fa8314ff6
Diffstat (limited to 'src/backends/backendsCommon/test/layerTests')
-rw-r--r--src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp17
-rw-r--r--src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.hpp49
2 files changed, 22 insertions, 44 deletions
diff --git a/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp
index 9588f560ef..e21a4b64f8 100644
--- a/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp
@@ -9,6 +9,7 @@
#include <armnn/ArmNN.hpp>
+#include <backendsCommon/test/DataLayoutUtils.hpp>
#include <backendsCommon/test/TensorCopyUtils.hpp>
#include <backendsCommon/test/WorkloadTestUtils.hpp>
@@ -29,22 +30,10 @@ LayerTestResult<T, 4> DepthToSpaceTestImpl(
const float qScale = 1.0f,
const int32_t qOffset = 0)
{
- const armnn::PermutationVector permVector{0, 2, 3, 1};
-
if (descriptor.m_Parameters.m_DataLayout == armnn::DataLayout::NCHW)
{
- inputInfo = armnnUtils::Permuted(inputInfo, permVector);
- outputInfo = armnnUtils::Permuted(outputInfo, permVector);
-
- constexpr size_t typeSize = sizeof(float);
-
- std::vector<float> inputTmp(inputData.size());
- armnnUtils::Permute(inputInfo.GetShape(), permVector, inputData.data(), inputTmp.data(), typeSize);
- inputData = inputTmp;
-
- std::vector<float> outputTmp(expectedOutputData.size());
- armnnUtils::Permute(outputInfo.GetShape(), permVector, expectedOutputData.data(), outputTmp.data(), typeSize);
- expectedOutputData = outputTmp;
+ PermuteTensorNhwcToNchw<float>(inputInfo, inputData);
+ PermuteTensorNhwcToNchw<float>(outputInfo, expectedOutputData);
}
if(armnn::IsQuantizedType<T>())
diff --git a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.hpp
index 6191adf61f..7391f9c198 100644
--- a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.hpp
+++ b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.hpp
@@ -12,7 +12,7 @@
#include <backendsCommon/CpuTensorHandle.hpp>
-#include <backendsCommon/test/CommonTestUtils.hpp>
+#include <backendsCommon/test/DataLayoutUtils.hpp>
#include <backendsCommon/test/QuantizeHelper.hpp>
#include <backendsCommon/test/TensorCopyUtils.hpp>
#include <backendsCommon/test/WorkloadTestUtils.hpp>
@@ -194,27 +194,16 @@ LayerTestResult<T, 4> TransposeConvolution2dTest(
}
template<typename T>
-void SwizzleData(const armnn::TensorInfo& inputInfo,
+void SwizzleData(armnn::TensorInfo& inputInfo,
std::vector<T>& inputData,
- const armnn::TensorInfo& outputInfo,
+ armnn::TensorInfo& outputInfo,
std::vector<T>& outputData,
- const armnn::TensorInfo& weightsInfo,
+ armnn::TensorInfo& weightsInfo,
std::vector<T>& weightsData)
{
- constexpr size_t dataTypeSize = sizeof(float);
- const armnn::PermutationVector nchwToNhwc = { 0, 3, 1, 2 };
-
- std::vector<T> tmp(inputData.size());
- armnnUtils::Permute(inputInfo.GetShape(), nchwToNhwc, inputData.data(), tmp.data(), dataTypeSize);
- inputData = tmp;
-
- tmp.resize(weightsData.size());
- armnnUtils::Permute(weightsInfo.GetShape(), nchwToNhwc, weightsData.data(), tmp.data(), dataTypeSize);
- weightsData = tmp;
-
- tmp.resize(outputData.size());
- armnnUtils::Permute(outputInfo.GetShape(), nchwToNhwc, outputData.data(), tmp.data(), dataTypeSize);
- outputData = tmp;
+ PermuteTensorNchwToNhwc<T>(inputInfo, inputData);
+ PermuteTensorNchwToNhwc<T>(outputInfo, outputData);
+ PermuteTensorNchwToNhwc<T>(weightsInfo, weightsData);
}
} // anonymous namespace
@@ -240,9 +229,9 @@ LayerTestResult<T, 4> SimpleTransposeConvolution2dTest(
constexpr unsigned int wWeights = 3u;
constexpr unsigned int hWeights = wWeights;
- TensorShape inputShape = MakeTensorShape(batches, channels, hInput, wInput, layout);
- TensorShape outputShape = MakeTensorShape(batches, channels, hOutput, wOutput, layout);
- TensorShape weightsShape = MakeTensorShape(batches, channels, hWeights, wWeights, layout);
+ TensorShape inputShape = { batches, channels, hInput, wInput };
+ TensorShape outputShape = { batches, channels, hOutput, wOutput };
+ TensorShape weightsShape = { batches, channels, hWeights, wWeights };
TensorInfo inputInfo(inputShape, ArmnnType);
TensorInfo outputInfo(outputShape, ArmnnType);
@@ -327,9 +316,9 @@ LayerTestResult<T, 4> PaddedTransposeConvolution2dTest(
constexpr unsigned int wWeights = 3u;
constexpr unsigned int hWeights = wWeights;
- TensorShape inputShape = MakeTensorShape(batches, channels, hInput, wInput, layout);
- TensorShape outputShape = MakeTensorShape(batches, channels, hOutput, wOutput, layout);
- TensorShape weightsShape = MakeTensorShape(batches, channels, hWeights, wWeights, layout);
+ TensorShape inputShape = { batches, channels, hInput, wInput };
+ TensorShape outputShape = { batches, channels, hOutput, wOutput };
+ TensorShape weightsShape = { batches, channels, hWeights, wWeights };
TensorInfo inputInfo(inputShape, ArmnnType);
TensorInfo outputInfo(outputShape, ArmnnType);
@@ -416,9 +405,9 @@ LayerTestResult<T, 4> StridedTransposeConvolution2dTest(
constexpr unsigned int wWeights = 3u;
constexpr unsigned int hWeights = wWeights;
- TensorShape inputShape = MakeTensorShape(batches, channels, hInput, wInput, layout);
- TensorShape outputShape = MakeTensorShape(batches, channels, hOutput, wOutput, layout);
- TensorShape weightsShape = MakeTensorShape(batches, channels, hWeights, wWeights, layout);
+ TensorShape inputShape = { batches, channels, hInput, wInput };
+ TensorShape outputShape = { batches, channels, hOutput, wOutput };
+ TensorShape weightsShape = { batches, channels, hWeights, wWeights };
TensorInfo inputInfo(inputShape, ArmnnType);
TensorInfo outputInfo(outputShape, ArmnnType);
@@ -492,11 +481,11 @@ LayerTestResult<T, 4> MultiChannelTransposeConvolution2dTest(
{
using namespace armnn;
- TensorShape inputShape = MakeTensorShape(1, 1, 2, 2, layout);
- TensorShape outputShape = MakeTensorShape(1, 2, 5, 5, layout);
+ TensorShape inputShape = { 1, 1, 2, 2 };
+ TensorShape outputShape = { 1, 2, 5, 5 };
// OIHW for NCHW; OHWI for NHWC
- TensorShape weightsShape = MakeTensorShape(2, 1, 3, 3, layout);
+ TensorShape weightsShape = { 2, 1, 3, 3 };
TensorShape biasesShape = { 2 };
TensorInfo inputInfo(inputShape, ArmnnType);