From 9150bff63a690caa743c471943afe509ebed1044 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Wed, 26 May 2021 15:40:53 +0100 Subject: IVGCVSW-4618 'Transition Units Test Suites' * Used doctest in android-nn-driver unit tests. Signed-off-by: Sadik Armagan Change-Id: I9b5d4dfd77d53c7ebee7f8c43628a1d6ff74d1a3 --- test/1.1/Transpose.cpp | 108 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 29 deletions(-) (limited to 'test/1.1/Transpose.cpp') diff --git a/test/1.1/Transpose.cpp b/test/1.1/Transpose.cpp index 206f9b98..4c4dc349 100644 --- a/test/1.1/Transpose.cpp +++ b/test/1.1/Transpose.cpp @@ -9,16 +9,13 @@ #include "../1.1/HalPolicy.hpp" -#include -#include +#include #include #include #include -BOOST_AUTO_TEST_SUITE(TransposeTests) - using namespace android::hardware; using namespace driverTestHelpers; using namespace armnn_driver; @@ -29,12 +26,6 @@ using RequestArgument = V1_0::RequestArgument; namespace { -#ifndef ARMCOMPUTECL_ENABLED - static const std::array COMPUTE_DEVICES = {{ armnn::Compute::CpuRef }}; -#else - static const std::array COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::GpuAcc }}; -#endif - void TransposeTestImpl(const TestTensor & inputs, int32_t perm[], const TestTensor & expectedOutputTensor, armnn::Compute computeDevice) { @@ -98,38 +89,97 @@ void TransposeTestImpl(const TestTensor & inputs, int32_t perm[], const float * expectedOutput = expectedOutputTensor.GetData(); for (unsigned int i = 0; i < expectedOutputTensor.GetNumElements(); ++i) { - BOOST_TEST(outdata[i] == expectedOutput[i]); + CHECK(outdata[i] == expectedOutput[i]); } } } // namespace -BOOST_DATA_TEST_CASE(Transpose , COMPUTE_DEVICES) +TEST_SUITE("TransposeTests_CpuRef") { - int32_t perm[] = {2, 3, 1, 0}; - TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; - TestTensor expected{armnn::TensorShape{2, 2, 2, 1},{1, 5, 2, 6, 3, 7, 4, 8}}; + TEST_CASE("Transpose_CpuRef") + { + int32_t perm[] = {2, 3, 1, 0}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{2, 2, 2, 1},{1, 5, 2, 6, 3, 7, 4, 8}}; - TransposeTestImpl(input, perm, expected, sample); -} + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuRef); + } -BOOST_DATA_TEST_CASE(TransposeNHWCToArmNN , COMPUTE_DEVICES) -{ - int32_t perm[] = {0, 3, 1, 2}; - TestTensor input{armnn::TensorShape{1, 2, 2, 3},{1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33}}; - TestTensor expected{armnn::TensorShape{1, 3, 2, 2},{1, 11, 21, 31, 2, 12, 22, 32, 3, 13, 23, 33}}; + TEST_CASE("TransposeNHWCToArmNN_CpuRef") + { + int32_t perm[] = {0, 3, 1, 2}; + TestTensor input{armnn::TensorShape{1, 2, 2, 3},{1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33}}; + TestTensor expected{armnn::TensorShape{1, 3, 2, 2},{1, 11, 21, 31, 2, 12, 22, 32, 3, 13, 23, 33}}; - TransposeTestImpl(input, perm, expected, sample); + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuRef); + } + TEST_CASE("TransposeArmNNToNHWC_CpuRef") + { + int32_t perm[] = {0, 2, 3, 1}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{1, 2, 2, 2},{1, 5, 2, 6, 3, 7, 4, 8}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuRef); + } } -BOOST_DATA_TEST_CASE(TransposeArmNNToNHWC , COMPUTE_DEVICES) +#ifdef ARMCOMPUTECL_ENABLED +TEST_SUITE("TransposeTests_CpuAcc") { - int32_t perm[] = {0, 2, 3, 1}; - TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; - TestTensor expected{armnn::TensorShape{1, 2, 2, 2},{1, 5, 2, 6, 3, 7, 4, 8}}; + TEST_CASE("Transpose_CpuAcc") + { + int32_t perm[] = {2, 3, 1, 0}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{2, 2, 2, 1},{1, 5, 2, 6, 3, 7, 4, 8}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuAcc); + } + + TEST_CASE("TransposeNHWCToArmNN_CpuAcc") + { + int32_t perm[] = {0, 3, 1, 2}; + TestTensor input{armnn::TensorShape{1, 2, 2, 3},{1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33}}; + TestTensor expected{armnn::TensorShape{1, 3, 2, 2},{1, 11, 21, 31, 2, 12, 22, 32, 3, 13, 23, 33}}; - TransposeTestImpl(input, perm, expected, sample); + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuAcc); + } + TEST_CASE("TransposeArmNNToNHWC_CpuAcc") + { + int32_t perm[] = {0, 2, 3, 1}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{1, 2, 2, 2},{1, 5, 2, 6, 3, 7, 4, 8}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::CpuAcc); + } } +TEST_SUITE("TransposeTests_GpuAcc") +{ + TEST_CASE("Transpose_GpuAcc") + { + int32_t perm[] = {2, 3, 1, 0}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{2, 2, 2, 1},{1, 5, 2, 6, 3, 7, 4, 8}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::GpuAcc); + } -BOOST_AUTO_TEST_SUITE_END() + TEST_CASE("TransposeNHWCToArmNN_GpuAcc") + { + int32_t perm[] = {0, 3, 1, 2}; + TestTensor input{armnn::TensorShape{1, 2, 2, 3},{1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33}}; + TestTensor expected{armnn::TensorShape{1, 3, 2, 2},{1, 11, 21, 31, 2, 12, 22, 32, 3, 13, 23, 33}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::GpuAcc); + } + TEST_CASE("TransposeArmNNToNHWC_GpuAcc") + { + int32_t perm[] = {0, 2, 3, 1}; + TestTensor input{armnn::TensorShape{1, 2, 2, 2},{1, 2, 3, 4, 5, 6, 7, 8}}; + TestTensor expected{armnn::TensorShape{1, 2, 2, 2},{1, 5, 2, 6, 3, 7, 4, 8}}; + + TransposeTestImpl(input, perm, expected, armnn::Compute::GpuAcc); + } +} +#endif -- cgit v1.2.1