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/Mean.cpp | 201 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 49 deletions(-) (limited to 'test/1.1/Mean.cpp') diff --git a/test/1.1/Mean.cpp b/test/1.1/Mean.cpp index c9a5a6d3..c7c5a9b5 100644 --- a/test/1.1/Mean.cpp +++ b/test/1.1/Mean.cpp @@ -8,12 +8,10 @@ #include "../1.1/HalPolicy.hpp" -#include +#include #include -BOOST_AUTO_TEST_SUITE(MeanTests) - using namespace android::hardware; using namespace driverTestHelpers; using namespace armnn_driver; @@ -24,12 +22,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 MeanTestImpl(const TestTensor& input, const hidl_vec& axisDimensions, const int32_t* axisValues, @@ -94,64 +86,175 @@ void MeanTestImpl(const TestTensor& input, if (preparedModel.get() != nullptr) { V1_0::ErrorStatus execStatus = Execute(preparedModel, request); - BOOST_TEST(execStatus == V1_0::ErrorStatus::NONE); + CHECK((int)execStatus == (int)V1_0::ErrorStatus::NONE); } const float* expectedOutputData = expectedOutput.GetData(); for (unsigned int i = 0; i < expectedOutput.GetNumElements(); i++) { - BOOST_TEST(outputData[i] == expectedOutputData[i]); + CHECK(outputData[i] == expectedOutputData[i]); } } } // anonymous namespace -BOOST_DATA_TEST_CASE(MeanNoKeepDimsTest, COMPUTE_DEVICES) +TEST_SUITE("MeanTests_CpuRef") { - TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, - 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, - 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; - hidl_vec axisDimensions = { 2 }; - int32_t axisValues[] = { 0, 1 }; - int32_t keepDims = 0; - TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; - - MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, sample); -} + TEST_CASE("MeanNoKeepDimsTest_CpuRef") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::CpuRef); + } -BOOST_DATA_TEST_CASE(MeanKeepDimsTest, COMPUTE_DEVICES) -{ - TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; - hidl_vec axisDimensions = { 1 }; - int32_t axisValues[] = { 2 }; - int32_t keepDims = 1; - TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + TEST_CASE("MeanKeepDimsTest_CpuRef") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::CpuRef); + } + + TEST_CASE("MeanFp16NoKeepDimsTest_CpuRef") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::CpuRef); + } + + TEST_CASE("MeanFp16KeepDimsTest_CpuRef") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; - MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, sample); + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::CpuRef); + } } -BOOST_DATA_TEST_CASE(MeanFp16NoKeepDimsTest, COMPUTE_DEVICES) +#ifdef ARMCOMPUTECL_ENABLED +TEST_SUITE("MeanTests_CpuAcc") { - TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, - 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, - 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; - hidl_vec axisDimensions = { 2 }; - int32_t axisValues[] = { 0, 1 }; - int32_t keepDims = 0; - TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; - - MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, sample); + TEST_CASE("MeanNoKeepDimsTest_CpuAcc") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::CpuAcc); + } + + TEST_CASE("MeanKeepDimsTest_CpuAcc") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::CpuAcc); + } + + TEST_CASE("MeanFp16NoKeepDimsTest_CpuAcc") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::CpuAcc); + } + + TEST_CASE("MeanFp16KeepDimsTest_CpuAcc") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::CpuAcc); + } } -BOOST_DATA_TEST_CASE(MeanFp16KeepDimsTest, COMPUTE_DEVICES) +TEST_SUITE("MeanTests_GpuAcc") { - TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; - hidl_vec axisDimensions = { 1 }; - int32_t axisValues[] = { 2 }; - int32_t keepDims = 1; - TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + TEST_CASE("MeanNoKeepDimsTest_GpuAcc") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::GpuAcc); + } - MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, sample); -} + TEST_CASE("MeanKeepDimsTest_GpuAcc") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; -BOOST_AUTO_TEST_SUITE_END() + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, false, armnn::Compute::GpuAcc); + } + + TEST_CASE("MeanFp16NoKeepDimsTest_GpuAcc") + { + TestTensor input{ armnn::TensorShape{ 4, 3, 2 }, + { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } }; + hidl_vec axisDimensions = { 2 }; + int32_t axisValues[] = { 0, 1 }; + int32_t keepDims = 0; + TestTensor expectedOutput{ armnn::TensorShape{ 2 }, { 12.0f, 13.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::GpuAcc); + } + + TEST_CASE("MeanFp16KeepDimsTest_GpuAcc") + { + TestTensor input{ armnn::TensorShape{ 1, 1, 3, 2 }, { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f } }; + hidl_vec axisDimensions = { 1 }; + int32_t axisValues[] = { 2 }; + int32_t keepDims = 1; + TestTensor expectedOutput{ armnn::TensorShape{ 1, 1, 1, 2 }, { 2.0f, 2.0f } }; + + MeanTestImpl(input, axisDimensions, axisValues, keepDims, expectedOutput, true, armnn::Compute::GpuAcc); + } +} +#endif -- cgit v1.2.1