From 1625efc870f1a8b7c6e6382277ddbb245f91a294 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 10 Jun 2021 18:24:34 +0100 Subject: IVGCVSW-5963 'Move unit tests to new framework' * Used doctest in ArmNN unit tests Signed-off-by: Sadik Armagan Change-Id: Ia9cf5fc72775878885c5f864abf2c56b3a935f1a --- .../aclCommon/test/ArmComputeTensorUtilsTests.cpp | 20 +++++----- .../aclCommon/test/CreateWorkloadClNeon.hpp | 18 +++++---- src/backends/aclCommon/test/MemCopyTests.cpp | 46 ++++++++++------------ 3 files changed, 41 insertions(+), 43 deletions(-) (limited to 'src/backends/aclCommon') diff --git a/src/backends/aclCommon/test/ArmComputeTensorUtilsTests.cpp b/src/backends/aclCommon/test/ArmComputeTensorUtilsTests.cpp index 4ab748806c..fa933a0ec3 100644 --- a/src/backends/aclCommon/test/ArmComputeTensorUtilsTests.cpp +++ b/src/backends/aclCommon/test/ArmComputeTensorUtilsTests.cpp @@ -5,13 +5,13 @@ #include -#include +#include using namespace armnn::armcomputetensorutils; -BOOST_AUTO_TEST_SUITE(ArmComputeTensorUtils) - -BOOST_AUTO_TEST_CASE(BuildArmComputeTensorInfoTest) +TEST_SUITE("ArmComputeTensorUtils") +{ +TEST_CASE("BuildArmComputeTensorInfoTest") { const armnn::TensorShape tensorShape = { 1, 2, 3, 4 }; @@ -26,21 +26,21 @@ BOOST_AUTO_TEST_CASE(BuildArmComputeTensorInfoTest) const arm_compute::TensorInfo aclTensorInfo0 = BuildArmComputeTensorInfo(tensorInfo0); const arm_compute::TensorShape& aclTensorShape = aclTensorInfo0.tensor_shape(); - BOOST_CHECK(aclTensorShape.num_dimensions() == tensorShape.GetNumDimensions()); + CHECK(aclTensorShape.num_dimensions() == tensorShape.GetNumDimensions()); for(unsigned int i = 0u; i < tensorShape.GetNumDimensions(); ++i) { // NOTE: arm_compute tensor dimensions are stored in the opposite order - BOOST_CHECK(aclTensorShape[i] == tensorShape[tensorShape.GetNumDimensions() - i - 1]); + CHECK(aclTensorShape[i] == tensorShape[tensorShape.GetNumDimensions() - i - 1]); } - BOOST_CHECK(aclTensorInfo0.data_type() == arm_compute::DataType::QASYMM8); - BOOST_CHECK(aclTensorInfo0.quantization_info().scale()[0] == quantScale); + CHECK(aclTensorInfo0.data_type() == arm_compute::DataType::QASYMM8); + CHECK(aclTensorInfo0.quantization_info().scale()[0] == quantScale); // Tensor info with per-axis quantization const armnn::TensorInfo tensorInfo1(tensorShape, dataType, quantScales, 0); const arm_compute::TensorInfo aclTensorInfo1 = BuildArmComputeTensorInfo(tensorInfo1); - BOOST_CHECK(aclTensorInfo1.quantization_info().scale() == quantScales); + CHECK(aclTensorInfo1.quantization_info().scale() == quantScales); } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp b/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp index 0a30907f55..bdae9988ed 100644 --- a/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp +++ b/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp @@ -19,6 +19,8 @@ #include #endif +#include + using namespace armnn; namespace @@ -92,23 +94,23 @@ void CreateMemCopyWorkloads(IWorkloadFactory& factory) auto workload2 = MakeAndCheckWorkload(*layer2, refFactory); MemCopyQueueDescriptor queueDescriptor1 = workload1->GetData(); - BOOST_TEST(queueDescriptor1.m_Inputs.size() == 1); - BOOST_TEST(queueDescriptor1.m_Outputs.size() == 1); + CHECK(queueDescriptor1.m_Inputs.size() == 1); + CHECK(queueDescriptor1.m_Outputs.size() == 1); auto inputHandle1 = PolymorphicDowncast(queueDescriptor1.m_Inputs[0]); auto outputHandle1 = PolymorphicDowncast(queueDescriptor1.m_Outputs[0]); - BOOST_TEST((inputHandle1->GetTensorInfo() == TensorInfo({2, 3}, DataType::Float32))); + CHECK((inputHandle1->GetTensorInfo() == TensorInfo({2, 3}, DataType::Float32))); auto result = CompareTensorHandleShape(outputHandle1, {2, 3}); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); MemCopyQueueDescriptor queueDescriptor2 = workload2->GetData(); - BOOST_TEST(queueDescriptor2.m_Inputs.size() == 1); - BOOST_TEST(queueDescriptor2.m_Outputs.size() == 1); + CHECK(queueDescriptor2.m_Inputs.size() == 1); + CHECK(queueDescriptor2.m_Outputs.size() == 1); auto inputHandle2 = PolymorphicDowncast(queueDescriptor2.m_Inputs[0]); auto outputHandle2 = PolymorphicDowncast(queueDescriptor2.m_Outputs[0]); result = CompareTensorHandleShape(inputHandle2, {2, 3}); - BOOST_TEST(result.m_Result, result.m_Message.str()); - BOOST_TEST((outputHandle2->GetTensorInfo() == TensorInfo({2, 3}, DataType::Float32))); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); + CHECK((outputHandle2->GetTensorInfo() == TensorInfo({2, 3}, DataType::Float32))); } } //namespace diff --git a/src/backends/aclCommon/test/MemCopyTests.cpp b/src/backends/aclCommon/test/MemCopyTests.cpp index 7612cbfe28..132550342c 100644 --- a/src/backends/aclCommon/test/MemCopyTests.cpp +++ b/src/backends/aclCommon/test/MemCopyTests.cpp @@ -15,71 +15,67 @@ #include #endif -#include +#include -BOOST_AUTO_TEST_SUITE(MemCopyCommon) - -BOOST_AUTO_TEST_CASE(AclTypeConversions) +TEST_SUITE("MemCopyCommon") +{ +TEST_CASE("AclTypeConversions") { arm_compute::Strides strides(1, 2, 3, 4); armnn::TensorShape convertedStrides = armnn::armcomputetensorutils::GetStrides(strides); - BOOST_TEST(convertedStrides[0] == 4); - BOOST_TEST(convertedStrides[1] == 3); - BOOST_TEST(convertedStrides[2] == 2); - BOOST_TEST(convertedStrides[3] == 1); + CHECK(convertedStrides[0] == 4); + CHECK(convertedStrides[1] == 3); + CHECK(convertedStrides[2] == 2); + CHECK(convertedStrides[3] == 1); arm_compute::TensorShape shape(5, 6, 7, 8); armnn::TensorShape convertedshape = armnn::armcomputetensorutils::GetShape(shape); - BOOST_TEST(convertedshape[0] == 8); - BOOST_TEST(convertedshape[1] == 7); - BOOST_TEST(convertedshape[2] == 6); - BOOST_TEST(convertedshape[3] == 5); + CHECK(convertedshape[0] == 8); + CHECK(convertedshape[1] == 7); + CHECK(convertedshape[2] == 6); + CHECK(convertedshape[3] == 5); } -BOOST_AUTO_TEST_SUITE_END() +} #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED) -BOOST_FIXTURE_TEST_SUITE(MemCopyClNeon, ClContextControlFixture) - -BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpu) +TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu") { LayerTestResult result = MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); - BOOST_TEST(predResult.m_Result, predResult.m_Message.str()); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); } -BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeon) +TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenGpuAndNeon") { LayerTestResult result = MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); - BOOST_TEST(predResult.m_Result, predResult.m_Message.str()); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); } -BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpuWithSubtensors) +TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpuWithSubtensors") { LayerTestResult result = MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); - BOOST_TEST(predResult.m_Result, predResult.m_Message.str()); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); } -BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors) +TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenGpuAndNeonWithSubtensors") { LayerTestResult result = MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); - BOOST_TEST(predResult.m_Result, predResult.m_Message.str()); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); } -BOOST_AUTO_TEST_SUITE_END() - #endif -- cgit v1.2.1