diff options
Diffstat (limited to 'src/backends/backendsCommon')
40 files changed, 1036 insertions, 1031 deletions
diff --git a/src/backends/backendsCommon/test/BackendIdTests.cpp b/src/backends/backendsCommon/test/BackendIdTests.cpp index e11c13e6ae..de6bef4c08 100644 --- a/src/backends/backendsCommon/test/BackendIdTests.cpp +++ b/src/backends/backendsCommon/test/BackendIdTests.cpp @@ -6,23 +6,23 @@ #include <armnn/BackendId.hpp> #include <armnn/Types.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> using namespace armnn; -BOOST_AUTO_TEST_SUITE(BackendIdTests) - -BOOST_AUTO_TEST_CASE(CreateBackendIdFromCompute) +TEST_SUITE("BackendIdTests") +{ +TEST_CASE("CreateBackendIdFromCompute") { BackendId fromCompute{Compute::GpuAcc}; - BOOST_TEST(fromCompute.Get() == GetComputeDeviceAsCString(Compute::GpuAcc)); + CHECK(fromCompute.Get() == GetComputeDeviceAsCString(Compute::GpuAcc)); } -BOOST_AUTO_TEST_CASE(CreateBackendIdVectorFromCompute) +TEST_CASE("CreateBackendIdVectorFromCompute") { std::vector<BackendId> fromComputes = {Compute::GpuAcc, Compute::CpuRef}; - BOOST_TEST(fromComputes[0].Get() == GetComputeDeviceAsCString(Compute::GpuAcc)); - BOOST_TEST(fromComputes[1].Get() == GetComputeDeviceAsCString(Compute::CpuRef)); + CHECK(fromComputes[0].Get() == GetComputeDeviceAsCString(Compute::GpuAcc)); + CHECK(fromComputes[1].Get() == GetComputeDeviceAsCString(Compute::CpuRef)); } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index 91399b4887..62c06fe6d3 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -21,7 +21,7 @@ #include <armnn/Logging.hpp> #include <armnn/profiling/ISendTimelinePacket.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> #include <cstdint> @@ -111,9 +111,9 @@ arm::pipe::Packet PacketWriter(uint32_t period, std::vector<uint16_t> counterval return {packetId, dataLength, uniqueData}; } -BOOST_AUTO_TEST_SUITE(BackendProfilingTestSuite) - -BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest) +TEST_SUITE("BackendProfilingTestSuite") +{ +TEST_CASE("BackendProfilingCounterRegisterMockBackendTest") { // Reset the profiling service to the uninitialized state armnn::IRuntime::CreationOptions options; @@ -133,17 +133,17 @@ BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest) // Check if the MockBackends 3 dummy counters {0, 1, 2-5 (four cores)} are registered armnn::BackendId mockId = armnn::MockBackendId(); const armnn::profiling::ICounterMappings& counterMap = GetProfilingService(&runtime).GetCounterMappings(); - BOOST_CHECK(counterMap.GetGlobalId(0, mockId) == 5 + shiftedId); - BOOST_CHECK(counterMap.GetGlobalId(1, mockId) == 6 + shiftedId); - BOOST_CHECK(counterMap.GetGlobalId(2, mockId) == 7 + shiftedId); - BOOST_CHECK(counterMap.GetGlobalId(3, mockId) == 8 + shiftedId); - BOOST_CHECK(counterMap.GetGlobalId(4, mockId) == 9 + shiftedId); - BOOST_CHECK(counterMap.GetGlobalId(5, mockId) == 10 + shiftedId); + CHECK(counterMap.GetGlobalId(0, mockId) == 5 + shiftedId); + CHECK(counterMap.GetGlobalId(1, mockId) == 6 + shiftedId); + CHECK(counterMap.GetGlobalId(2, mockId) == 7 + shiftedId); + CHECK(counterMap.GetGlobalId(3, mockId) == 8 + shiftedId); + CHECK(counterMap.GetGlobalId(4, mockId) == 9 + shiftedId); + CHECK(counterMap.GetGlobalId(5, mockId) == 10 + shiftedId); options.m_ProfilingOptions.m_EnableProfiling = false; GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, true); } -BOOST_AUTO_TEST_CASE(TestBackendCounters) +TEST_CASE("TestBackendCounters") { Holder holder; arm::pipe::PacketVersionResolver packetVersionResolver; @@ -220,18 +220,18 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); std::set<armnn::BackendId> activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 1); - BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end()); + CHECK(activeIds.size() == 1); + CHECK((activeIds.find(gpuAccId) != activeIds.end())); std::vector<Timestamp> recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp[0].timestamp == period); - BOOST_CHECK(recievedTimestamp.size() == 1); - BOOST_CHECK(recievedTimestamp[0].counterValues.size() == gpuCounters.size()); + CHECK(recievedTimestamp[0].timestamp == period); + CHECK(recievedTimestamp.size() == 1); + CHECK(recievedTimestamp[0].counterValues.size() == gpuCounters.size()); for (unsigned long i=0; i< gpuCounters.size(); ++i) { - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == gpuCounters[i]); - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); + CHECK(recievedTimestamp[0].counterValues[i].counterId == gpuCounters[i]); + CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); } sendCounterPacket.ClearTimestamps(); @@ -240,18 +240,18 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 1); - BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end()); + CHECK(activeIds.size() == 1); + CHECK((activeIds.find(cpuAccId) != activeIds.end())); recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp[0].timestamp == period); - BOOST_CHECK(recievedTimestamp.size() == 1); - BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size()); + CHECK(recievedTimestamp[0].timestamp == period); + CHECK(recievedTimestamp.size() == 1); + CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size()); for (unsigned long i=0; i< cpuCounters.size(); ++i) { - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]); - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); + CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]); + CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); } sendCounterPacket.ClearTimestamps(); @@ -262,28 +262,28 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 2); - BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end()); - BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end()); + CHECK(activeIds.size() == 2); + CHECK((activeIds.find(cpuAccId) != activeIds.end())); + CHECK((activeIds.find(gpuAccId) != activeIds.end())); recievedTimestamp = sendCounterPacket.GetTimestamps(); +// + CHECK(recievedTimestamp[0].timestamp == period); + CHECK(recievedTimestamp[1].timestamp == period); - BOOST_CHECK(recievedTimestamp[0].timestamp == period); - BOOST_CHECK(recievedTimestamp[1].timestamp == period); - - BOOST_CHECK(recievedTimestamp.size() == 2); - BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2); - BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size()); + CHECK(recievedTimestamp.size() == 2); + CHECK(recievedTimestamp[0].counterValues.size() == 2); + CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size()); - BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]); - BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u); - BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[1]); - BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 2u); + CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]); + CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u); + CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[1]); + CHECK(recievedTimestamp[0].counterValues[1].counterValue == 2u); for (unsigned long i=0; i< gpuCounters.size(); ++i) { - BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]); - BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u); + CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]); + CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u); } sendCounterPacket.ClearTimestamps(); @@ -297,24 +297,24 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 2); - BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end()); - BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end()); + CHECK(activeIds.size() == 2); + CHECK((activeIds.find(cpuAccId) != activeIds.end())); + CHECK((activeIds.find(gpuAccId) != activeIds.end())); recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size()); + CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size()); for (unsigned long i=0; i< cpuCounters.size(); ++i) { - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]); - BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); + CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]); + CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u); } - BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size()); + CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size()); for (unsigned long i=0; i< gpuCounters.size(); ++i) { - BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]); - BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u); + CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]); + CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u); } sendCounterPacket.ClearTimestamps(); @@ -326,27 +326,27 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 2); - BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end()); - BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end()); + CHECK(activeIds.size() == 2); + CHECK((activeIds.find(cpuAccId) != activeIds.end())); + CHECK((activeIds.find(gpuAccId) != activeIds.end())); recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp.size() == 2); + CHECK(recievedTimestamp.size() == 2); - BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2); + CHECK(recievedTimestamp[0].counterValues.size() == 2); - BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]); - BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u); - BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[2]); - BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 3u); + CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]); + CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u); + CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[2]); + CHECK(recievedTimestamp[0].counterValues[1].counterValue == 3u); - BOOST_CHECK(recievedTimestamp[1].counterValues.size() == 2); + CHECK(recievedTimestamp[1].counterValues.size() == 2); - BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterId == gpuCounters[0]); - BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterValue == 1u); - BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterId == gpuCounters[1]); - BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterValue == 2u); + CHECK(recievedTimestamp[1].counterValues[0].counterId == gpuCounters[0]); + CHECK(recievedTimestamp[1].counterValues[0].counterValue == 1u); + CHECK(recievedTimestamp[1].counterValues[1].counterId == gpuCounters[1]); + CHECK(recievedTimestamp[1].counterValues[1].counterValue == 2u); sendCounterPacket.ClearTimestamps(); @@ -355,10 +355,10 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 0); + CHECK(activeIds.size() == 0); recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp.size() == 0); + CHECK(recievedTimestamp.size() == 0); sendCounterPacket.ClearTimestamps(); @@ -367,13 +367,13 @@ BOOST_AUTO_TEST_CASE(TestBackendCounters) periodicCounterCapture.Stop(); activeIds = holder.GetCaptureData().GetActiveBackends(); - BOOST_CHECK(activeIds.size() == 0); + CHECK(activeIds.size() == 0); recievedTimestamp = sendCounterPacket.GetTimestamps(); - BOOST_CHECK(recievedTimestamp.size() == 0); + CHECK(recievedTimestamp.size() == 0); } -BOOST_AUTO_TEST_CASE(TestBackendCounterLogging) +TEST_CASE("TestBackendCounterLogging") { std::stringstream ss; @@ -450,10 +450,10 @@ BOOST_AUTO_TEST_CASE(TestBackendCounterLogging) periodicCounterCapture.Stop(); SetLogFilter(armnn::LogSeverity::Fatal); - BOOST_CHECK(ss.str().find("ActivateCounters example test error") != std::string::npos); + CHECK(ss.str().find("ActivateCounters example test error") != std::string::npos); } -BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket) +TEST_CASE("BackendProfilingContextGetSendTimelinePacket") { // Reset the profiling service to the uninitialized state armnn::IRuntime::CreationOptions options; @@ -467,10 +467,10 @@ BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket) armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance(); armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext(); // Check that there is a valid context set. - BOOST_CHECK(mockBackEndProfilingContext); + CHECK(mockBackEndProfilingContext); armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface = mockBackEndProfilingContext->GetBackendProfiling(); - BOOST_CHECK(backendProfilingIface); + CHECK(backendProfilingIface); // Now for the meat of the test. We're just going to send a random packet and make sure there // are no exceptions or errors. The sending of packets is already tested in SendTimelinePacketTests. @@ -486,7 +486,7 @@ BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket) profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true); } -BOOST_AUTO_TEST_CASE(GetProfilingGuidGenerator) +TEST_CASE("GetProfilingGuidGenerator") { // Reset the profiling service to the uninitialized state armnn::IRuntime::CreationOptions options; @@ -498,19 +498,19 @@ BOOST_AUTO_TEST_CASE(GetProfilingGuidGenerator) armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance(); armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext(); // Check that there is a valid context set. - BOOST_CHECK(mockBackEndProfilingContext); + CHECK(mockBackEndProfilingContext); armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface = mockBackEndProfilingContext->GetBackendProfiling(); - BOOST_CHECK(backendProfilingIface); + CHECK(backendProfilingIface); // Get the Guid generator and check the getting two Guid's results in the second being greater than the first. armnn::profiling::IProfilingGuidGenerator& guidGenerator = backendProfilingIface->GetProfilingGuidGenerator(); const armnn::profiling::ProfilingDynamicGuid& firstGuid = guidGenerator.NextGuid(); const armnn::profiling::ProfilingDynamicGuid& secondGuid = guidGenerator.NextGuid(); - BOOST_CHECK(secondGuid > firstGuid); + CHECK(secondGuid > firstGuid); // Reset the profiling servie after the test. options.m_ProfilingOptions.m_EnableProfiling = false; } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/BackendRegistryTests.cpp b/src/backends/backendsCommon/test/BackendRegistryTests.cpp index ce8acbbf2a..d9c19d659c 100644 --- a/src/backends/backendsCommon/test/BackendRegistryTests.cpp +++ b/src/backends/backendsCommon/test/BackendRegistryTests.cpp @@ -9,7 +9,7 @@ #include <armnn/backends/IBackendInternal.hpp> #include <reference/RefBackend.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> namespace { @@ -33,20 +33,20 @@ private: } -BOOST_AUTO_TEST_SUITE(BackendRegistryTests) - -BOOST_AUTO_TEST_CASE(SwapRegistry) +TEST_SUITE("BackendRegistryTests") +{ +TEST_CASE("SwapRegistry") { using namespace armnn; auto nFactories = BackendRegistryInstance().Size(); { SwapRegistryStorage helper; - BOOST_TEST(BackendRegistryInstance().Size() == 0); + CHECK(BackendRegistryInstance().Size() == 0); } - BOOST_TEST(BackendRegistryInstance().Size() == nFactories); + CHECK(BackendRegistryInstance().Size() == nFactories); } -BOOST_AUTO_TEST_CASE(TestRegistryHelper) +TEST_CASE("TestRegistryHelper") { using namespace armnn; SwapRegistryStorage helper; @@ -64,19 +64,19 @@ BOOST_AUTO_TEST_CASE(TestRegistryHelper) ); // sanity check: the factory has not been called yet - BOOST_TEST(called == false); + CHECK(called == false); auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld"); // sanity check: the factory still not called - BOOST_TEST(called == false); + CHECK(called == false); factoryFunction(); - BOOST_TEST(called == true); + CHECK(called == true); BackendRegistryInstance().Deregister("HelloWorld"); } -BOOST_AUTO_TEST_CASE(TestDirectCallToRegistry) +TEST_CASE("TestDirectCallToRegistry") { using namespace armnn; SwapRegistryStorage helper; @@ -92,15 +92,15 @@ BOOST_AUTO_TEST_CASE(TestDirectCallToRegistry) ); // sanity check: the factory has not been called yet - BOOST_TEST(called == false); + CHECK(called == false); auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld"); // sanity check: the factory still not called - BOOST_TEST(called == false); + CHECK(called == false); factoryFunction(); - BOOST_TEST(called == true); + CHECK(called == true); BackendRegistryInstance().Deregister("HelloWorld"); } @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(TestDirectCallToRegistry) // of Neon not being detected the exception is raised and so the backend is not added to the supportedBackends // list -BOOST_AUTO_TEST_CASE(ThrowBackendUnavailableException) +TEST_CASE("ThrowBackendUnavailableException") { using namespace armnn; @@ -142,9 +142,9 @@ BOOST_AUTO_TEST_CASE(ThrowBackendUnavailableException) catch (const BackendUnavailableException& e) { // Caught - BOOST_CHECK_EQUAL(e.what(), exceptionMessage); - BOOST_TEST_MESSAGE("ThrowBackendUnavailableExceptionImpl: BackendUnavailableException caught."); + CHECK_EQ(e.what(), exceptionMessage); + MESSAGE("ThrowBackendUnavailableExceptionImpl: BackendUnavailableException caught."); } } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/BatchToSpaceNdEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/BatchToSpaceNdEndToEndTestImpl.hpp index d1be409480..254b3c20a0 100644 --- a/src/backends/backendsCommon/test/BatchToSpaceNdEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/BatchToSpaceNdEndToEndTestImpl.hpp @@ -10,7 +10,7 @@ #include <backendsCommon/test/CommonTestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -62,7 +62,7 @@ void BatchToSpaceNdEndToEnd(const std::vector<BackendId>& backends, armnn::DataL // Builds up the structure of the network INetworkPtr net = CreateBatchToSpaceNdNetwork<ArmnnType>(inputShape, outputShape, blockShape, crops, dataLayout); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ 1, 2, 3, 4 }; @@ -93,7 +93,7 @@ void BatchToSpaceNdComplexEndToEnd(const std::vector<BackendId>& backends, armnn // Builds up the structure of the network INetworkPtr net = CreateBatchToSpaceNdNetwork<ArmnnType>(inputShape, outputShape, blockShape, crops, dataLayout); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ diff --git a/src/backends/backendsCommon/test/CMakeLists.txt b/src/backends/backendsCommon/test/CMakeLists.txt index 6313bd5cc9..d0c95c5e33 100644 --- a/src/backends/backendsCommon/test/CMakeLists.txt +++ b/src/backends/backendsCommon/test/CMakeLists.txt @@ -189,6 +189,7 @@ target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/backends) target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/profiling) target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/profiling/common/include) +target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/third-party) # Dummy shared object for testing. # This is a simple library used to test the utility functions that will be used to handle the shared objects. diff --git a/src/backends/backendsCommon/test/ComparisonEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ComparisonEndToEndTestImpl.hpp index c705f87b85..40e3fd62ee 100644 --- a/src/backends/backendsCommon/test/ComparisonEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ComparisonEndToEndTestImpl.hpp @@ -12,7 +12,7 @@ #include <armnn/utility/NumericCast.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -61,7 +61,7 @@ void ComparisonSimpleEndToEnd(const std::vector<BackendId>& backends, // Builds up the structure of the network INetworkPtr net = CreateComparisonNetwork<ArmnnInType>(inputShapes, outputShape, operation); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); const std::vector<TInput> input0({ 1, 1, 1, 1, 5, 5, 5, 5, 3, 3, 3, 3, 4, 4, 4, 4 }); @@ -89,8 +89,6 @@ void ComparisonBroadcastEndToEnd(const std::vector<BackendId>& backends, // Builds up the structure of the network INetworkPtr net = CreateComparisonNetwork<ArmnnInType>(inputShapes, outputShape, operation); - BOOST_TEST_CHECKPOINT("create a network"); - const std::vector<TInput> input0({ 1, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11, 12 }); diff --git a/src/backends/backendsCommon/test/CompatibilityTests.cpp b/src/backends/backendsCommon/test/CompatibilityTests.cpp index ed00088549..4abab2724a 100644 --- a/src/backends/backendsCommon/test/CompatibilityTests.cpp +++ b/src/backends/backendsCommon/test/CompatibilityTests.cpp @@ -3,8 +3,6 @@ // SPDX-License-Identifier: MIT // -#include <boost/test/unit_test.hpp> - #include <cl/ClBackend.hpp> #include <neon/NeonBackend.hpp> #include <reference/RefBackend.hpp> @@ -12,192 +10,195 @@ #include <Network.hpp> +#include <doctest/doctest.h> + #include <vector> #include <string> using namespace armnn; -BOOST_AUTO_TEST_SUITE(BackendsCompatibility, * boost::unit_test::disabled()) - #if defined(ARMCOMPUTENEON_ENABLED) -BOOST_AUTO_TEST_CASE(Neon_Cl_DirectCompatibility_Test) -{ - auto neonBackend = std::make_unique<NeonBackend>(); - auto clBackend = std::make_unique<ClBackend>(); - - TensorHandleFactoryRegistry registry; - neonBackend->RegisterTensorHandleFactories(registry); - clBackend->RegisterTensorHandleFactories(registry); - - const BackendId& neonBackendId = neonBackend->GetId(); - const BackendId& clBackendId = clBackend->GetId(); - - BackendsMap backends; - backends[neonBackendId] = std::move(neonBackend); - backends[clBackendId] = std::move(clBackend); - - armnn::Graph graph; - - armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "input"); - - inputLayer->SetBackendId(neonBackendId); - - armnn::SoftmaxDescriptor smDesc; - armnn::SoftmaxLayer* const softmaxLayer1 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax1"); - softmaxLayer1->SetBackendId(clBackendId); - - armnn::SoftmaxLayer* const softmaxLayer2 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax2"); - softmaxLayer2->SetBackendId(neonBackendId); - - armnn::SoftmaxLayer* const softmaxLayer3 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax3"); - softmaxLayer3->SetBackendId(clBackendId); - - armnn::SoftmaxLayer* const softmaxLayer4 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax4"); - softmaxLayer4->SetBackendId(neonBackendId); - - armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output"); - outputLayer->SetBackendId(clBackendId); - - inputLayer->GetOutputSlot(0).Connect(softmaxLayer1->GetInputSlot(0)); - softmaxLayer1->GetOutputSlot(0).Connect(softmaxLayer2->GetInputSlot(0)); - softmaxLayer2->GetOutputSlot(0).Connect(softmaxLayer3->GetInputSlot(0)); - softmaxLayer3->GetOutputSlot(0).Connect(softmaxLayer4->GetInputSlot(0)); - softmaxLayer4->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); - - graph.TopologicalSort(); - - std::vector<std::string> errors; - auto result = SelectTensorHandleStrategy(graph, backends, registry, true, errors); - - BOOST_TEST(result.m_Error == false); - BOOST_TEST(result.m_Warning == false); - - OutputSlot& inputLayerOut = inputLayer->GetOutputSlot(0); - OutputSlot& softmaxLayer1Out = softmaxLayer1->GetOutputSlot(0); - OutputSlot& softmaxLayer2Out = softmaxLayer2->GetOutputSlot(0); - OutputSlot& softmaxLayer3Out = softmaxLayer3->GetOutputSlot(0); - OutputSlot& softmaxLayer4Out = softmaxLayer4->GetOutputSlot(0); - - // Check that the correct factory was selected - BOOST_TEST(inputLayerOut.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); - BOOST_TEST(softmaxLayer1Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); - BOOST_TEST(softmaxLayer2Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); - BOOST_TEST(softmaxLayer3Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); - BOOST_TEST(softmaxLayer4Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); - - // Check that the correct strategy was selected - BOOST_TEST((inputLayerOut.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); - BOOST_TEST((softmaxLayer1Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); - BOOST_TEST((softmaxLayer2Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); - BOOST_TEST((softmaxLayer3Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); - BOOST_TEST((softmaxLayer4Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); - - graph.AddCompatibilityLayers(backends, registry); - - // Test for copy layers - int copyCount= 0; - graph.ForEachLayer([©Count](Layer* layer) - { - if (layer->GetType() == LayerType::MemCopy) - { - copyCount++; - } - }); - BOOST_TEST(copyCount == 0); - - // Test for import layers - int importCount= 0; - graph.ForEachLayer([&importCount](Layer *layer) - { - if (layer->GetType() == LayerType::MemImport) - { - importCount++; - } - }); - BOOST_TEST(importCount == 0); -} +// Disabled Test Suite +//TEST_SUITE("BackendsCompatibility") +//TEST_CASE("Neon_Cl_DirectCompatibility_Test") +//{ +// auto neonBackend = std::make_unique<NeonBackend>(); +// auto clBackend = std::make_unique<ClBackend>(); +// +// TensorHandleFactoryRegistry registry; +// neonBackend->RegisterTensorHandleFactories(registry); +// clBackend->RegisterTensorHandleFactories(registry); +// +// const BackendId& neonBackendId = neonBackend->GetId(); +// const BackendId& clBackendId = clBackend->GetId(); +// +// BackendsMap backends; +// backends[neonBackendId] = std::move(neonBackend); +// backends[clBackendId] = std::move(clBackend); +// +// armnn::Graph graph; +// +// armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "input"); +// +// inputLayer->SetBackendId(neonBackendId); +// +// armnn::SoftmaxDescriptor smDesc; +// armnn::SoftmaxLayer* const softmaxLayer1 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax1"); +// softmaxLayer1->SetBackendId(clBackendId); +// +// armnn::SoftmaxLayer* const softmaxLayer2 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax2"); +// softmaxLayer2->SetBackendId(neonBackendId); +// +// armnn::SoftmaxLayer* const softmaxLayer3 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax3"); +// softmaxLayer3->SetBackendId(clBackendId); +// +// armnn::SoftmaxLayer* const softmaxLayer4 = graph.AddLayer<armnn::SoftmaxLayer>(smDesc, "softmax4"); +// softmaxLayer4->SetBackendId(neonBackendId); +// +// armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output"); +// outputLayer->SetBackendId(clBackendId); +// +// inputLayer->GetOutputSlot(0).Connect(softmaxLayer1->GetInputSlot(0)); +// softmaxLayer1->GetOutputSlot(0).Connect(softmaxLayer2->GetInputSlot(0)); +// softmaxLayer2->GetOutputSlot(0).Connect(softmaxLayer3->GetInputSlot(0)); +// softmaxLayer3->GetOutputSlot(0).Connect(softmaxLayer4->GetInputSlot(0)); +// softmaxLayer4->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); +// +// graph.TopologicalSort(); +// +// std::vector<std::string> errors; +// auto result = SelectTensorHandleStrategy(graph, backends, registry, true, errors); +// +// CHECK(result.m_Error == false); +// CHECK(result.m_Warning == false); +// +// OutputSlot& inputLayerOut = inputLayer->GetOutputSlot(0); +// OutputSlot& softmaxLayer1Out = softmaxLayer1->GetOutputSlot(0); +// OutputSlot& softmaxLayer2Out = softmaxLayer2->GetOutputSlot(0); +// OutputSlot& softmaxLayer3Out = softmaxLayer3->GetOutputSlot(0); +// OutputSlot& softmaxLayer4Out = softmaxLayer4->GetOutputSlot(0); +// +// // Check that the correct factory was selected +// CHECK(inputLayerOut.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); +// CHECK(softmaxLayer1Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); +// CHECK(softmaxLayer2Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); +// CHECK(softmaxLayer3Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); +// CHECK(softmaxLayer4Out.GetTensorHandleFactoryId() == "Arm/Cl/TensorHandleFactory"); +// +// // Check that the correct strategy was selected +// CHECK((inputLayerOut.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); +// CHECK((softmaxLayer1Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); +// CHECK((softmaxLayer2Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); +// CHECK((softmaxLayer3Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); +// CHECK((softmaxLayer4Out.GetEdgeStrategyForConnection(0) == EdgeStrategy::DirectCompatibility)); +// +// graph.AddCompatibilityLayers(backends, registry); +// +// // Test for copy layers +// int copyCount= 0; +// graph.ForEachLayer([©Count](Layer* layer) +// { +// if (layer->GetType() == LayerType::MemCopy) +// { +// copyCount++; +// } +// }); +// CHECK(copyCount == 0); +// +// // Test for import layers +// int importCount= 0; +// graph.ForEachLayer([&importCount](Layer *layer) +// { +// if (layer->GetType() == LayerType::MemImport) +// { +// importCount++; +// } +// }); +// CHECK(importCount == 0); +//} +// +//} #endif -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(BackendCapability) +TEST_SUITE("BackendCapability") +{ #if defined(ARMNNREF_ENABLED) -BOOST_AUTO_TEST_CASE(Ref_Backends_Capability_Test) +TEST_CASE("Ref_Backends_Capability_Test") { auto refBackend = std::make_unique<RefBackend>(); auto refCapabilities = refBackend->GetCapabilities(); - BOOST_CHECK(armnn::HasCapability("NonConstWeights", refCapabilities)); - BOOST_CHECK(armnn::HasCapability("AsyncExecution", refCapabilities)); + CHECK(armnn::HasCapability("NonConstWeights", refCapabilities)); + CHECK(armnn::HasCapability("AsyncExecution", refCapabilities)); armnn::BackendOptions::BackendOption nonConstWeights{"NonConstWeights", true}; armnn::BackendOptions::BackendOption AsyncExecution{"AsyncExecution", true}; - BOOST_CHECK(armnn::HasCapability(nonConstWeights, refCapabilities)); - BOOST_CHECK(armnn::HasCapability(AsyncExecution, refCapabilities)); + CHECK(armnn::HasCapability(nonConstWeights, refCapabilities)); + CHECK(armnn::HasCapability(AsyncExecution, refCapabilities)); } -BOOST_AUTO_TEST_CASE(Ref_Backends_Unkown_Capability_Test) +TEST_CASE("Ref_Backends_Unkown_Capability_Test") { auto refBackend = std::make_unique<RefBackend>(); auto refCapabilities = refBackend->GetCapabilities(); armnn::BackendOptions::BackendOption AsyncExecutionFalse{"AsyncExecution", false}; - BOOST_CHECK(!armnn::HasCapability(AsyncExecutionFalse, refCapabilities)); + CHECK(!armnn::HasCapability(AsyncExecutionFalse, refCapabilities)); armnn::BackendOptions::BackendOption AsyncExecutionInt{"AsyncExecution", 50}; - BOOST_CHECK(!armnn::HasCapability(AsyncExecutionFalse, refCapabilities)); + CHECK(!armnn::HasCapability(AsyncExecutionFalse, refCapabilities)); armnn::BackendOptions::BackendOption AsyncExecutionFloat{"AsyncExecution", 0.0f}; - BOOST_CHECK(!armnn::HasCapability(AsyncExecutionFloat, refCapabilities)); + CHECK(!armnn::HasCapability(AsyncExecutionFloat, refCapabilities)); armnn::BackendOptions::BackendOption AsyncExecutionString{"AsyncExecution", "true"}; - BOOST_CHECK(!armnn::HasCapability(AsyncExecutionString, refCapabilities)); + CHECK(!armnn::HasCapability(AsyncExecutionString, refCapabilities)); - BOOST_CHECK(!armnn::HasCapability("Telekinesis", refCapabilities)); + CHECK(!armnn::HasCapability("Telekinesis", refCapabilities)); armnn::BackendOptions::BackendOption unkownCapability{"Telekinesis", true}; - BOOST_CHECK(!armnn::HasCapability(unkownCapability, refCapabilities)); + CHECK(!armnn::HasCapability(unkownCapability, refCapabilities)); } #endif #if defined(ARMCOMPUTENEON_ENABLED) -BOOST_AUTO_TEST_CASE(Neon_Backends_Capability_Test) +TEST_CASE("Neon_Backends_Capability_Test") { auto neonBackend = std::make_unique<NeonBackend>(); auto neonCapabilities = neonBackend->GetCapabilities(); - BOOST_CHECK(armnn::HasCapability("NonConstWeights", neonCapabilities)); - BOOST_CHECK(armnn::HasCapability("AsyncExecution", neonCapabilities)); + CHECK(armnn::HasCapability("NonConstWeights", neonCapabilities)); + CHECK(armnn::HasCapability("AsyncExecution", neonCapabilities)); armnn::BackendOptions::BackendOption nonConstWeights{"NonConstWeights", false}; armnn::BackendOptions::BackendOption AsyncExecution{"AsyncExecution", false}; - BOOST_CHECK(armnn::HasCapability(nonConstWeights, neonCapabilities)); - BOOST_CHECK(armnn::HasCapability(AsyncExecution, neonCapabilities)); + CHECK(armnn::HasCapability(nonConstWeights, neonCapabilities)); + CHECK(armnn::HasCapability(AsyncExecution, neonCapabilities)); } #endif #if defined(ARMCOMPUTECL_ENABLED) -BOOST_AUTO_TEST_CASE(Cl_Backends_Capability_Test) +TEST_CASE("Cl_Backends_Capability_Test") { auto clBackend = std::make_unique<ClBackend>(); auto clCapabilities = clBackend->GetCapabilities(); - BOOST_CHECK(armnn::HasCapability("NonConstWeights", clCapabilities)); - BOOST_CHECK(armnn::HasCapability("AsyncExecution", clCapabilities)); + CHECK(armnn::HasCapability("NonConstWeights", clCapabilities)); + CHECK(armnn::HasCapability("AsyncExecution", clCapabilities)); armnn::BackendOptions::BackendOption nonConstWeights{"NonConstWeights", false}; armnn::BackendOptions::BackendOption AsyncExecution{"AsyncExecution", false}; - BOOST_CHECK(armnn::HasCapability(nonConstWeights, clCapabilities)); - BOOST_CHECK(armnn::HasCapability(AsyncExecution, clCapabilities)); + CHECK(armnn::HasCapability(nonConstWeights, clCapabilities)); + CHECK(armnn::HasCapability(AsyncExecution, clCapabilities)); } #endif -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/ConcatEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ConcatEndToEndTestImpl.hpp index 58a1f39a78..5b2f33fc1a 100644 --- a/src/backends/backendsCommon/test/ConcatEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ConcatEndToEndTestImpl.hpp @@ -12,7 +12,7 @@ #include <armnn/utility/NumericCast.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -64,7 +64,7 @@ void ConcatDim0EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -128,8 +128,6 @@ void ConcatDim1EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis); - BOOST_TEST_CHECKPOINT("create a network"); - // Creates structures for input & output. std::vector<T> inputData{ 1, 2, @@ -192,8 +190,6 @@ void ConcatDim2EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis); - BOOST_TEST_CHECKPOINT("create a network"); - // Creates structures for input & output. std::vector<T> inputData{ 1, 2, @@ -255,8 +251,6 @@ void ConcatDim3EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis); - BOOST_TEST_CHECKPOINT("create a network"); - // Creates structures for input & output. std::vector<T> inputData{ 1, 2, diff --git a/src/backends/backendsCommon/test/DefaultAsyncExecuteTest.cpp b/src/backends/backendsCommon/test/DefaultAsyncExecuteTest.cpp index 2dd5298059..ea997290e5 100644 --- a/src/backends/backendsCommon/test/DefaultAsyncExecuteTest.cpp +++ b/src/backends/backendsCommon/test/DefaultAsyncExecuteTest.cpp @@ -8,19 +8,21 @@ #include <backendsCommon/TensorHandle.hpp> #include <backendsCommon/Workload.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> using namespace armnn; -BOOST_AUTO_TEST_SUITE(WorkloadAsyncExecuteTests) namespace { +TEST_SUITE("WorkloadAsyncExecuteTests") +{ + struct Workload0 : BaseWorkload<ElementwiseUnaryQueueDescriptor> { Workload0(const ElementwiseUnaryQueueDescriptor& descriptor, const WorkloadInfo& info) - : BaseWorkload(descriptor, info) + : BaseWorkload(descriptor, info) { } @@ -33,7 +35,9 @@ struct Workload0 : BaseWorkload<ElementwiseUnaryQueueDescriptor> int* inVals = static_cast<int*>(m_Data.m_Inputs[0][0].Map()); int* outVals = static_cast<int*>(m_Data.m_Outputs[0][0].Map()); - for (unsigned int i = 0; i < m_Data.m_Inputs[0][0].GetShape().GetNumElements(); ++i) + for (unsigned int i = 0; + i < m_Data.m_Inputs[0][0].GetShape().GetNumElements(); + ++i) { outVals[i] = inVals[i] * outVals[i]; inVals[i] = outVals[i]; @@ -45,7 +49,9 @@ struct Workload0 : BaseWorkload<ElementwiseUnaryQueueDescriptor> int* inVals = static_cast<int*>(desc.m_Inputs[0][0].Map()); int* outVals = static_cast<int*>(desc.m_Outputs[0][0].Map()); - for (unsigned int i = 0; i < desc.m_Inputs[0][0].GetShape().GetNumElements(); ++i) + for (unsigned int i = 0; + i < desc.m_Inputs[0][0].GetShape().GetNumElements(); + ++i) { outVals[i] = inVals[i] + outVals[i]; inVals[i] = outVals[i]; @@ -61,7 +67,7 @@ struct Workload0 : BaseWorkload<ElementwiseUnaryQueueDescriptor> struct Workload1 : BaseWorkload<ElementwiseUnaryQueueDescriptor> { Workload1(const ElementwiseUnaryQueueDescriptor& descriptor, const WorkloadInfo& info) - : BaseWorkload(descriptor, info) + : BaseWorkload(descriptor, info) { } @@ -70,7 +76,9 @@ struct Workload1 : BaseWorkload<ElementwiseUnaryQueueDescriptor> int* inVals = static_cast<int*>(m_Data.m_Inputs[0][0].Map()); int* outVals = static_cast<int*>(m_Data.m_Outputs[0][0].Map()); - for (unsigned int i = 0; i < m_Data.m_Inputs[0][0].GetShape().GetNumElements(); ++i) + for (unsigned int i = 0; + i < m_Data.m_Inputs[0][0].GetShape().GetNumElements(); + ++i) { outVals[i] = inVals[i] * outVals[i]; inVals[i] = outVals[i]; @@ -83,7 +91,9 @@ void ValidateTensor(ITensorHandle* tensorHandle, int expectedValue) int* actualOutput = static_cast<int*>(tensorHandle->Map()); bool allValuesCorrect = true; - for (unsigned int i = 0; i < tensorHandle->GetShape().GetNumElements(); ++i) + for (unsigned int i = 0; + i < tensorHandle->GetShape().GetNumElements(); + ++i) { if (actualOutput[i] != expectedValue) { @@ -91,7 +101,7 @@ void ValidateTensor(ITensorHandle* tensorHandle, int expectedValue) } } - BOOST_CHECK(allValuesCorrect); + CHECK(allValuesCorrect); } template<typename Workload> @@ -108,7 +118,7 @@ std::unique_ptr<Workload> CreateWorkload(TensorInfo info, ITensorHandle* inputTe return std::make_unique<Workload>(elementwiseUnaryQueueDescriptor, workloadInfo); } -BOOST_AUTO_TEST_CASE(TestAsyncExecute) +TEST_CASE("TestAsyncExecute") { TensorInfo info({5}, DataType::Signed32); @@ -145,7 +155,7 @@ BOOST_AUTO_TEST_CASE(TestAsyncExecute) ValidateTensor(&workload0.get()->GetQueueDescriptor()->m_Inputs[0][0], expectedExecuteval); } -BOOST_AUTO_TEST_CASE(TestDefaultAsyncExecute) +TEST_CASE("TestDefaultAsyncExecute") { TensorInfo info({5}, DataType::Signed32); @@ -179,7 +189,7 @@ BOOST_AUTO_TEST_CASE(TestDefaultAsyncExecute) ValidateTensor(workingMemDescriptor.m_Inputs[0], expectedExecuteval); } -BOOST_AUTO_TEST_CASE(TestDefaultAsyncExeuteWithThreads) +TEST_CASE("TestDefaultAsyncExeuteWithThreads") { // Use a large vector so the threads have a chance to interact unsigned int vecSize = 1000; @@ -243,6 +253,6 @@ BOOST_AUTO_TEST_CASE(TestDefaultAsyncExeuteWithThreads) ValidateTensor(workingMemDescriptor2.m_Inputs[0], expectedExecuteval2); } -BOOST_AUTO_TEST_SUITE_END() +} }
\ No newline at end of file diff --git a/src/backends/backendsCommon/test/DequantizeEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/DequantizeEndToEndTestImpl.hpp index e62415904c..a5e2faccc9 100644 --- a/src/backends/backendsCommon/test/DequantizeEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/DequantizeEndToEndTestImpl.hpp @@ -10,6 +10,8 @@ #include <armnn/INetwork.hpp> #include <ResolveType.hpp> +#include <doctest/doctest.h> + namespace { @@ -45,7 +47,7 @@ void DequantizeEndToEndLayerTestImpl(const std::vector<BackendId>& backends, // Builds up the structure of the network armnn::INetworkPtr net = CreateDequantizeNetwork<T>(inputInfo, outputInfo); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); std::map<int, std::vector<T>> inputTensorData = { { 0, input } }; std::map<int, std::vector<float>> expectedOutputData = { { 0, expectedOutput } }; diff --git a/src/backends/backendsCommon/test/DetectionPostProcessEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/DetectionPostProcessEndToEndTestImpl.hpp index 5a42550a5f..a566964ba2 100644 --- a/src/backends/backendsCommon/test/DetectionPostProcessEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/DetectionPostProcessEndToEndTestImpl.hpp @@ -10,6 +10,8 @@ #include <armnn/INetwork.hpp> #include <ResolveType.hpp> +#include <doctest/doctest.h> + namespace{ template<typename T> @@ -89,7 +91,7 @@ void DetectionPostProcessEndToEnd(const std::vector<BackendId>& backends, bool u armnn::INetworkPtr net = CreateDetectionPostProcessNetwork<T>(boxEncodingsInfo, scoresInfo, anchorsInfo, anchors, useRegularNms); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); std::map<int, std::vector<T>> inputTensorData = {{ 0, boxEncodings }, { 1, scores }}; std::map<int, std::vector<float>> expectedOutputData = {{ 0, expectedDetectionBoxes }, diff --git a/src/backends/backendsCommon/test/DynamicBackendTests.cpp b/src/backends/backendsCommon/test/DynamicBackendTests.cpp index b1c8234691..669ce6020e 100644 --- a/src/backends/backendsCommon/test/DynamicBackendTests.cpp +++ b/src/backends/backendsCommon/test/DynamicBackendTests.cpp @@ -7,13 +7,14 @@ #include <test/UnitTests.hpp> -BOOST_AUTO_TEST_SUITE(DynamicBackendTests) +#include <doctest/doctest.h> +TEST_SUITE("DynamicBackendTests") +{ ARMNN_SIMPLE_TEST_CASE(OpenCloseHandle, OpenCloseHandleTestImpl); ARMNN_SIMPLE_TEST_CASE(CloseInvalidHandle, CloseInvalidHandleTestImpl); ARMNN_SIMPLE_TEST_CASE(OpenEmptyFileName, OpenEmptyFileNameTestImpl); ARMNN_SIMPLE_TEST_CASE(OpenNotExistingFile, OpenNotExistingFileTestImpl); -ARMNN_SIMPLE_TEST_CASE(OpenNotSharedObjectFile, OpenNotSharedObjectTestImpl); ARMNN_SIMPLE_TEST_CASE(GetValidEntryPoint, GetValidEntryPointTestImpl); ARMNN_SIMPLE_TEST_CASE(GetNameMangledEntryPoint, GetNameMangledEntryPointTestImpl); ARMNN_SIMPLE_TEST_CASE(GetNoExternEntryPoint, GetNoExternEntryPointTestImpl); @@ -21,7 +22,6 @@ ARMNN_SIMPLE_TEST_CASE(GetNotExistingEntryPoint, GetNotExistingEntryPointTestImp ARMNN_SIMPLE_TEST_CASE(BackendVersioning, BackendVersioningTestImpl); - ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendObjectInvalidHandle, CreateDynamicBackendObjectInvalidHandleTestImpl); ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendObjectInvalidInterface1, @@ -39,11 +39,12 @@ ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendObjectInvalidInterface6, ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendObjectInvalidInterface7, CreateDynamicBackendObjectInvalidInterface7TestImpl); +ARMNN_SIMPLE_TEST_CASE(OpenNotSharedObjectFile, OpenNotSharedObjectTestImpl); +ARMNN_SIMPLE_TEST_CASE(GetSharedObjects, GetSharedObjectsTestImpl); + ARMNN_SIMPLE_TEST_CASE(GetBackendPaths, GetBackendPathsTestImpl) ARMNN_SIMPLE_TEST_CASE(GetBackendPathsOverride, GetBackendPathsOverrideTestImpl) -ARMNN_SIMPLE_TEST_CASE(GetSharedObjects, GetSharedObjectsTestImpl); - ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackends, CreateDynamicBackendsTestImpl); ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendsNoPaths, CreateDynamicBackendsNoPathsTestImpl); ARMNN_SIMPLE_TEST_CASE(CreateDynamicBackendsAllInvalid, CreateDynamicBackendsAllInvalidTestImpl); @@ -76,4 +77,4 @@ ARMNN_SIMPLE_TEST_CASE(CreateSampleDynamicBackend, CreateSampleDynamicBackendTes ARMNN_SIMPLE_TEST_CASE(SampleDynamicBackendEndToEnd, SampleDynamicBackendEndToEndTestImpl); #endif -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/DynamicBackendTests.hpp b/src/backends/backendsCommon/test/DynamicBackendTests.hpp index a4f1613a58..53ff5caa3f 100644 --- a/src/backends/backendsCommon/test/DynamicBackendTests.hpp +++ b/src/backends/backendsCommon/test/DynamicBackendTests.hpp @@ -18,7 +18,11 @@ #include <string> #include <memory> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> + +#if defined(_MSC_VER) +#include <Windows.h> +#endif #if !defined(DYNAMIC_BACKEND_BUILD_DIR) #define DYNAMIC_BACKEND_BUILD_DIR fs::path("./") @@ -106,50 +110,43 @@ private: FactoryStorage m_TempStorage; }; +#if defined(_MSC_VER) +std::string GetUnitTestExecutablePath() +{ + char buffer[MAX_PATH] = ""; + GetModuleFileNameA(NULL, buffer, MAX_PATH); + fs::path executablePath(buffer); + return executablePath.parent_path(); +} + +#else +std::string GetUnitTestExecutablePath() +{ + char buffer[PATH_MAX] = ""; + if (readlink("/proc/self/exe", buffer, PATH_MAX) != -1) + { + fs::path executablePath(buffer); + return executablePath.parent_path(); + } + return ""; +} +#endif + std::string GetBasePath(const std::string& basePath) { using namespace fs; // What we're looking for here is the location of the UnitTests executable. - // In the normal build environment there are a series of files and - // directories created by cmake. If the executable has been relocated they - // may not be there. The search hierarchy is: - // * User specified --dynamic-backend-build-dir - // * Compile time value of DYNAMIC_BACKEND_BUILD_DIR. - // * Arg0 location. - // * Fall back value of current directory. - path programLocation = DYNAMIC_BACKEND_BUILD_DIR; - // Look for the specific argument --dynamic-backend-build-dir? - if (boost::unit_test::framework::master_test_suite().argc == 3) - { - // Boost custom arguments begin after a '--' on the command line. - if (g_TestDirCLI.compare(boost::unit_test::framework::master_test_suite().argv[1]) == 0) - { - // Then the next argument is the path. - programLocation = boost::unit_test::framework::master_test_suite().argv[2]; - } - } - else + // Fall back value of current directory. + path programLocation = GetUnitTestExecutablePath(); + if (!exists(programLocation)) { - // Start by checking if DYNAMIC_BACKEND_BUILD_DIR value exist. - if (!exists(programLocation)) - { - // That doesn't exist try looking at arg[0]. - path arg0Path(boost::unit_test::framework::master_test_suite().argv[0]); - arg0Path.remove_filename(); - path arg0SharedObjectPath(arg0Path); - arg0SharedObjectPath.append(basePath); - if (exists(arg0SharedObjectPath)) - { - // Yeah arg0 worked. - programLocation = arg0Path; - } - } + programLocation = DYNAMIC_BACKEND_BUILD_DIR; } + // This is the base path from the build where the test libraries were built. path sharedObjectPath = programLocation.append(basePath); - BOOST_REQUIRE_MESSAGE(exists(sharedObjectPath), "Base path for shared objects does not exist: " + - sharedObjectPath.string() + "\nTo specify the root of this base path on the " + - "command line add: \'-- --dynamic-backend-build-dir <path>\'"); + REQUIRE_MESSAGE(exists(sharedObjectPath), + "Base path for shared objects does not exist: " + sharedObjectPath.string()); return sharedObjectPath.string(); } @@ -192,7 +189,7 @@ std::string GetTestFilePath(const std::string& directory, const std::string& fil path directoryPath(directory); path fileNamePath = directoryPath.append(fileName); - BOOST_CHECK(exists(fileNamePath)); + CHECK(exists(fileNamePath)); return fileNamePath.string(); } @@ -205,8 +202,8 @@ void OpenCloseHandleTestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendUtils::CloseHandle(sharedObjectHandle); } @@ -224,8 +221,8 @@ void OpenEmptyFileNameTestImpl() using namespace armnn; void* sharedObjectHandle = nullptr; - BOOST_CHECK_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(""), RuntimeException); - BOOST_TEST((sharedObjectHandle == nullptr)); + CHECK_THROWS_AS(sharedObjectHandle = DynamicBackendUtils::OpenHandle(""), RuntimeException); + CHECK((sharedObjectHandle == nullptr)); } void OpenNotExistingFileTestImpl() @@ -233,8 +230,8 @@ void OpenNotExistingFileTestImpl() using namespace armnn; void* sharedObjectHandle = nullptr; - BOOST_CHECK_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle("NotExistingFileName"), RuntimeException); - BOOST_TEST((sharedObjectHandle == nullptr)); + CHECK_THROWS_AS(sharedObjectHandle = DynamicBackendUtils::OpenHandle("NotExistingFileName"), RuntimeException); + CHECK((sharedObjectHandle == nullptr)); } void OpenNotSharedObjectTestImpl() @@ -245,8 +242,8 @@ void OpenNotSharedObjectTestImpl() std::string notSharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestNoSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(notSharedObjectFilePath), RuntimeException); - BOOST_TEST((sharedObjectHandle == nullptr)); + CHECK_THROWS_AS(sharedObjectHandle = DynamicBackendUtils::OpenHandle(notSharedObjectFilePath), RuntimeException); + CHECK((sharedObjectHandle == nullptr)); } void GetValidEntryPointTestImpl() @@ -257,15 +254,15 @@ void GetValidEntryPointTestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); using TestFunctionType = int(*)(int); TestFunctionType testFunctionPointer = nullptr; - BOOST_CHECK_NO_THROW(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, + CHECK_NOTHROW(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, "TestFunction1")); - BOOST_TEST((testFunctionPointer != nullptr)); - BOOST_TEST(testFunctionPointer(7) == 7); + CHECK((testFunctionPointer != nullptr)); + CHECK(testFunctionPointer(7) == 7); DynamicBackendUtils::CloseHandle(sharedObjectHandle); } @@ -278,15 +275,15 @@ void GetNameMangledEntryPointTestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); using TestFunctionType = int(*)(int); TestFunctionType testFunctionPointer = nullptr; - BOOST_CHECK_THROW(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, + CHECK_THROWS_AS(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, "TestFunction2"), RuntimeException); - BOOST_TEST((testFunctionPointer == nullptr)); + CHECK((testFunctionPointer == nullptr)); DynamicBackendUtils::CloseHandle(sharedObjectHandle); } @@ -299,15 +296,15 @@ void GetNoExternEntryPointTestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); using TestFunctionType = int(*)(int); TestFunctionType testFunctionPointer = nullptr; - BOOST_CHECK_THROW(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, + CHECK_THROWS_AS(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, "TestFunction3"), RuntimeException); - BOOST_TEST((testFunctionPointer == nullptr)); + CHECK((testFunctionPointer == nullptr)); DynamicBackendUtils::CloseHandle(sharedObjectHandle); } @@ -320,15 +317,15 @@ void GetNotExistingEntryPointTestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestSharedObjectFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); using TestFunctionType = int(*)(int); TestFunctionType testFunctionPointer = nullptr; - BOOST_CHECK_THROW(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, + CHECK_THROWS_AS(testFunctionPointer = DynamicBackendUtils::GetEntryPoint<TestFunctionType>(sharedObjectHandle, "TestFunction4"), RuntimeException); - BOOST_TEST((testFunctionPointer == nullptr)); + CHECK((testFunctionPointer == nullptr)); DynamicBackendUtils::CloseHandle(sharedObjectHandle); } @@ -342,36 +339,36 @@ void BackendVersioningTestImpl() // Same backend and backend API versions are compatible with the backend API BackendVersion sameBackendVersion{ 2, 4 }; - BOOST_TEST(sameBackendVersion == backendApiVersion); - BOOST_TEST(sameBackendVersion <= backendApiVersion); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, sameBackendVersion) == true); + CHECK(sameBackendVersion == backendApiVersion); + CHECK(sameBackendVersion <= backendApiVersion); + CHECK(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, sameBackendVersion) == true); // Backend versions that differ from the backend API version by major revision are not compatible // with the backend API BackendVersion laterMajorBackendVersion{ 3, 4 }; - BOOST_TEST(!(laterMajorBackendVersion == backendApiVersion)); - BOOST_TEST(!(laterMajorBackendVersion <= backendApiVersion)); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, laterMajorBackendVersion) == false); + CHECK(!(laterMajorBackendVersion == backendApiVersion)); + CHECK(!(laterMajorBackendVersion <= backendApiVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, laterMajorBackendVersion) == false); BackendVersion earlierMajorBackendVersion{ 1, 4 }; - BOOST_TEST(!(earlierMajorBackendVersion == backendApiVersion)); - BOOST_TEST(earlierMajorBackendVersion <= backendApiVersion); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, + CHECK(!(earlierMajorBackendVersion == backendApiVersion)); + CHECK(earlierMajorBackendVersion <= backendApiVersion); + CHECK(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, earlierMajorBackendVersion) == false); // Backend versions with the same major revision but later minor revision than // the backend API version are not compatible with the backend API BackendVersion laterMinorBackendVersion{ 2, 5 }; - BOOST_TEST(!(laterMinorBackendVersion == backendApiVersion)); - BOOST_TEST(!(laterMinorBackendVersion <= backendApiVersion)); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, laterMinorBackendVersion) == false); + CHECK(!(laterMinorBackendVersion == backendApiVersion)); + CHECK(!(laterMinorBackendVersion <= backendApiVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, laterMinorBackendVersion) == false); // Backend versions with the same major revision but earlier minor revision than // the backend API version are compatible with the backend API BackendVersion earlierMinorBackendVersion{ 2, 3 }; - BOOST_TEST(!(earlierMinorBackendVersion == backendApiVersion)); - BOOST_TEST(earlierMinorBackendVersion <= backendApiVersion); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, earlierMinorBackendVersion) == true); + CHECK(!(earlierMinorBackendVersion == backendApiVersion)); + CHECK(earlierMinorBackendVersion <= backendApiVersion); + CHECK(TestDynamicBackendUtils::IsBackendCompatibleTest(backendApiVersion, earlierMinorBackendVersion) == true); } #if defined(ARMNNREF_ENABLED) @@ -387,41 +384,41 @@ void CreateValidDynamicBackendObjectTestImpl() std::string testSubDirectory = GetTestSubDirectory(g_TestDynamicBackendSubDir); // We expect this path to exists so we can load a valid dynamic backend. - BOOST_CHECK_MESSAGE(fs::exists(testSubDirectory), + CHECK_MESSAGE(fs::exists(testSubDirectory), "Base path for shared objects does not exist: " + testSubDirectory); std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestValidTestDynamicBackendFileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_NO_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle))); - BOOST_TEST((dynamicBackend != nullptr)); + CHECK_NOTHROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle))); + CHECK((dynamicBackend != nullptr)); BackendId dynamicBackendId; - BOOST_CHECK_NO_THROW(dynamicBackendId = dynamicBackend->GetBackendId()); - BOOST_TEST((dynamicBackendId == "ValidTestDynamicBackend")); + CHECK_NOTHROW(dynamicBackendId = dynamicBackend->GetBackendId()); + CHECK((dynamicBackendId == "ValidTestDynamicBackend")); BackendVersion dynamicBackendVersion; - BOOST_CHECK_NO_THROW(dynamicBackendVersion = dynamicBackend->GetBackendVersion()); - BOOST_TEST((dynamicBackendVersion == IBackendInternal::GetApiVersion())); + CHECK_NOTHROW(dynamicBackendVersion = dynamicBackend->GetBackendVersion()); + CHECK((dynamicBackendVersion == IBackendInternal::GetApiVersion())); IBackendInternalUniquePtr dynamicBackendInstance1; - BOOST_CHECK_NO_THROW(dynamicBackendInstance1 = dynamicBackend->GetBackend()); - BOOST_TEST((dynamicBackendInstance1 != nullptr)); + CHECK_NOTHROW(dynamicBackendInstance1 = dynamicBackend->GetBackend()); + CHECK((dynamicBackendInstance1 != nullptr)); BackendRegistry::FactoryFunction dynamicBackendFactoryFunction = nullptr; - BOOST_CHECK_NO_THROW(dynamicBackendFactoryFunction = dynamicBackend->GetFactoryFunction()); - BOOST_TEST((dynamicBackendFactoryFunction != nullptr)); + CHECK_NOTHROW(dynamicBackendFactoryFunction = dynamicBackend->GetFactoryFunction()); + CHECK((dynamicBackendFactoryFunction != nullptr)); IBackendInternalUniquePtr dynamicBackendInstance2; - BOOST_CHECK_NO_THROW(dynamicBackendInstance2 = dynamicBackendFactoryFunction()); - BOOST_TEST((dynamicBackendInstance2 != nullptr)); + CHECK_NOTHROW(dynamicBackendInstance2 = dynamicBackendFactoryFunction()); + CHECK((dynamicBackendInstance2 != nullptr)); - BOOST_TEST((dynamicBackendInstance1->GetId() == "ValidTestDynamicBackend")); - BOOST_TEST((dynamicBackendInstance2->GetId() == "ValidTestDynamicBackend")); + CHECK((dynamicBackendInstance1->GetId() == "ValidTestDynamicBackend")); + CHECK((dynamicBackendInstance2->GetId() == "ValidTestDynamicBackend")); } #endif @@ -433,8 +430,8 @@ void CreateDynamicBackendObjectInvalidHandleTestImpl() void* sharedObjectHandle = nullptr; DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), InvalidArgumentException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), InvalidArgumentException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface1TestImpl() @@ -448,12 +445,12 @@ void CreateDynamicBackendObjectInvalidInterface1TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend1FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface2TestImpl() @@ -468,12 +465,12 @@ void CreateDynamicBackendObjectInvalidInterface2TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend2FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface3TestImpl() @@ -488,12 +485,12 @@ void CreateDynamicBackendObjectInvalidInterface3TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend3FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface4TestImpl() @@ -508,12 +505,12 @@ void CreateDynamicBackendObjectInvalidInterface4TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend4FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface5TestImpl() @@ -529,12 +526,12 @@ void CreateDynamicBackendObjectInvalidInterface5TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend5FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void CreateDynamicBackendObjectInvalidInterface6TestImpl() @@ -550,32 +547,32 @@ void CreateDynamicBackendObjectInvalidInterface6TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend6FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_NO_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle))); - BOOST_TEST((dynamicBackend != nullptr)); + CHECK_NOTHROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle))); + CHECK((dynamicBackend != nullptr)); BackendId dynamicBackendId; - BOOST_CHECK_NO_THROW(dynamicBackendId = dynamicBackend->GetBackendId()); - BOOST_TEST((dynamicBackendId == "InvalidTestDynamicBackend")); + CHECK_NOTHROW(dynamicBackendId = dynamicBackend->GetBackendId()); + CHECK((dynamicBackendId == "InvalidTestDynamicBackend")); BackendVersion dynamicBackendVersion; - BOOST_CHECK_NO_THROW(dynamicBackendVersion = dynamicBackend->GetBackendVersion()); - BOOST_TEST((dynamicBackendVersion == BackendVersion({ 1, 0 }))); + CHECK_NOTHROW(dynamicBackendVersion = dynamicBackend->GetBackendVersion()); + CHECK((dynamicBackendVersion == BackendVersion({ 1, 0 }))); IBackendInternalUniquePtr dynamicBackendInstance1; - BOOST_CHECK_THROW(dynamicBackendInstance1 = dynamicBackend->GetBackend(), RuntimeException); - BOOST_TEST((dynamicBackendInstance1 == nullptr)); + CHECK_THROWS_AS(dynamicBackendInstance1 = dynamicBackend->GetBackend(), RuntimeException); + CHECK((dynamicBackendInstance1 == nullptr)); BackendRegistry::FactoryFunction dynamicBackendFactoryFunction = nullptr; - BOOST_CHECK_NO_THROW(dynamicBackendFactoryFunction = dynamicBackend->GetFactoryFunction()); - BOOST_TEST((dynamicBackendFactoryFunction != nullptr)); + CHECK_NOTHROW(dynamicBackendFactoryFunction = dynamicBackend->GetFactoryFunction()); + CHECK((dynamicBackendFactoryFunction != nullptr)); IBackendInternalUniquePtr dynamicBackendInstance2; - BOOST_CHECK_THROW(dynamicBackendInstance2 = dynamicBackendFactoryFunction(), RuntimeException); - BOOST_TEST((dynamicBackendInstance2 == nullptr)); + CHECK_THROWS_AS(dynamicBackendInstance2 = dynamicBackendFactoryFunction(), RuntimeException); + CHECK((dynamicBackendInstance2 == nullptr)); } void CreateDynamicBackendObjectInvalidInterface7TestImpl() @@ -591,12 +588,12 @@ void CreateDynamicBackendObjectInvalidInterface7TestImpl() std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestInvalidTestDynamicBackend7FileName); void* sharedObjectHandle = nullptr; - BOOST_CHECK_NO_THROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); - BOOST_TEST((sharedObjectHandle != nullptr)); + CHECK_NOTHROW(sharedObjectHandle = DynamicBackendUtils::OpenHandle(sharedObjectFilePath)); + CHECK((sharedObjectHandle != nullptr)); DynamicBackendPtr dynamicBackend; - BOOST_CHECK_THROW(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); - BOOST_TEST((dynamicBackend == nullptr)); + CHECK_THROWS_AS(dynamicBackend.reset(new DynamicBackend(sharedObjectHandle)), RuntimeException); + CHECK((dynamicBackend == nullptr)); } void GetBackendPathsTestImpl() @@ -616,67 +613,67 @@ void GetBackendPathsTestImpl() std::string subDir3 = GetTestSubDirectory(g_TestDynamicBackendsSubDir3); std::string subDir4 = GetTestSubDirectory(g_TestDynamicBackendsSubDir4); - BOOST_CHECK(exists(subDir1)); - BOOST_CHECK(exists(subDir2)); - BOOST_CHECK(exists(subDir3)); - BOOST_CHECK(!exists(subDir4)); + CHECK(exists(subDir1)); + CHECK(exists(subDir2)); + CHECK(exists(subDir3)); + CHECK(!exists(subDir4)); // No path - BOOST_TEST(TestDynamicBackendUtils::GetBackendPathsImplTest("").empty()); + CHECK(TestDynamicBackendUtils::GetBackendPathsImplTest("").empty()); // Malformed path std::string malformedDir(subDir1 + "/" + subDir1); - BOOST_TEST(TestDynamicBackendUtils::GetBackendPathsImplTest(malformedDir).size()==0); + CHECK(TestDynamicBackendUtils::GetBackendPathsImplTest(malformedDir).size()==0); // Single valid path std::vector<std::string> DynamicBackendPaths2 = TestDynamicBackendUtils::GetBackendPathsImplTest(subDir1); - BOOST_TEST(DynamicBackendPaths2.size() == 1); - BOOST_TEST(DynamicBackendPaths2[0] == subDir1); + CHECK(DynamicBackendPaths2.size() == 1); + CHECK(DynamicBackendPaths2[0] == subDir1); // Multiple equal and valid paths std::string multipleEqualDirs(subDir1 + ":" + subDir1); std::vector<std::string> DynamicBackendPaths3 = TestDynamicBackendUtils::GetBackendPathsImplTest(multipleEqualDirs); - BOOST_TEST(DynamicBackendPaths3.size() == 1); - BOOST_TEST(DynamicBackendPaths3[0] == subDir1); + CHECK(DynamicBackendPaths3.size() == 1); + CHECK(DynamicBackendPaths3[0] == subDir1); // Multiple empty paths - BOOST_TEST(TestDynamicBackendUtils::GetBackendPathsImplTest(":::").empty()); + CHECK(TestDynamicBackendUtils::GetBackendPathsImplTest(":::").empty()); // Multiple valid paths std::string multipleValidPaths(subDir1 + ":" + subDir2 + ":" + subDir3); std::vector<std::string> DynamicBackendPaths5 = TestDynamicBackendUtils::GetBackendPathsImplTest(multipleValidPaths); - BOOST_TEST(DynamicBackendPaths5.size() == 3); - BOOST_TEST(DynamicBackendPaths5[0] == subDir1); - BOOST_TEST(DynamicBackendPaths5[1] == subDir2); - BOOST_TEST(DynamicBackendPaths5[2] == subDir3); + CHECK(DynamicBackendPaths5.size() == 3); + CHECK(DynamicBackendPaths5[0] == subDir1); + CHECK(DynamicBackendPaths5[1] == subDir2); + CHECK(DynamicBackendPaths5[2] == subDir3); // Valid among empty paths std::string validAmongEmptyDirs("::" + subDir1 + ":"); std::vector<std::string> DynamicBackendPaths6 = TestDynamicBackendUtils::GetBackendPathsImplTest(validAmongEmptyDirs); - BOOST_TEST(DynamicBackendPaths6.size() == 1); - BOOST_TEST(DynamicBackendPaths6[0] == subDir1); + CHECK(DynamicBackendPaths6.size() == 1); + CHECK(DynamicBackendPaths6[0] == subDir1); // Invalid among empty paths std::string invalidAmongEmptyDirs(":" + subDir4 + "::"); - BOOST_TEST(TestDynamicBackendUtils::GetBackendPathsImplTest(invalidAmongEmptyDirs).empty()); + CHECK(TestDynamicBackendUtils::GetBackendPathsImplTest(invalidAmongEmptyDirs).empty()); // Valid, invalid and empty paths std::string validInvalidEmptyDirs(subDir1 + ":" + subDir4 + ":"); std::vector<std::string> DynamicBackendPaths8 = TestDynamicBackendUtils::GetBackendPathsImplTest(validInvalidEmptyDirs); - BOOST_TEST(DynamicBackendPaths8.size() == 1); - BOOST_TEST(DynamicBackendPaths8[0] == subDir1); + CHECK(DynamicBackendPaths8.size() == 1); + CHECK(DynamicBackendPaths8[0] == subDir1); // Mix of duplicates of valid, invalid and empty paths std::string duplicateValidInvalidEmptyDirs(validInvalidEmptyDirs + ":" + validInvalidEmptyDirs + ":" + subDir2 + ":" + subDir2); std::vector<std::string> DynamicBackendPaths9 = TestDynamicBackendUtils::GetBackendPathsImplTest(duplicateValidInvalidEmptyDirs); - BOOST_TEST(DynamicBackendPaths9.size() == 2); - BOOST_TEST(DynamicBackendPaths9[0] == subDir1); - BOOST_TEST(DynamicBackendPaths9[1] == subDir2); + CHECK(DynamicBackendPaths9.size() == 2); + CHECK(DynamicBackendPaths9[0] == subDir1); + CHECK(DynamicBackendPaths9[1] == subDir2); } void GetBackendPathsOverrideTestImpl() @@ -687,17 +684,17 @@ void GetBackendPathsOverrideTestImpl() std::string subDir1 = GetTestSubDirectory(g_TestDynamicBackendsSubDir1); std::string subDir4 = GetTestSubDirectory(g_TestDynamicBackendsSubDir4); - BOOST_CHECK(exists(subDir1)); - BOOST_CHECK(!exists(subDir4)); + CHECK(exists(subDir1)); + CHECK(!exists(subDir4)); // Override with valid path std::vector<std::string> validResult = DynamicBackendUtils::GetBackendPaths(subDir1); - BOOST_TEST(validResult.size() == 1); - BOOST_TEST(validResult[0] == subDir1); + CHECK(validResult.size() == 1); + CHECK(validResult[0] == subDir1); // Override with invalid path std::vector<std::string> invalidResult = DynamicBackendUtils::GetBackendPaths(subDir4); - BOOST_TEST(invalidResult.empty()); + CHECK(invalidResult.empty()); } void GetSharedObjectsTestImpl() @@ -753,10 +750,10 @@ void GetSharedObjectsTestImpl() std::string testDynamicBackendsSubDir2 = GetTestSubDirectory(g_TestDynamicBackendsSubDir2); std::string testDynamicBackendsSubDir3 = GetTestSubDirectory(g_TestDynamicBackendsSubDir3); std::string testDynamicBackendsSubDir4 = GetTestSubDirectory(g_TestDynamicBackendsSubDir4); - BOOST_CHECK(exists(testDynamicBackendsSubDir1)); - BOOST_CHECK(exists(testDynamicBackendsSubDir2)); - BOOST_CHECK(exists(testDynamicBackendsSubDir3)); - BOOST_CHECK(!exists(testDynamicBackendsSubDir4)); + CHECK(exists(testDynamicBackendsSubDir1)); + CHECK(exists(testDynamicBackendsSubDir2)); + CHECK(exists(testDynamicBackendsSubDir3)); + CHECK(!exists(testDynamicBackendsSubDir4)); std::vector<std::string> backendPaths { @@ -779,16 +776,16 @@ void GetSharedObjectsTestImpl() path(testDynamicBackendsSubDir2 + "Arm_GpuAcc_backend.so") // Duplicates on different paths are allowed }; - BOOST_TEST(sharedObjects.size() == expectedSharedObjects.size()); - BOOST_TEST(fs::equivalent(path(sharedObjects[0]), expectedSharedObjects[0])); - BOOST_TEST(fs::equivalent(path(sharedObjects[1]), expectedSharedObjects[1])); - BOOST_TEST(fs::equivalent(path(sharedObjects[2]), expectedSharedObjects[2])); - BOOST_TEST(fs::equivalent(path(sharedObjects[3]), expectedSharedObjects[3])); - BOOST_TEST(fs::equivalent(path(sharedObjects[4]), expectedSharedObjects[4])); - BOOST_TEST(fs::equivalent(path(sharedObjects[5]), expectedSharedObjects[5])); - BOOST_TEST(fs::equivalent(path(sharedObjects[6]), expectedSharedObjects[6])); - BOOST_TEST(fs::equivalent(path(sharedObjects[7]), expectedSharedObjects[7])); - BOOST_TEST(fs::equivalent(path(sharedObjects[8]), expectedSharedObjects[8])); + CHECK(sharedObjects.size() == expectedSharedObjects.size()); + CHECK(fs::equivalent(path(sharedObjects[0]), expectedSharedObjects[0])); + CHECK(fs::equivalent(path(sharedObjects[1]), expectedSharedObjects[1])); + CHECK(fs::equivalent(path(sharedObjects[2]), expectedSharedObjects[2])); + CHECK(fs::equivalent(path(sharedObjects[3]), expectedSharedObjects[3])); + CHECK(fs::equivalent(path(sharedObjects[4]), expectedSharedObjects[4])); + CHECK(fs::equivalent(path(sharedObjects[5]), expectedSharedObjects[5])); + CHECK(fs::equivalent(path(sharedObjects[6]), expectedSharedObjects[6])); + CHECK(fs::equivalent(path(sharedObjects[7]), expectedSharedObjects[7])); + CHECK(fs::equivalent(path(sharedObjects[8]), expectedSharedObjects[8])); } void CreateDynamicBackendsTestImpl() @@ -824,10 +821,10 @@ void CreateDynamicBackendsTestImpl() std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6); std::string testDynamicBackendsSubDir7 = GetTestSubDirectory(g_TestDynamicBackendsSubDir7); std::string testDynamicBackendsSubDir8 = GetTestSubDirectory(g_TestDynamicBackendsSubDir8); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); - BOOST_CHECK(exists(testDynamicBackendsSubDir6)); - BOOST_CHECK(exists(testDynamicBackendsSubDir7)); - BOOST_CHECK(!exists(testDynamicBackendsSubDir8)); + CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir6)); + CHECK(exists(testDynamicBackendsSubDir7)); + CHECK(!exists(testDynamicBackendsSubDir8)); std::vector<std::string> backendPaths { @@ -839,19 +836,19 @@ void CreateDynamicBackendsTestImpl() std::vector<std::string> sharedObjects = DynamicBackendUtils::GetSharedObjects(backendPaths); std::vector<DynamicBackendPtr> dynamicBackends = DynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 5); - BOOST_TEST((dynamicBackends[0] != nullptr)); - BOOST_TEST((dynamicBackends[1] != nullptr)); - BOOST_TEST((dynamicBackends[2] != nullptr)); - BOOST_TEST((dynamicBackends[3] != nullptr)); - BOOST_TEST((dynamicBackends[4] != nullptr)); + CHECK(dynamicBackends.size() == 5); + CHECK((dynamicBackends[0] != nullptr)); + CHECK((dynamicBackends[1] != nullptr)); + CHECK((dynamicBackends[2] != nullptr)); + CHECK((dynamicBackends[3] != nullptr)); + CHECK((dynamicBackends[4] != nullptr)); // Duplicates are allowed here, they will be skipped later during the backend registration - BOOST_TEST((dynamicBackends[0]->GetBackendId() == "TestValid2")); - BOOST_TEST((dynamicBackends[1]->GetBackendId() == "TestValid3")); - BOOST_TEST((dynamicBackends[2]->GetBackendId() == "TestValid2")); // From duplicate Arm_TestValid2_backend.so - BOOST_TEST((dynamicBackends[3]->GetBackendId() == "TestValid2")); // From Arm_TestValid4_backend.so - BOOST_TEST((dynamicBackends[4]->GetBackendId() == "TestValid5")); + CHECK((dynamicBackends[0]->GetBackendId() == "TestValid2")); + CHECK((dynamicBackends[1]->GetBackendId() == "TestValid3")); + CHECK((dynamicBackends[2]->GetBackendId() == "TestValid2")); // From duplicate Arm_TestValid2_backend.so + CHECK((dynamicBackends[3]->GetBackendId() == "TestValid2")); // From Arm_TestValid4_backend.so + CHECK((dynamicBackends[4]->GetBackendId() == "TestValid5")); } void CreateDynamicBackendsNoPathsTestImpl() @@ -860,7 +857,7 @@ void CreateDynamicBackendsNoPathsTestImpl() std::vector<DynamicBackendPtr> dynamicBackends = DynamicBackendUtils::CreateDynamicBackends({}); - BOOST_TEST(dynamicBackends.empty()); + CHECK(dynamicBackends.empty()); } void CreateDynamicBackendsAllInvalidTestImpl() @@ -875,7 +872,7 @@ void CreateDynamicBackendsAllInvalidTestImpl() }; std::vector<DynamicBackendPtr> dynamicBackends = DynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.empty()); + CHECK(dynamicBackends.empty()); } void CreateDynamicBackendsMixedTypesTestImpl() @@ -885,8 +882,8 @@ void CreateDynamicBackendsMixedTypesTestImpl() std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5); std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); - BOOST_CHECK(exists(testDynamicBackendsSubDir6)); + CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir6)); std::string testValidBackend2FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend2FileName); @@ -894,9 +891,9 @@ void CreateDynamicBackendsMixedTypesTestImpl() g_TestInvalidBackend8FileName); std::string testInvalidBackend9FilePath = GetTestFilePath(testDynamicBackendsSubDir6, g_TestInvalidBackend9FileName); - BOOST_CHECK(exists(testValidBackend2FilePath)); - BOOST_CHECK(exists(testInvalidBackend8FilePath)); - BOOST_CHECK(exists(testInvalidBackend9FilePath)); + CHECK(exists(testValidBackend2FilePath)); + CHECK(exists(testInvalidBackend8FilePath)); + CHECK(exists(testInvalidBackend9FilePath)); std::vector<std::string> sharedObjects { @@ -907,9 +904,9 @@ void CreateDynamicBackendsMixedTypesTestImpl() }; std::vector<DynamicBackendPtr> dynamicBackends = DynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 1); - BOOST_TEST((dynamicBackends[0] != nullptr)); - BOOST_TEST((dynamicBackends[0]->GetBackendId() == "TestValid2")); + CHECK(dynamicBackends.size() == 1); + CHECK((dynamicBackends[0] != nullptr)); + CHECK((dynamicBackends[0]->GetBackendId() == "TestValid2")); } #if defined(ARMNNREF_ENABLED) @@ -922,42 +919,42 @@ void RegisterSingleDynamicBackendTestImpl() // Dummy registry used for testing BackendRegistry backendRegistry; - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir5)); std::string testValidBackend2FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend2FileName); - BOOST_CHECK(exists(testValidBackend2FilePath)); + CHECK(exists(testValidBackend2FilePath)); std::vector<std::string> sharedObjects{ testValidBackend2FilePath }; std::vector<DynamicBackendPtr> dynamicBackends = TestDynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 1); - BOOST_TEST((dynamicBackends[0] != nullptr)); + CHECK(dynamicBackends.size() == 1); + CHECK((dynamicBackends[0] != nullptr)); BackendId dynamicBackendId = dynamicBackends[0]->GetBackendId(); - BOOST_TEST((dynamicBackendId == "TestValid2")); + CHECK((dynamicBackendId == "TestValid2")); BackendVersion dynamicBackendVersion = dynamicBackends[0]->GetBackendVersion(); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); BackendIdSet registeredBackendIds = TestDynamicBackendUtils::RegisterDynamicBackendsImplTest(backendRegistry, dynamicBackends); - BOOST_TEST(backendRegistry.Size() == 1); - BOOST_TEST(registeredBackendIds.size() == 1); + CHECK(backendRegistry.Size() == 1); + CHECK(registeredBackendIds.size() == 1); BackendIdSet backendIds = backendRegistry.GetBackendIds(); - BOOST_TEST(backendIds.size() == 1); - BOOST_TEST((backendIds.find(dynamicBackendId) != backendIds.end())); - BOOST_TEST((registeredBackendIds.find(dynamicBackendId) != registeredBackendIds.end())); + CHECK(backendIds.size() == 1); + CHECK((backendIds.find(dynamicBackendId) != backendIds.end())); + CHECK((registeredBackendIds.find(dynamicBackendId) != registeredBackendIds.end())); auto dynamicBackendFactoryFunction = backendRegistry.GetFactory(dynamicBackendId); - BOOST_TEST((dynamicBackendFactoryFunction != nullptr)); + CHECK((dynamicBackendFactoryFunction != nullptr)); IBackendInternalUniquePtr dynamicBackend = dynamicBackendFactoryFunction(); - BOOST_TEST((dynamicBackend != nullptr)); - BOOST_TEST((dynamicBackend->GetId() == dynamicBackendId)); + CHECK((dynamicBackend != nullptr)); + CHECK((dynamicBackend->GetId() == dynamicBackendId)); } void RegisterMultipleDynamicBackendsTestImpl() @@ -969,15 +966,15 @@ void RegisterMultipleDynamicBackendsTestImpl() std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5); std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); - BOOST_CHECK(exists(testDynamicBackendsSubDir6)); + CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir6)); std::string testValidBackend2FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend2FileName); std::string testValidBackend3FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend3FileName); std::string testValidBackend5FilePath = GetTestFilePath(testDynamicBackendsSubDir6, g_TestValidBackend5FileName); - BOOST_CHECK(exists(testValidBackend2FilePath)); - BOOST_CHECK(exists(testValidBackend3FilePath)); - BOOST_CHECK(exists(testValidBackend5FilePath)); + CHECK(exists(testValidBackend2FilePath)); + CHECK(exists(testValidBackend3FilePath)); + CHECK(exists(testValidBackend5FilePath)); std::vector<std::string> sharedObjects { @@ -987,52 +984,52 @@ void RegisterMultipleDynamicBackendsTestImpl() }; std::vector<DynamicBackendPtr> dynamicBackends = TestDynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 3); - BOOST_TEST((dynamicBackends[0] != nullptr)); - BOOST_TEST((dynamicBackends[1] != nullptr)); - BOOST_TEST((dynamicBackends[2] != nullptr)); + CHECK(dynamicBackends.size() == 3); + CHECK((dynamicBackends[0] != nullptr)); + CHECK((dynamicBackends[1] != nullptr)); + CHECK((dynamicBackends[2] != nullptr)); BackendId dynamicBackendId1 = dynamicBackends[0]->GetBackendId(); BackendId dynamicBackendId2 = dynamicBackends[1]->GetBackendId(); BackendId dynamicBackendId3 = dynamicBackends[2]->GetBackendId(); - BOOST_TEST((dynamicBackendId1 == "TestValid2")); - BOOST_TEST((dynamicBackendId2 == "TestValid3")); - BOOST_TEST((dynamicBackendId3 == "TestValid5")); + CHECK((dynamicBackendId1 == "TestValid2")); + CHECK((dynamicBackendId2 == "TestValid3")); + CHECK((dynamicBackendId3 == "TestValid5")); for (size_t i = 0; i < dynamicBackends.size(); i++) { BackendVersion dynamicBackendVersion = dynamicBackends[i]->GetBackendVersion(); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); } // Dummy registry used for testing BackendRegistry backendRegistry; - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); BackendIdSet registeredBackendIds = TestDynamicBackendUtils::RegisterDynamicBackendsImplTest(backendRegistry, dynamicBackends); - BOOST_TEST(backendRegistry.Size() == 3); - BOOST_TEST(registeredBackendIds.size() == 3); + CHECK(backendRegistry.Size() == 3); + CHECK(registeredBackendIds.size() == 3); BackendIdSet backendIds = backendRegistry.GetBackendIds(); - BOOST_TEST(backendIds.size() == 3); - BOOST_TEST((backendIds.find(dynamicBackendId1) != backendIds.end())); - BOOST_TEST((backendIds.find(dynamicBackendId2) != backendIds.end())); - BOOST_TEST((backendIds.find(dynamicBackendId3) != backendIds.end())); - BOOST_TEST((registeredBackendIds.find(dynamicBackendId1) != registeredBackendIds.end())); - BOOST_TEST((registeredBackendIds.find(dynamicBackendId2) != registeredBackendIds.end())); - BOOST_TEST((registeredBackendIds.find(dynamicBackendId3) != registeredBackendIds.end())); + CHECK(backendIds.size() == 3); + CHECK((backendIds.find(dynamicBackendId1) != backendIds.end())); + CHECK((backendIds.find(dynamicBackendId2) != backendIds.end())); + CHECK((backendIds.find(dynamicBackendId3) != backendIds.end())); + CHECK((registeredBackendIds.find(dynamicBackendId1) != registeredBackendIds.end())); + CHECK((registeredBackendIds.find(dynamicBackendId2) != registeredBackendIds.end())); + CHECK((registeredBackendIds.find(dynamicBackendId3) != registeredBackendIds.end())); for (size_t i = 0; i < dynamicBackends.size(); i++) { BackendId dynamicBackendId = dynamicBackends[i]->GetBackendId(); auto dynamicBackendFactoryFunction = backendRegistry.GetFactory(dynamicBackendId); - BOOST_TEST((dynamicBackendFactoryFunction != nullptr)); + CHECK((dynamicBackendFactoryFunction != nullptr)); IBackendInternalUniquePtr dynamicBackend = dynamicBackendFactoryFunction(); - BOOST_TEST((dynamicBackend != nullptr)); - BOOST_TEST((dynamicBackend->GetId() == dynamicBackendId)); + CHECK((dynamicBackend != nullptr)); + CHECK((dynamicBackend->GetId() == dynamicBackendId)); } } @@ -1076,11 +1073,11 @@ void RegisterMixedDynamicBackendsTestImpl() std::string testDynamicBackendsSubDir7 = GetTestSubDirectory(g_TestDynamicBackendsSubDir7); std::string testDynamicBackendsSubDir8 = GetTestSubDirectory(g_TestDynamicBackendsSubDir8); std::string testDynamicBackendsSubDir9 = GetTestSubDirectory(g_TestDynamicBackendsSubDir9); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); - BOOST_CHECK(exists(testDynamicBackendsSubDir6)); - BOOST_CHECK(exists(testDynamicBackendsSubDir7)); - BOOST_CHECK(!exists(testDynamicBackendsSubDir8)); - BOOST_CHECK(exists(testDynamicBackendsSubDir9)); + CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir6)); + CHECK(exists(testDynamicBackendsSubDir7)); + CHECK(!exists(testDynamicBackendsSubDir8)); + CHECK(exists(testDynamicBackendsSubDir9)); std::string testValidBackend2FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend2FileName); std::string testValidBackend3FilePath = GetTestFilePath(testDynamicBackendsSubDir5, g_TestValidBackend3FileName); @@ -1095,15 +1092,15 @@ void RegisterMixedDynamicBackendsTestImpl() g_TestInvalidBackend10FileName); std::string testInvalidBackend11FilePath = GetTestFilePath(testDynamicBackendsSubDir9, g_TestInvalidBackend11FileName); - BOOST_CHECK(exists(testValidBackend2FilePath)); - BOOST_CHECK(exists(testValidBackend3FilePath)); - BOOST_CHECK(exists(testValidBackend2DupFilePath)); - BOOST_CHECK(exists(testValidBackend4FilePath)); - BOOST_CHECK(exists(testValidBackend5FilePath)); - BOOST_CHECK(exists(testInvalidBackend8FilePath)); - BOOST_CHECK(exists(testInvalidBackend9FilePath)); - BOOST_CHECK(exists(testInvalidBackend10FilePath)); - BOOST_CHECK(exists(testInvalidBackend11FilePath)); + CHECK(exists(testValidBackend2FilePath)); + CHECK(exists(testValidBackend3FilePath)); + CHECK(exists(testValidBackend2DupFilePath)); + CHECK(exists(testValidBackend4FilePath)); + CHECK(exists(testValidBackend5FilePath)); + CHECK(exists(testInvalidBackend8FilePath)); + CHECK(exists(testInvalidBackend9FilePath)); + CHECK(exists(testInvalidBackend10FilePath)); + CHECK(exists(testInvalidBackend11FilePath)); std::vector<std::string> sharedObjects { @@ -1120,14 +1117,14 @@ void RegisterMixedDynamicBackendsTestImpl() }; std::vector<DynamicBackendPtr> dynamicBackends = TestDynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 7); - BOOST_TEST((dynamicBackends[0] != nullptr)); - BOOST_TEST((dynamicBackends[1] != nullptr)); - BOOST_TEST((dynamicBackends[2] != nullptr)); - BOOST_TEST((dynamicBackends[3] != nullptr)); - BOOST_TEST((dynamicBackends[4] != nullptr)); - BOOST_TEST((dynamicBackends[5] != nullptr)); - BOOST_TEST((dynamicBackends[6] != nullptr)); + CHECK(dynamicBackends.size() == 7); + CHECK((dynamicBackends[0] != nullptr)); + CHECK((dynamicBackends[1] != nullptr)); + CHECK((dynamicBackends[2] != nullptr)); + CHECK((dynamicBackends[3] != nullptr)); + CHECK((dynamicBackends[4] != nullptr)); + CHECK((dynamicBackends[5] != nullptr)); + CHECK((dynamicBackends[6] != nullptr)); BackendId dynamicBackendId1 = dynamicBackends[0]->GetBackendId(); BackendId dynamicBackendId2 = dynamicBackends[1]->GetBackendId(); @@ -1136,23 +1133,23 @@ void RegisterMixedDynamicBackendsTestImpl() BackendId dynamicBackendId5 = dynamicBackends[4]->GetBackendId(); BackendId dynamicBackendId6 = dynamicBackends[5]->GetBackendId(); BackendId dynamicBackendId7 = dynamicBackends[6]->GetBackendId(); - BOOST_TEST((dynamicBackendId1 == "TestValid2")); - BOOST_TEST((dynamicBackendId2 == "TestValid3")); - BOOST_TEST((dynamicBackendId3 == "TestValid2")); // From duplicate Arm_TestValid2_backend.so - BOOST_TEST((dynamicBackendId4 == "TestValid2")); // From Arm_TestValid4_backend.so - BOOST_TEST((dynamicBackendId5 == "TestValid5")); - BOOST_TEST((dynamicBackendId6 == "")); - BOOST_TEST((dynamicBackendId7 == "Unknown")); + CHECK((dynamicBackendId1 == "TestValid2")); + CHECK((dynamicBackendId2 == "TestValid3")); + CHECK((dynamicBackendId3 == "TestValid2")); // From duplicate Arm_TestValid2_backend.so + CHECK((dynamicBackendId4 == "TestValid2")); // From Arm_TestValid4_backend.so + CHECK((dynamicBackendId5 == "TestValid5")); + CHECK((dynamicBackendId6 == "")); + CHECK((dynamicBackendId7 == "Unknown")); for (size_t i = 0; i < dynamicBackends.size(); i++) { BackendVersion dynamicBackendVersion = dynamicBackends[i]->GetBackendVersion(); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); } // Dummy registry used for testing BackendRegistry backendRegistry; - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); std::vector<BackendId> expectedRegisteredbackendIds { @@ -1163,22 +1160,22 @@ void RegisterMixedDynamicBackendsTestImpl() BackendIdSet registeredBackendIds = TestDynamicBackendUtils::RegisterDynamicBackendsImplTest(backendRegistry, dynamicBackends); - BOOST_TEST(backendRegistry.Size() == expectedRegisteredbackendIds.size()); - BOOST_TEST(registeredBackendIds.size() == expectedRegisteredbackendIds.size()); + CHECK(backendRegistry.Size() == expectedRegisteredbackendIds.size()); + CHECK(registeredBackendIds.size() == expectedRegisteredbackendIds.size()); BackendIdSet backendIds = backendRegistry.GetBackendIds(); - BOOST_TEST(backendIds.size() == expectedRegisteredbackendIds.size()); + CHECK(backendIds.size() == expectedRegisteredbackendIds.size()); for (const BackendId& expectedRegisteredbackendId : expectedRegisteredbackendIds) { - BOOST_TEST((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); - BOOST_TEST((registeredBackendIds.find(expectedRegisteredbackendId) != registeredBackendIds.end())); + CHECK((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); + CHECK((registeredBackendIds.find(expectedRegisteredbackendId) != registeredBackendIds.end())); auto dynamicBackendFactoryFunction = backendRegistry.GetFactory(expectedRegisteredbackendId); - BOOST_TEST((dynamicBackendFactoryFunction != nullptr)); + CHECK((dynamicBackendFactoryFunction != nullptr)); IBackendInternalUniquePtr dynamicBackend = dynamicBackendFactoryFunction(); - BOOST_TEST((dynamicBackend != nullptr)); - BOOST_TEST((dynamicBackend->GetId() == expectedRegisteredbackendId)); + CHECK((dynamicBackend != nullptr)); + CHECK((dynamicBackend->GetId() == expectedRegisteredbackendId)); } } #endif @@ -1200,14 +1197,14 @@ void RegisterMultipleInvalidDynamicBackendsTestImpl() // Arm_TestInvalid11_backend.so -> not valid (invalid backend id) std::string testDynamicBackendsSubDir9 = GetTestSubDirectory(g_TestDynamicBackendsSubDir9); - BOOST_CHECK(exists(testDynamicBackendsSubDir9)); + CHECK(exists(testDynamicBackendsSubDir9)); std::string testInvalidBackend10FilePath = GetTestFilePath(testDynamicBackendsSubDir9, g_TestInvalidBackend10FileName); std::string testInvalidBackend11FilePath = GetTestFilePath(testDynamicBackendsSubDir9, g_TestInvalidBackend11FileName); - BOOST_CHECK(exists(testInvalidBackend10FilePath)); - BOOST_CHECK(exists(testInvalidBackend11FilePath)); + CHECK(exists(testInvalidBackend10FilePath)); + CHECK(exists(testInvalidBackend11FilePath)); std::vector<std::string> sharedObjects { @@ -1217,30 +1214,30 @@ void RegisterMultipleInvalidDynamicBackendsTestImpl() }; std::vector<DynamicBackendPtr> dynamicBackends = TestDynamicBackendUtils::CreateDynamicBackends(sharedObjects); - BOOST_TEST(dynamicBackends.size() == 2); - BOOST_TEST((dynamicBackends[0] != nullptr)); - BOOST_TEST((dynamicBackends[1] != nullptr)); + CHECK(dynamicBackends.size() == 2); + CHECK((dynamicBackends[0] != nullptr)); + CHECK((dynamicBackends[1] != nullptr)); BackendId dynamicBackendId1 = dynamicBackends[0]->GetBackendId(); BackendId dynamicBackendId2 = dynamicBackends[1]->GetBackendId(); - BOOST_TEST((dynamicBackendId1 == "")); - BOOST_TEST((dynamicBackendId2 == "Unknown")); + CHECK((dynamicBackendId1 == "")); + CHECK((dynamicBackendId2 == "Unknown")); for (size_t i = 0; i < dynamicBackends.size(); i++) { BackendVersion dynamicBackendVersion = dynamicBackends[i]->GetBackendVersion(); - BOOST_TEST(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); + CHECK(TestDynamicBackendUtils::IsBackendCompatible(dynamicBackendVersion)); } // Dummy registry used for testing BackendRegistry backendRegistry; - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); // Check that no dynamic backend got registered BackendIdSet registeredBackendIds = TestDynamicBackendUtils::RegisterDynamicBackendsImplTest(backendRegistry, dynamicBackends); - BOOST_TEST(backendRegistry.Size() == 0); - BOOST_TEST(registeredBackendIds.empty()); + CHECK(backendRegistry.Size() == 0); + CHECK(registeredBackendIds.empty()); } #if !defined(ARMNN_DYNAMIC_BACKEND_ENABLED) @@ -1253,16 +1250,16 @@ void RuntimeEmptyTestImpl() TestBackendRegistry testBackendRegistry; const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); IRuntime::CreationOptions creationOptions; IRuntimePtr runtime = IRuntime::Create(creationOptions); const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.empty()); + CHECK(supportedBackendIds.empty()); - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); } #endif @@ -1277,7 +1274,7 @@ void RuntimeDynamicBackendsTestImpl() // This directory contains valid and invalid backends std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5); - BOOST_CHECK(exists(testDynamicBackendsSubDir5)); + CHECK(exists(testDynamicBackendsSubDir5)); // Using the path override in CreationOptions to load some test dynamic backends IRuntime::CreationOptions creationOptions; @@ -1291,20 +1288,20 @@ void RuntimeDynamicBackendsTestImpl() }; const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == expectedRegisteredbackendIds.size()); + CHECK(backendRegistry.Size() == expectedRegisteredbackendIds.size()); BackendIdSet backendIds = backendRegistry.GetBackendIds(); for (const BackendId& expectedRegisteredbackendId : expectedRegisteredbackendIds) { - BOOST_TEST((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); + CHECK((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); } const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.size() == expectedRegisteredbackendIds.size()); + CHECK(supportedBackendIds.size() == expectedRegisteredbackendIds.size()); for (const BackendId& expectedRegisteredbackendId : expectedRegisteredbackendIds) { - BOOST_TEST((supportedBackendIds.find(expectedRegisteredbackendId) != supportedBackendIds.end())); + CHECK((supportedBackendIds.find(expectedRegisteredbackendId) != supportedBackendIds.end())); } } @@ -1318,7 +1315,7 @@ void RuntimeDuplicateDynamicBackendsTestImpl() // This directory contains valid, invalid and duplicate backends std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6); - BOOST_CHECK(exists(testDynamicBackendsSubDir6)); + CHECK(exists(testDynamicBackendsSubDir6)); // Using the path override in CreationOptions to load some test dynamic backends IRuntime::CreationOptions creationOptions; @@ -1332,20 +1329,20 @@ void RuntimeDuplicateDynamicBackendsTestImpl() }; const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == expectedRegisteredbackendIds.size()); + CHECK(backendRegistry.Size() == expectedRegisteredbackendIds.size()); BackendIdSet backendIds = backendRegistry.GetBackendIds(); for (const BackendId& expectedRegisteredbackendId : expectedRegisteredbackendIds) { - BOOST_TEST((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); + CHECK((backendIds.find(expectedRegisteredbackendId) != backendIds.end())); } const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.size() == expectedRegisteredbackendIds.size()); + CHECK(supportedBackendIds.size() == expectedRegisteredbackendIds.size()); for (const BackendId& expectedRegisteredbackendId : expectedRegisteredbackendIds) { - BOOST_TEST((supportedBackendIds.find(expectedRegisteredbackendId) != supportedBackendIds.end())); + CHECK((supportedBackendIds.find(expectedRegisteredbackendId) != supportedBackendIds.end())); } } @@ -1359,7 +1356,7 @@ void RuntimeInvalidDynamicBackendsTestImpl() // This directory contains only invalid backends std::string testDynamicBackendsSubDir9 = GetTestSubDirectory(g_TestDynamicBackendsSubDir9); - BOOST_CHECK(exists(testDynamicBackendsSubDir9)); + CHECK(exists(testDynamicBackendsSubDir9)); // Using the path override in CreationOptions to load some test dynamic backends IRuntime::CreationOptions creationOptions; @@ -1367,11 +1364,11 @@ void RuntimeInvalidDynamicBackendsTestImpl() IRuntimePtr runtime = IRuntime::Create(creationOptions); const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.empty()); + CHECK(supportedBackendIds.empty()); } void RuntimeInvalidOverridePathTestImpl() @@ -1387,11 +1384,11 @@ void RuntimeInvalidOverridePathTestImpl() IRuntimePtr runtime = IRuntime::Create(creationOptions); const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == 0); + CHECK(backendRegistry.Size() == 0); const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.empty()); + CHECK(supportedBackendIds.empty()); } #if defined(ARMNNREF_ENABLED) @@ -1410,12 +1407,12 @@ void CreateReferenceDynamicBackendTestImpl() std::string dynamicBackendsBaseDir = GetDynamicBackendsBasePath(); std::string referenceDynamicBackendSubDir = GetTestSubDirectory(dynamicBackendsBaseDir, g_ReferenceDynamicBackendSubDir); - BOOST_CHECK(exists(referenceDynamicBackendSubDir)); + CHECK(exists(referenceDynamicBackendSubDir)); // Check that the reference dynamic backend file exists std::string referenceBackendFilePath = GetTestFilePath(referenceDynamicBackendSubDir, g_ReferenceBackendFileName); - BOOST_CHECK(exists(referenceBackendFilePath)); + CHECK(exists(referenceBackendFilePath)); // Using the path override in CreationOptions to load the reference dynamic backend IRuntime::CreationOptions creationOptions; @@ -1423,28 +1420,28 @@ void CreateReferenceDynamicBackendTestImpl() IRuntimePtr runtime = IRuntime::Create(creationOptions); const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() == 1); + CHECK(backendRegistry.Size() == 1); BackendIdSet backendIds = backendRegistry.GetBackendIds(); - BOOST_TEST((backendIds.find("CpuRef") != backendIds.end())); + CHECK((backendIds.find("CpuRef") != backendIds.end())); const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.size() == 1); - BOOST_TEST((supportedBackendIds.find("CpuRef") != supportedBackendIds.end())); + CHECK(supportedBackendIds.size() == 1); + CHECK((supportedBackendIds.find("CpuRef") != supportedBackendIds.end())); // Get the factory function auto referenceDynamicBackendFactoryFunction = backendRegistry.GetFactory("CpuRef"); - BOOST_TEST((referenceDynamicBackendFactoryFunction != nullptr)); + CHECK((referenceDynamicBackendFactoryFunction != nullptr)); // Use the factory function to create an instance of the reference backend IBackendInternalUniquePtr referenceDynamicBackend = referenceDynamicBackendFactoryFunction(); - BOOST_TEST((referenceDynamicBackend != nullptr)); - BOOST_TEST((referenceDynamicBackend->GetId() == "CpuRef")); + CHECK((referenceDynamicBackend != nullptr)); + CHECK((referenceDynamicBackend->GetId() == "CpuRef")); // Test the backend instance by querying the layer support IBackendInternal::ILayerSupportSharedPtr referenceLayerSupport = referenceDynamicBackend->GetLayerSupport(); - BOOST_TEST((referenceLayerSupport != nullptr)); + CHECK((referenceLayerSupport != nullptr)); TensorShape inputShape { 1, 16, 16, 16 }; TensorShape outputShape{ 1, 16, 16, 16 }; @@ -1459,11 +1456,11 @@ void CreateReferenceDynamicBackendTestImpl() convolution2dDescriptor, weightInfo, EmptyOptional()); - BOOST_TEST(referenceConvolution2dSupported); + CHECK(referenceConvolution2dSupported); // Test the backend instance by creating a workload IBackendInternal::IWorkloadFactoryPtr referenceWorkloadFactory = referenceDynamicBackend->CreateWorkloadFactory(); - BOOST_TEST((referenceWorkloadFactory != nullptr)); + CHECK((referenceWorkloadFactory != nullptr)); // Create dummy settings for the workload Convolution2dQueueDescriptor convolution2dQueueDescriptor; @@ -1478,8 +1475,8 @@ void CreateReferenceDynamicBackendTestImpl() // Create a convolution workload with the dummy settings auto workload = referenceWorkloadFactory->CreateConvolution2d(convolution2dQueueDescriptor, workloadInfo); - BOOST_TEST((workload != nullptr)); - BOOST_TEST(workload.get() == PolymorphicDowncast<RefConvolution2dWorkload*>(workload.get())); + CHECK((workload != nullptr)); + CHECK(workload.get() == PolymorphicDowncast<RefConvolution2dWorkload*>(workload.get())); } #endif @@ -1498,7 +1495,7 @@ void CheckSampleDynamicBackendLoaded() "Ensure a DYNAMIC_BACKEND_PATHS was set at compile time to the location of " "libArm_SampleDynamic_backend.so. " "To disable this test recompile with: -DSAMPLE_DYNAMIC_BACKEND_ENABLED=0"; - BOOST_FAIL(message); + FAIL(message); } } @@ -1509,25 +1506,25 @@ void CreateSampleDynamicBackendTestImpl() IRuntime::CreationOptions creationOptions; IRuntimePtr runtime = IRuntime::Create(creationOptions); const BackendRegistry& backendRegistry = BackendRegistryInstance(); - BOOST_TEST(backendRegistry.Size() >= 1); + CHECK(backendRegistry.Size() >= 1); CheckSampleDynamicBackendLoaded(); const DeviceSpec& deviceSpec = *PolymorphicDowncast<const DeviceSpec*>(&runtime->GetDeviceSpec()); BackendIdSet supportedBackendIds = deviceSpec.GetSupportedBackends(); - BOOST_TEST(supportedBackendIds.size()>= 1); - BOOST_TEST((supportedBackendIds.find("SampleDynamic") != supportedBackendIds.end())); + CHECK(supportedBackendIds.size()>= 1); + CHECK((supportedBackendIds.find("SampleDynamic") != supportedBackendIds.end())); // Get the factory function auto sampleDynamicBackendFactoryFunction = backendRegistry.GetFactory("SampleDynamic"); - BOOST_TEST((sampleDynamicBackendFactoryFunction != nullptr)); + CHECK((sampleDynamicBackendFactoryFunction != nullptr)); // Use the factory function to create an instance of the dynamic backend IBackendInternalUniquePtr sampleDynamicBackend = sampleDynamicBackendFactoryFunction(); - BOOST_TEST((sampleDynamicBackend != nullptr)); - BOOST_TEST((sampleDynamicBackend->GetId() == "SampleDynamic")); + CHECK((sampleDynamicBackend != nullptr)); + CHECK((sampleDynamicBackend->GetId() == "SampleDynamic")); // Test the backend instance by querying the layer support IBackendInternal::ILayerSupportSharedPtr sampleLayerSupport = sampleDynamicBackend->GetLayerSupport(); - BOOST_TEST((sampleLayerSupport != nullptr)); + CHECK((sampleLayerSupport != nullptr)); TensorShape inputShape { 1, 16, 16, 16 }; TensorShape outputShape{ 1, 16, 16, 16 }; @@ -1542,11 +1539,11 @@ void CreateSampleDynamicBackendTestImpl() convolution2dDescriptor, weightInfo, EmptyOptional()); - BOOST_TEST(!sampleConvolution2dSupported); + CHECK(!sampleConvolution2dSupported); // Test the backend instance by creating a workload IBackendInternal::IWorkloadFactoryPtr sampleWorkloadFactory = sampleDynamicBackend->CreateWorkloadFactory(); - BOOST_TEST((sampleWorkloadFactory != nullptr)); + CHECK((sampleWorkloadFactory != nullptr)); // Create dummy settings for the workload AdditionQueueDescriptor additionQueueDescriptor; @@ -1558,7 +1555,7 @@ void CreateSampleDynamicBackendTestImpl() // Create a addition workload auto workload = sampleWorkloadFactory->CreateAddition(additionQueueDescriptor, workloadInfo); - BOOST_TEST((workload != nullptr)); + CHECK((workload != nullptr)); } void SampleDynamicBackendEndToEndTestImpl() @@ -1611,6 +1608,6 @@ void SampleDynamicBackendEndToEndTestImpl() runtime->EnqueueWorkload(netId, inputTensors, outputTensors); // Checks the results. - BOOST_TEST(outputData == expectedOutputData); + CHECK(outputData == expectedOutputData); } #endif diff --git a/src/backends/backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp index 5fedaa2171..f958613d02 100644 --- a/src/backends/backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp @@ -12,7 +12,7 @@ #include <armnn/utility/NumericCast.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -61,7 +61,7 @@ void ElementwiseUnarySimpleEndToEnd(const std::vector<BackendId>& backends, // Builds up the structure of the network INetworkPtr net = CreateElementwiseUnaryNetwork<ArmnnInType>(inputShape, outputShape, operation, qScale, qOffset); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); const std::vector<float> input({ 1, -1, 1, 1, 5, -5, 5, 5, -3, 3, 3, 3, 4, 4, -4, 4 }); diff --git a/src/backends/backendsCommon/test/EndToEndTestImpl.hpp b/src/backends/backendsCommon/test/EndToEndTestImpl.hpp index a5fe8c6a62..2d268f8ea1 100644 --- a/src/backends/backendsCommon/test/EndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/EndToEndTestImpl.hpp @@ -14,7 +14,7 @@ #include <QuantizeHelper.hpp> #include <ResolveType.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -169,7 +169,7 @@ void EndToEndLayerTestImpl(INetworkPtr network, std::vector<TOutput> out = outputStorage.at(it.first); for (unsigned int i = 0; i < out.size(); ++i) { - BOOST_CHECK_MESSAGE(Compare<ArmnnOType>(it.second[i], out[i], tolerance) == true, + CHECK_MESSAGE(Compare<ArmnnOType>(it.second[i], out[i], tolerance) == true, "Actual output: " << out[i] << ". Expected output:" << it.second[i]); } @@ -203,7 +203,7 @@ inline void ImportNonAlignedInputPointerTest(std::vector<BackendId> backends) // Optimize the network IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_CHECK(optNet); + CHECK(optNet); // Loads it into the runtime. NetworkId netId; @@ -238,7 +238,7 @@ inline void ImportNonAlignedInputPointerTest(std::vector<BackendId> backends) runtime->GetProfiler(netId)->EnableProfiling(true); // Do the inference and expect it to fail with a ImportMemoryException - BOOST_CHECK_THROW(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryImportException); + CHECK_THROWS_AS(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryImportException); } inline void ExportNonAlignedOutputPointerTest(std::vector<BackendId> backends) @@ -268,7 +268,7 @@ inline void ExportNonAlignedOutputPointerTest(std::vector<BackendId> backends) // Optimize the network IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_CHECK(optNet); + CHECK(optNet); // Loads it into the runtime. NetworkId netId; @@ -304,11 +304,11 @@ inline void ExportNonAlignedOutputPointerTest(std::vector<BackendId> backends) if (backends[0] == Compute::CpuAcc) { // For CpuAcc the NeonTensorHandle will throw its own exception on misaligned memory - BOOST_CHECK_THROW(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryImportException); + CHECK_THROWS_AS(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryImportException); } else { - BOOST_CHECK_THROW(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryExportException); + CHECK_THROWS_AS(runtime->EnqueueWorkload(netId, inputTensors, outputTensors), MemoryExportException); } } @@ -339,7 +339,7 @@ inline void ImportAlignedPointerTest(std::vector<BackendId> backends) // Optimize the network IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_CHECK(optNet); + CHECK(optNet); // Loads it into the runtime. NetworkId netId; @@ -383,18 +383,18 @@ inline void ImportAlignedPointerTest(std::vector<BackendId> backends) // Contains ActivationWorkload std::size_t found = dump.find("ActivationWorkload"); - BOOST_TEST(found != std::string::npos); + CHECK(found != std::string::npos); // Contains SyncMemGeneric found = dump.find("SyncMemGeneric"); - BOOST_TEST(found != std::string::npos); + CHECK(found != std::string::npos); // Does not contain CopyMemGeneric found = dump.find("CopyMemGeneric"); - BOOST_TEST(found == std::string::npos); + CHECK(found == std::string::npos); // Check output is as expected - BOOST_TEST(outputData == expectedOutput); + CHECK(outputData == expectedOutput); } inline void ImportOnlyWorkload(std::vector<BackendId> backends) @@ -424,17 +424,17 @@ inline void ImportOnlyWorkload(std::vector<BackendId> backends) // optimize the network IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_TEST_CHECKPOINT("Load Network"); + INFO("Load Network"); // Load it into the runtime. It should pass. NetworkId netId; std::string ignoredErrorMessage; INetworkProperties networkProperties(false, MemorySource::Malloc, MemorySource::Undefined); - BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) + CHECK(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) == Status::Success); - BOOST_TEST_CHECKPOINT("Generate Data"); + INFO("Generate Data"); // Creates structures for input & output std::vector<float> inputData { @@ -448,7 +448,7 @@ inline void ImportOnlyWorkload(std::vector<BackendId> backends) 1.0f, 4.0f, 9.0f, 16.0f }; - BOOST_TEST_CHECKPOINT("Create Network"); + INFO("Create Network"); InputTensors inputTensors { {0,armnn::ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}, @@ -458,15 +458,14 @@ inline void ImportOnlyWorkload(std::vector<BackendId> backends) {0,armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} }; - BOOST_TEST_CHECKPOINT("Get Profiler"); - + INFO("Get Profiler"); runtime->GetProfiler(netId)->EnableProfiling(true); - BOOST_TEST_CHECKPOINT("Run Inference"); + INFO("Run Inference"); // Do the inference runtime->EnqueueWorkload(netId, inputTensors, outputTensors); - BOOST_TEST_CHECKPOINT("Print Profiler"); + INFO("Print Profiler"); // Retrieve the Profiler.Print() output to get the workload execution ProfilerManager& profilerManager = armnn::ProfilerManager::GetInstance(); std::stringstream ss; @@ -474,17 +473,17 @@ inline void ImportOnlyWorkload(std::vector<BackendId> backends) std::string dump = ss.str(); // Check there are no SyncMemGeneric workloads as we didn't export - BOOST_TEST_CHECKPOINT("Find SyncMemGeneric"); + INFO("Find SyncMemGeneric"); int count = SubStringCounter(dump, "SyncMemGeneric"); - BOOST_TEST(count == 0); + CHECK(count == 0); // Should only be 1 CopyMemGeneric for the output as we imported - BOOST_TEST_CHECKPOINT("Find CopyMemGeneric"); + INFO("Find CopyMemGeneric"); count = SubStringCounter(dump, "CopyMemGeneric"); - BOOST_TEST(count == 1); + CHECK(count == 1); // Check the output is correct - BOOST_CHECK_EQUAL_COLLECTIONS(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end()); + CHECK(std::equal(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end())); } inline void ExportOnlyWorkload(std::vector<BackendId> backends) @@ -514,15 +513,15 @@ inline void ExportOnlyWorkload(std::vector<BackendId> backends) // optimize the network IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_TEST_CHECKPOINT("Load Network"); + INFO("Load Network"); // Load it into the runtime. It should pass. NetworkId netId; std::string ignoredErrorMessage; INetworkProperties networkProperties(false, MemorySource::Undefined, MemorySource::Malloc); - BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) + CHECK(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) == Status::Success); - BOOST_TEST_CHECKPOINT("Generate Data"); + INFO("Generate Data"); // Creates structures for input & output std::vector<float> inputData { @@ -536,7 +535,7 @@ inline void ExportOnlyWorkload(std::vector<BackendId> backends) 1.0f, 4.0f, 9.0f, 16.0f }; - BOOST_TEST_CHECKPOINT("Create Network"); + INFO("Create Network"); InputTensors inputTensors { {0,armnn::ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}, @@ -546,15 +545,14 @@ inline void ExportOnlyWorkload(std::vector<BackendId> backends) {0,armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} }; - BOOST_TEST_CHECKPOINT("Get Profiler"); - + INFO("Get Profiler"); runtime->GetProfiler(netId)->EnableProfiling(true); - BOOST_TEST_CHECKPOINT("Run Inference"); + INFO("Run Inference"); // Do the inference runtime->EnqueueWorkload(netId, inputTensors, outputTensors); - BOOST_TEST_CHECKPOINT("Print Profiler"); + INFO("Print Profiler"); // Retrieve the Profiler.Print() output to get the workload execution ProfilerManager& profilerManager = armnn::ProfilerManager::GetInstance(); std::stringstream ss; @@ -562,17 +560,17 @@ inline void ExportOnlyWorkload(std::vector<BackendId> backends) std::string dump = ss.str(); // Check there is a SyncMemGeneric workload as we exported - BOOST_TEST_CHECKPOINT("Find SyncMemGeneric"); + INFO("Find SyncMemGeneric"); int count = SubStringCounter(dump, "SyncMemGeneric"); - BOOST_TEST(count == 1); + CHECK(count == 1); // Should be 1 CopyMemGeneric for the output as we did not import - BOOST_TEST_CHECKPOINT("Find CopyMemGeneric"); + INFO("Find CopyMemGeneric"); count = SubStringCounter(dump, "CopyMemGeneric"); - BOOST_TEST(count == 1); + CHECK(count == 1); // Check the output is correct - BOOST_CHECK_EQUAL_COLLECTIONS(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end()); + CHECK(std::equal(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end())); } inline void ImportAndExportWorkload(std::vector<BackendId> backends) @@ -601,17 +599,17 @@ inline void ImportAndExportWorkload(std::vector<BackendId> backends) IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_TEST_CHECKPOINT("Load Network"); + INFO("Load Network"); // Load it into the runtime. It should pass. NetworkId netId; std::string ignoredErrorMessage; INetworkProperties networkProperties(false, MemorySource::Malloc, MemorySource::Malloc); - BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) + CHECK(runtime->LoadNetwork(netId, std::move(optNet),ignoredErrorMessage, networkProperties) == Status::Success); - BOOST_TEST_CHECKPOINT("Generate Data"); + INFO("Generate Data"); // Creates structures for input & output std::vector<float> inputData { @@ -625,7 +623,7 @@ inline void ImportAndExportWorkload(std::vector<BackendId> backends) 1.0f, 4.0f, 9.0f, 16.0f }; - BOOST_TEST_CHECKPOINT("Create Network"); + INFO("Create Network"); InputTensors inputTensors { {0,armnn::ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}, @@ -635,15 +633,14 @@ inline void ImportAndExportWorkload(std::vector<BackendId> backends) {0,armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} }; - BOOST_TEST_CHECKPOINT("Get Profiler"); - + INFO("Get Profiler"); runtime->GetProfiler(netId)->EnableProfiling(true); - BOOST_TEST_CHECKPOINT("Run Inference"); + INFO("Run Inference"); // Do the inference runtime->EnqueueWorkload(netId, inputTensors, outputTensors); - BOOST_TEST_CHECKPOINT("Print Profiler"); + INFO("Print Profiler"); // Retrieve the Profiler.Print() output to get the workload execution ProfilerManager& profilerManager = armnn::ProfilerManager::GetInstance(); std::stringstream ss; @@ -651,17 +648,17 @@ inline void ImportAndExportWorkload(std::vector<BackendId> backends) std::string dump = ss.str(); // Check there is a SyncMemGeneric workload as we exported - BOOST_TEST_CHECKPOINT("Find SyncMemGeneric"); + INFO("Find SyncMemGeneric"); int count = SubStringCounter(dump, "SyncMemGeneric"); - BOOST_TEST(count == 1); + CHECK(count == 1); // Shouldn't be any CopyMemGeneric workloads - BOOST_TEST_CHECKPOINT("Find CopyMemGeneric"); + INFO("Find CopyMemGeneric"); count = SubStringCounter(dump, "CopyMemGeneric"); - BOOST_TEST(count == 0); + CHECK(count == 0); // Check the output is correct - BOOST_CHECK_EQUAL_COLLECTIONS(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end()); + CHECK(std::equal(outputData.begin(), outputData.end(), expectedOutput.begin(), expectedOutput.end())); } inline void ExportOutputWithSeveralOutputSlotConnectionsTest(std::vector<BackendId> backends) @@ -753,19 +750,19 @@ inline void ExportOutputWithSeveralOutputSlotConnectionsTest(std::vector<Backend found = dump.find("ClActivationWorkload"); } - BOOST_TEST(found != std::string::npos); + CHECK(found != std::string::npos); // No contains SyncMemGeneric found = dump.find("SyncMemGeneric"); - BOOST_TEST(found == std::string::npos); + CHECK(found == std::string::npos); // Contains CopyMemGeneric found = dump.find("CopyMemGeneric"); - BOOST_TEST(found != std::string::npos); + CHECK(found != std::string::npos); // Check that the outputs are correct - BOOST_CHECK_EQUAL_COLLECTIONS(outputData0.begin(), outputData0.end(), - expectedOutput.begin(), expectedOutput.end()); - BOOST_CHECK_EQUAL_COLLECTIONS(outputData1.begin(), outputData1.end(), - expectedOutput.begin(), expectedOutput.end()); + CHECK(std::equal(outputData0.begin(), outputData0.end(), + expectedOutput.begin(), expectedOutput.end())); + CHECK(std::equal(outputData1.begin(), outputData1.end(), + expectedOutput.begin(), expectedOutput.end())); } inline void StridedSliceInvalidSliceEndToEndTest(std::vector<BackendId> backends) @@ -801,7 +798,7 @@ inline void StridedSliceInvalidSliceEndToEndTest(std::vector<BackendId> backends stridedSlice->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 3 }, DataType::Float32)); // Attempt to optimize the network and check that the correct exception is thrown - BOOST_CHECK_THROW(Optimize(*net, backends, runtime->GetDeviceSpec()), armnn::LayerValidationException); + CHECK_THROWS_AS(Optimize(*net, backends, runtime->GetDeviceSpec()), armnn::LayerValidationException); } } // anonymous namespace diff --git a/src/backends/backendsCommon/test/FillEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/FillEndToEndTestImpl.hpp index 5d7601b14b..2a4ccb6898 100644 --- a/src/backends/backendsCommon/test/FillEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/FillEndToEndTestImpl.hpp @@ -12,6 +12,8 @@ #include <ResolveType.hpp> +#include <doctest/doctest.h> + namespace { @@ -55,7 +57,7 @@ void FillEndToEnd(const std::vector<armnn::BackendId>& backends) armnn::INetworkPtr network = CreateFillNetwork(inputInfo, outputInfo, descriptor); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(network); std::map<int, std::vector<int32_t>> inputTensorData = {{ 0, inputData }}; std::map<int, std::vector<T>> expectedOutputTensorData = {{ 0, expectedOutputData }}; diff --git a/src/backends/backendsCommon/test/FullyConnectedEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/FullyConnectedEndToEndTestImpl.hpp index 5a618c32e1..923d6f3641 100644 --- a/src/backends/backendsCommon/test/FullyConnectedEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/FullyConnectedEndToEndTestImpl.hpp @@ -12,7 +12,7 @@ #include <armnn/utility/NumericCast.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -83,7 +83,7 @@ void FullyConnectedWithDynamicWeightsEndToEnd(const std::vector<armnn::BackendId weightsTensorInfo, descriptor); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(network); std::map<int, std::vector<T>> inputTensorData = {{ 0, inputData }, {1, weightsData}}; std::map<int, std::vector<T>> expectedOutputTensorData = {{ 0, expectedOutputData }}; diff --git a/src/backends/backendsCommon/test/GatherEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/GatherEndToEndTestImpl.hpp index 82f94512c3..431ef31437 100644 --- a/src/backends/backendsCommon/test/GatherEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/GatherEndToEndTestImpl.hpp @@ -10,6 +10,8 @@ #include <armnn/INetwork.hpp> #include <ResolveType.hpp> +#include <doctest/doctest.h> + namespace{ armnn::INetworkPtr CreateGatherNetwork(const armnn::TensorInfo& paramsInfo, @@ -59,7 +61,7 @@ void GatherEndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network armnn::INetworkPtr net = CreateGatherNetwork(paramsInfo, indicesInfo, outputInfo, indicesData); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); std::map<int, std::vector<T>> inputTensorData = {{ 0, paramsData }}; std::map<int, std::vector<T>> expectedOutputData = {{ 0, expectedOutput }}; @@ -115,8 +117,6 @@ void GatherMultiDimEndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network armnn::INetworkPtr net = CreateGatherNetwork(paramsInfo, indicesInfo, outputInfo, indicesData); - BOOST_TEST_CHECKPOINT("create a network"); - std::map<int, std::vector<T>> inputTensorData = {{ 0, paramsData }}; std::map<int, std::vector<T>> expectedOutputData = {{ 0, expectedOutput }}; diff --git a/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp index a3dd88c893..d758137b3b 100644 --- a/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp @@ -16,7 +16,7 @@ #include <test/TestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> namespace { @@ -82,7 +82,7 @@ void InstanceNormalizationEndToEnd(const std::vector<armnn::BackendId>& backends beta, eps); - BOOST_TEST_CHECKPOINT("Create a network"); + CHECK(net); std::map<int, std::vector<float>> inputTensorData = { { 0, inputData } }; std::map<int, std::vector<float>> expectedOutputTensorData = { { 0, expectedOutputData } }; diff --git a/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp b/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp index 4240bb1061..5a05ee1d85 100644 --- a/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp +++ b/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp @@ -12,6 +12,8 @@ #include <armnn/utility/IgnoreUnused.hpp> +#include <doctest/doctest.h> + namespace { armnn::Graph dummyGraph; @@ -756,7 +758,7 @@ bool IsLayerSupportedTest(FactoryType *factory, Tag<Type>) try { bool retVal = LayerPolicy::MakeDummyWorkload(factory, numIn, numOut).get() != nullptr; - BOOST_CHECK_MESSAGE(retVal, layerName << errorMsg); + CHECK_MESSAGE(retVal, layerName << errorMsg); return retVal; } catch(const armnn::InvalidArgumentException& e) @@ -768,13 +770,13 @@ bool IsLayerSupportedTest(FactoryType *factory, Tag<Type>) catch(const std::exception& e) { errorMsg = e.what(); - BOOST_TEST_ERROR(layerName << ": " << errorMsg); + FAIL(layerName << ": " << errorMsg); return false; } catch(...) { errorMsg = "Unexpected error while testing support for "; - BOOST_TEST_ERROR(errorMsg << layerName); + FAIL(errorMsg << layerName); return false; } } @@ -784,7 +786,7 @@ bool IsLayerSupportedTest(FactoryType *factory, Tag<Type>) try { bool retVal = LayerPolicy::MakeDummyWorkload(factory, numIn, numOut).get() == nullptr; - BOOST_CHECK_MESSAGE(retVal, layerName << errorMsg); + CHECK_MESSAGE(retVal, layerName << errorMsg); return retVal; } // These two exceptions are ok: For workloads that are partially supported, attempting to instantiate them @@ -803,13 +805,13 @@ bool IsLayerSupportedTest(FactoryType *factory, Tag<Type>) catch(const std::exception& e) { errorMsg = e.what(); - BOOST_TEST_ERROR(layerName << ": " << errorMsg); + FAIL(layerName << ": " << errorMsg); return false; } catch(...) { errorMsg = "Unexpected error while testing support for "; - BOOST_TEST_ERROR(errorMsg << layerName); + FAIL(errorMsg << layerName); return false; } } @@ -871,7 +873,7 @@ bool TestLayerTypeMatches() std::stringstream ss; ss << LayerPolicy::NameStr << " layer type mismatches expected layer type value."; bool v = Type == layer.m_Layer->GetType(); - BOOST_CHECK_MESSAGE(v, ss.str()); + CHECK_MESSAGE(v, ss.str()); return v; } diff --git a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp index a2206f714c..92c8e14e4b 100644 --- a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp +++ b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp @@ -12,11 +12,12 @@ #include <armnn/IRuntime.hpp> #include <armnn/INetwork.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <sstream> #include <stack> #include <string> +#include <algorithm> inline bool AreMatchingPair(const char opening, const char closing) { @@ -67,7 +68,7 @@ std::vector<double> ExtractMeasurements(const std::string& exp) } catch (std::invalid_argument const&) { - BOOST_FAIL("Could not convert measurements to double: " + numberString); + FAIL("Could not convert measurements to double: " + numberString); } numberString.clear(); @@ -82,7 +83,7 @@ std::vector<double> ExtractMeasurements(const std::string& exp) } catch (std::invalid_argument const&) { - BOOST_FAIL("Could not convert measurements to double: " + numberString); + FAIL("Could not convert measurements to double: " + numberString); } numberString.clear(); } @@ -120,7 +121,7 @@ std::string GetSoftmaxProfilerJson(const std::vector<armnn::BackendId>& backends { using namespace armnn; - BOOST_CHECK(!backends.empty()); + CHECK(!backends.empty()); ProfilerManager& profilerManager = armnn::ProfilerManager::GetInstance(); @@ -160,12 +161,12 @@ std::string GetSoftmaxProfilerJson(const std::vector<armnn::BackendId>& backends IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); if(!optNet) { - BOOST_FAIL("Error occurred during Optimization, Optimize() returned nullptr."); + FAIL("Error occurred during Optimization, Optimize() returned nullptr."); } // load it into the runtime NetworkId netId; auto error = runtime->LoadNetwork(netId, std::move(optNet)); - BOOST_TEST(error == Status::Success); + CHECK(error == Status::Success); // create structures for input & output std::vector<uint8_t> inputData @@ -202,7 +203,7 @@ inline void ValidateProfilerJson(std::string& result) { // ensure all measurements are greater than zero std::vector<double> measurementsVector = ExtractMeasurements(result); - BOOST_CHECK(!measurementsVector.empty()); + CHECK(!measurementsVector.empty()); // check sections contain raw and unit tags // first ensure Parenthesis are balanced @@ -219,12 +220,12 @@ inline void ValidateProfilerJson(std::string& result) sectionVector.erase(sectionVector.begin() + static_cast<int>(i)); } } - BOOST_CHECK(!sectionVector.empty()); + CHECK(!sectionVector.empty()); - BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), + CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), [](std::string i) { return (i.find("\"raw\":") != std::string::npos); })); - BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), + CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), [](std::string i) { return (i.find("\"unit\":") != std::string::npos); })); } @@ -235,11 +236,11 @@ inline void ValidateProfilerJson(std::string& result) result.erase(std::remove_if (result.begin(),result.end(), [](char c) { return c == '\t'; }), result.end()); - BOOST_CHECK(result.find("ArmNN") != std::string::npos); - BOOST_CHECK(result.find("inference_measurements") != std::string::npos); + CHECK(result.find("ArmNN") != std::string::npos); + CHECK(result.find("inference_measurements") != std::string::npos); // ensure no spare parenthesis present in print output - BOOST_CHECK(AreParenthesesMatching(result)); + CHECK(AreParenthesesMatching(result)); } void RunSoftmaxProfilerJsonPrinterTest(const std::vector<armnn::BackendId>& backends) @@ -253,11 +254,11 @@ void RunSoftmaxProfilerJsonPrinterTest(const std::vector<armnn::BackendId>& back const armnn::BackendId& firstBackend = backends.at(0); if (firstBackend == armnn::Compute::GpuAcc) { - BOOST_CHECK(result.find("OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]") + CHECK(result.find("OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]") != std::string::npos); } else if (firstBackend == armnn::Compute::CpuAcc) { - BOOST_CHECK(result.find("NeonKernelTimer/: CpuLogitsDLogSoftmaxKernel_#") != std::string::npos); + CHECK(result.find("NeonKernelTimer/: CpuLogitsDLogSoftmaxKernel_#") != std::string::npos); } } diff --git a/src/backends/backendsCommon/test/LayerReleaseConstantDataTest.cpp b/src/backends/backendsCommon/test/LayerReleaseConstantDataTest.cpp index 0ca4b0a7f9..579be513f3 100644 --- a/src/backends/backendsCommon/test/LayerReleaseConstantDataTest.cpp +++ b/src/backends/backendsCommon/test/LayerReleaseConstantDataTest.cpp @@ -10,7 +10,7 @@ #include <backendsCommon/TensorHandle.hpp> #include <backendsCommon/WorkloadData.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <utility> @@ -23,9 +23,9 @@ using namespace std; // Checks weights and biases before the method called and after. ///////////////////////////////////////////////////////////////////////////////////////////// -BOOST_AUTO_TEST_SUITE(LayerReleaseConstantDataTest) - -BOOST_AUTO_TEST_CASE(ReleaseBatchNormalizationLayerConstantDataTest) +TEST_SUITE("LayerReleaseConstantDataTest") +{ +TEST_CASE("ReleaseBatchNormalizationLayerConstantDataTest") { Graph graph; @@ -54,24 +54,24 @@ BOOST_AUTO_TEST_CASE(ReleaseBatchNormalizationLayerConstantDataTest) Connect(layer, output, tensorInfo); // check the constants that they are not NULL - BOOST_CHECK(layer->m_Mean != nullptr); - BOOST_CHECK(layer->m_Variance != nullptr); - BOOST_CHECK(layer->m_Beta != nullptr); - BOOST_CHECK(layer->m_Gamma != nullptr); + CHECK(layer->m_Mean != nullptr); + CHECK(layer->m_Variance != nullptr); + CHECK(layer->m_Beta != nullptr); + CHECK(layer->m_Gamma != nullptr); // free up the constants.. layer->ReleaseConstantData(); // check the constants that they are NULL now - BOOST_CHECK(layer->m_Mean == nullptr); - BOOST_CHECK(layer->m_Variance == nullptr); - BOOST_CHECK(layer->m_Beta == nullptr); - BOOST_CHECK(layer->m_Gamma == nullptr); + CHECK(layer->m_Mean == nullptr); + CHECK(layer->m_Variance == nullptr); + CHECK(layer->m_Beta == nullptr); + CHECK(layer->m_Gamma == nullptr); } - BOOST_AUTO_TEST_CASE(ReleaseConvolution2dLayerConstantDataTest) + TEST_CASE("ReleaseConvolution2dLayerConstantDataTest") { Graph graph; @@ -104,18 +104,18 @@ BOOST_AUTO_TEST_CASE(ReleaseBatchNormalizationLayerConstantDataTest) Connect(layer, output, TensorInfo({2, 2, 2, 10}, armnn::DataType::Float32)); // check the constants that they are not NULL - BOOST_CHECK(layer->m_Weight != nullptr); - BOOST_CHECK(layer->m_Bias != nullptr); + CHECK(layer->m_Weight != nullptr); + CHECK(layer->m_Bias != nullptr); // free up the constants.. layer->ReleaseConstantData(); // check the constants that they are NULL now - BOOST_CHECK(layer->m_Weight == nullptr); - BOOST_CHECK(layer->m_Bias == nullptr); + CHECK(layer->m_Weight == nullptr); + CHECK(layer->m_Bias == nullptr); } -BOOST_AUTO_TEST_CASE(ReleaseDepthwiseConvolution2dLayerConstantDataTest) +TEST_CASE("ReleaseDepthwiseConvolution2dLayerConstantDataTest") { Graph graph; @@ -145,18 +145,18 @@ BOOST_AUTO_TEST_CASE(ReleaseDepthwiseConvolution2dLayerConstantDataTest) Connect(layer, output, TensorInfo({2, 9, 2, 10}, armnn::DataType::Float32)); // check the constants that they are not NULL - BOOST_CHECK(layer->m_Weight != nullptr); - BOOST_CHECK(layer->m_Bias != nullptr); + CHECK(layer->m_Weight != nullptr); + CHECK(layer->m_Bias != nullptr); // free up the constants.. layer->ReleaseConstantData(); // check the constants that they are NULL now - BOOST_CHECK(layer->m_Weight == nullptr); - BOOST_CHECK(layer->m_Bias == nullptr); + CHECK(layer->m_Weight == nullptr); + CHECK(layer->m_Bias == nullptr); } -BOOST_AUTO_TEST_CASE(ReleaseFullyConnectedLayerConstantDataTest) +TEST_CASE("ReleaseFullyConnectedLayerConstantDataTest") { Graph graph; @@ -186,16 +186,16 @@ BOOST_AUTO_TEST_CASE(ReleaseFullyConnectedLayerConstantDataTest) Connect(layer, output, TensorInfo({3, 7}, DataType::QAsymmU8, outputQScale)); // check the constants that they are not NULL - BOOST_CHECK(layer->m_Weight != nullptr); - BOOST_CHECK(layer->m_Bias != nullptr); + CHECK(layer->m_Weight != nullptr); + CHECK(layer->m_Bias != nullptr); // free up the constants.. layer->ReleaseConstantData(); // check the constants that they are NULL now - BOOST_CHECK(layer->m_Weight == nullptr); - BOOST_CHECK(layer->m_Bias == nullptr); + CHECK(layer->m_Weight == nullptr); + CHECK(layer->m_Bias == nullptr); } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/LogSoftmaxEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/LogSoftmaxEndToEndTestImpl.cpp index f1e6242869..1f7f57806e 100644 --- a/src/backends/backendsCommon/test/LogSoftmaxEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/LogSoftmaxEndToEndTestImpl.cpp @@ -10,7 +10,7 @@ #include <test/TestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> namespace { @@ -60,7 +60,7 @@ void LogSoftmaxEndToEnd(const std::vector<armnn::BackendId>& backends, beta, axis); - BOOST_TEST_CHECKPOINT("Create a network"); + CHECK(net); std::map<int, std::vector<float>> inputTensorData = { {0, inputData} }; std::map<int, std::vector<float>> expectedOutputTensorData = { {0, expectedOutputData} }; diff --git a/src/backends/backendsCommon/test/OptimizationViewsTests.cpp b/src/backends/backendsCommon/test/OptimizationViewsTests.cpp index b472a0321d..246cb509c3 100644 --- a/src/backends/backendsCommon/test/OptimizationViewsTests.cpp +++ b/src/backends/backendsCommon/test/OptimizationViewsTests.cpp @@ -14,8 +14,7 @@ #include <SubgraphView.hpp> #include <SubgraphViewSelector.hpp> -#include <boost/test/unit_test.hpp> - +#include <doctest/doctest.h> using namespace armnn; @@ -28,31 +27,31 @@ void CheckLayers(Graph& graph) { case LayerType::Input: ++m_inputLayerCount; - BOOST_TEST((layer->GetName() == std::string("inLayer0") || + CHECK((layer->GetName() == std::string("inLayer0") || layer->GetName() == std::string("inLayer1"))); break; // The Addition layer should become a PreCompiled Layer after Optimisation case LayerType::PreCompiled: ++m_addLayerCount; - BOOST_TEST(layer->GetName() == "pre-compiled"); + CHECK(std::string(layer->GetName()) == "pre-compiled"); break; case LayerType::Output: ++m_outputLayerCount; - BOOST_TEST(layer->GetName() == "outLayer"); + CHECK(std::string(layer->GetName()) == "outLayer"); break; default: //Fail for anything else - BOOST_TEST(false); + CHECK(false); } } - BOOST_TEST(m_inputLayerCount == 2); - BOOST_TEST(m_outputLayerCount == 1); - BOOST_TEST(m_addLayerCount == 1); + CHECK(m_inputLayerCount == 2); + CHECK(m_outputLayerCount == 1); + CHECK(m_addLayerCount == 1); } -BOOST_AUTO_TEST_SUITE(OptimizationViewsTestSuite) - -BOOST_AUTO_TEST_CASE(OptimizedViewsSubgraphLayerCount) +TEST_SUITE("OptimizationViewsTestSuite") +{ +TEST_CASE("OptimizedViewsSubgraphLayerCount") { OptimizationViews view; // Construct a graph with 3 layers @@ -117,10 +116,10 @@ BOOST_AUTO_TEST_CASE(OptimizedViewsSubgraphLayerCount) CreateOutputsFrom({convLayer2}), {convLayer1, convLayer2, substitutionpreCompiledLayer}); - BOOST_CHECK(view.Validate(*originalSubgraph)); + CHECK(view.Validate(*originalSubgraph)); } -BOOST_AUTO_TEST_CASE(OptimizedViewsSubgraphLayerCountFailValidate) +TEST_CASE("OptimizedViewsSubgraphLayerCountFailValidate") { OptimizationViews view; // Construct a graph with 3 layers @@ -180,10 +179,10 @@ BOOST_AUTO_TEST_CASE(OptimizedViewsSubgraphLayerCountFailValidate) {convLayer1, convLayer2, substitutionpreCompiledLayer}); // Validate should fail as convLayer1 is not counted - BOOST_CHECK(!view.Validate(*originalSubgraph)); + CHECK(!view.Validate(*originalSubgraph)); } -BOOST_AUTO_TEST_CASE(OptimizeViewsValidateDeviceMockBackend) +TEST_CASE("OptimizeViewsValidateDeviceMockBackend") { // build up the structure of the network armnn::INetworkPtr net(armnn::INetwork::Create()); @@ -209,11 +208,11 @@ BOOST_AUTO_TEST_CASE(OptimizeViewsValidateDeviceMockBackend) std::vector<armnn::BackendId> backends = { MockBackend().GetIdStatic() }; armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_CHECK(optNet); + CHECK(optNet); // Check the optimised graph armnn::Graph& graph = GetGraphForTesting(optNet.get()); CheckLayers(graph); } -BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file +}
\ No newline at end of file diff --git a/src/backends/backendsCommon/test/OptimizeSubgraphViewTests.cpp b/src/backends/backendsCommon/test/OptimizeSubgraphViewTests.cpp index f7ebf1a14e..6c76da67b3 100644 --- a/src/backends/backendsCommon/test/OptimizeSubgraphViewTests.cpp +++ b/src/backends/backendsCommon/test/OptimizeSubgraphViewTests.cpp @@ -12,8 +12,7 @@ #include <armnn/BackendRegistry.hpp> -#include <boost/test/unit_test.hpp> - +#include <doctest/doctest.h> #include <unordered_map> using namespace armnn; @@ -64,7 +63,7 @@ Layer* AddInputLayer(Graph& graph, LayerBindingId inputId = 0) { Layer* const inputLayer = graph.AddLayer<InputLayer>(inputId, layerName.c_str()); - BOOST_TEST(inputLayer); + CHECK(inputLayer); inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo); return inputLayer; } @@ -74,7 +73,7 @@ Layer* AddOutputLayer(Graph& graph, const std::string& layerName) { Layer* const outputLayer = graph.AddLayer<OutputLayer>(0, layerName.c_str()); - BOOST_TEST(outputLayer); + CHECK(outputLayer); return outputLayer; } @@ -88,7 +87,7 @@ Convolution2dLayer* AddConvolutionLayer(Graph& graph, const TensorInfo& outputInfo) { Convolution2dLayer* const convLayer = graph.AddLayer<Convolution2dLayer>(convolutionDescriptor, layerName.c_str()); - BOOST_TEST(convLayer); + CHECK(convLayer); SetWeightAndBias(convLayer, weightInfo, biasInfo); convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo); layersInGraph.insert(std::make_pair(convLayer->GetName(), convLayer)); @@ -103,7 +102,7 @@ Pooling2dLayer* AddPoolingLayer(Graph& graph, const TensorInfo& outputInfo) { Pooling2dLayer* const poolingLayer = graph.AddLayer<Pooling2dLayer>(poolingDescriptor, layerName.c_str()); - BOOST_TEST(poolingLayer); + CHECK(poolingLayer); poolingLayer->GetOutputSlot(0).SetTensorInfo(outputInfo); layersInGraph.insert(std::make_pair(poolingLayer->GetName(), poolingLayer)); return poolingLayer; @@ -116,7 +115,7 @@ AdditionLayer* AddAdditionaLayer(Graph& graph, const TensorInfo& outputInfo) { AdditionLayer* const additionLayer = graph.AddLayer<AdditionLayer>(layerName.c_str()); - BOOST_TEST(additionLayer); + CHECK(additionLayer); additionLayer->GetOutputSlot(0).SetTensorInfo(outputInfo); layersInGraph.insert(std::make_pair(additionLayer->GetName(), additionLayer)); return additionLayer; @@ -140,23 +139,23 @@ void CheckSubstitution(const OptimizationViews::SubstitutionPair& substitution, const SubgraphView::OutputSlots& replacementSubgraphOutputSlots = replacementSubgraph.GetOutputSlots(); const SubgraphView::Layers& replacementSubgraphLayers = replacementSubgraph.GetLayers(); - BOOST_TEST(substitutableSubgraphInputSlots.size() == expectedSubstitutableSubgraphSize.m_NumInputSlots); - BOOST_TEST(substitutableSubgraphOutputSlots.size() == expectedSubstitutableSubgraphSize.m_NumOutputSlots); - BOOST_TEST(substitutableSubgraphLayers.size() == expectedSubstitutableSubgraphSize.m_NumLayers); + CHECK(substitutableSubgraphInputSlots.size() == expectedSubstitutableSubgraphSize.m_NumInputSlots); + CHECK(substitutableSubgraphOutputSlots.size() == expectedSubstitutableSubgraphSize.m_NumOutputSlots); + CHECK(substitutableSubgraphLayers.size() == expectedSubstitutableSubgraphSize.m_NumLayers); - BOOST_TEST(AreEqual(substitutableSubgraphInputSlots, expectedSubstitutableInputSlots)); - BOOST_TEST(AreEqual(substitutableSubgraphOutputSlots, expectedSubstitutableOutputSlots)); - BOOST_TEST(AreEqual(substitutableSubgraphLayers, expectedSubstitutableLayers)); + CHECK(AreEqual(substitutableSubgraphInputSlots, expectedSubstitutableInputSlots)); + CHECK(AreEqual(substitutableSubgraphOutputSlots, expectedSubstitutableOutputSlots)); + CHECK(AreEqual(substitutableSubgraphLayers, expectedSubstitutableLayers)); - BOOST_TEST(replacementSubgraphInputSlots.size() == expectedReplacementSubgraphSize.m_NumInputSlots); - BOOST_TEST(replacementSubgraphOutputSlots.size() == expectedReplacementSubgraphSize.m_NumOutputSlots); - BOOST_TEST(replacementSubgraphLayers.size() == expectedReplacementSubgraphSize.m_NumLayers); + CHECK(replacementSubgraphInputSlots.size() == expectedReplacementSubgraphSize.m_NumInputSlots); + CHECK(replacementSubgraphOutputSlots.size() == expectedReplacementSubgraphSize.m_NumOutputSlots); + CHECK(replacementSubgraphLayers.size() == expectedReplacementSubgraphSize.m_NumLayers); - BOOST_TEST(!AreEqual(replacementSubgraphInputSlots, expectedSubstitutableInputSlots)); - BOOST_TEST(!AreEqual(replacementSubgraphOutputSlots, expectedSubstitutableOutputSlots)); - BOOST_TEST(!AreEqual(replacementSubgraphLayers, expectedSubstitutableLayers)); + CHECK(!AreEqual(replacementSubgraphInputSlots, expectedSubstitutableInputSlots)); + CHECK(!AreEqual(replacementSubgraphOutputSlots, expectedSubstitutableOutputSlots)); + CHECK(!AreEqual(replacementSubgraphLayers, expectedSubstitutableLayers)); - BOOST_TEST(std::all_of(replacementSubgraphLayers.begin(), + CHECK(std::all_of(replacementSubgraphLayers.begin(), replacementSubgraphLayers.end(), [](const Layer* layer) { @@ -175,13 +174,13 @@ void CheckFailedSubgraph(const SubgraphView& failedSubgraph, const SubgraphView::OutputSlots& failedSubgraphOutputSlots = failedSubgraph.GetOutputSlots(); const SubgraphView::Layers& failedSubgraphLayers = failedSubgraph.GetLayers(); - BOOST_TEST(failedSubgraphInputSlots.size() == expectedFailedSubgraphSize.m_NumInputSlots); - BOOST_TEST(failedSubgraphOutputSlots.size() == expectedFailedSubgraphSize.m_NumOutputSlots); - BOOST_TEST(failedSubgraphLayers.size() == expectedFailedSubgraphSize.m_NumLayers); + CHECK(failedSubgraphInputSlots.size() == expectedFailedSubgraphSize.m_NumInputSlots); + CHECK(failedSubgraphOutputSlots.size() == expectedFailedSubgraphSize.m_NumOutputSlots); + CHECK(failedSubgraphLayers.size() == expectedFailedSubgraphSize.m_NumLayers); - BOOST_TEST(AreEqual(failedSubgraphInputSlots, expectedFailedInputSlots)); - BOOST_TEST(AreEqual(failedSubgraphOutputSlots, expectedFailedOutputSlots)); - BOOST_TEST(AreEqual(failedSubgraphLayers, expectedFailedLayers)); + CHECK(AreEqual(failedSubgraphInputSlots, expectedFailedInputSlots)); + CHECK(AreEqual(failedSubgraphOutputSlots, expectedFailedOutputSlots)); + CHECK(AreEqual(failedSubgraphLayers, expectedFailedLayers)); } // Convenience function to check that the given untouched subgraph matches the specified expected values @@ -195,13 +194,13 @@ void CheckUntouchedSubgraph(const SubgraphView& untouchedSubgraph, const SubgraphView::OutputSlots& untouchedSubgraphOutputSlots = untouchedSubgraph.GetOutputSlots(); const SubgraphView::Layers& untouchedSubgraphLayers = untouchedSubgraph.GetLayers(); - BOOST_TEST(untouchedSubgraphInputSlots.size() == expectedUntouchedSubgraphSize.m_NumInputSlots); - BOOST_TEST(untouchedSubgraphOutputSlots.size() == expectedUntouchedSubgraphSize.m_NumOutputSlots); - BOOST_TEST(untouchedSubgraphLayers.size() == expectedUntouchedSubgraphSize.m_NumLayers); + CHECK(untouchedSubgraphInputSlots.size() == expectedUntouchedSubgraphSize.m_NumInputSlots); + CHECK(untouchedSubgraphOutputSlots.size() == expectedUntouchedSubgraphSize.m_NumOutputSlots); + CHECK(untouchedSubgraphLayers.size() == expectedUntouchedSubgraphSize.m_NumLayers); - BOOST_TEST(AreEqual(untouchedSubgraphInputSlots, expectedUntouchedInputSlots)); - BOOST_TEST(AreEqual(untouchedSubgraphOutputSlots, expectedUntouchedOutputSlots)); - BOOST_TEST(AreEqual(untouchedSubgraphLayers, expectedUntouchedLayers)); + CHECK(AreEqual(untouchedSubgraphInputSlots, expectedUntouchedInputSlots)); + CHECK(AreEqual(untouchedSubgraphOutputSlots, expectedUntouchedOutputSlots)); + CHECK(AreEqual(untouchedSubgraphLayers, expectedUntouchedLayers)); } // Creates a subgraph containing only a single unsupported layer (only convolutions are unsupported by the mock backend) @@ -551,28 +550,28 @@ void FullyUnsupporteSubgraphTestImpl1() // Create an unsupported subgraph SubgraphView::SubgraphViewPtr subgraphPtr = BuildFullyUnsupportedSubgraph1(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 1); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 1); - BOOST_TEST(Contains(layersInGraph, "pooling layer")); + CHECK(Contains(layersInGraph, "pooling layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly, but no optimization is performed - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // ======================================================================= // The expected results are: @@ -585,14 +584,14 @@ void FullyUnsupporteSubgraphTestImpl1() // Check the substitutions // ----------------------- - BOOST_TEST(optimizationViews.GetSubstitutions().empty()); + CHECK(optimizationViews.GetSubstitutions().empty()); // -------------------------- // Check the failed subgraphs // -------------------------- const OptimizationViews::Subgraphs& failedSubgraphs = optimizationViews.GetFailedSubgraphs(); - BOOST_TEST(failedSubgraphs.size() == 1); + CHECK(failedSubgraphs.size() == 1); CheckFailedSubgraph(failedSubgraphs.at(0), { subgraphInputSlots.size(), subgraphOutputSlots.size(), subgraphLayers.size() }, @@ -604,7 +603,7 @@ void FullyUnsupporteSubgraphTestImpl1() // Check the untouched subgraphs // ----------------------------- - BOOST_TEST(optimizationViews.GetUntouchedSubgraphs().empty()); + CHECK(optimizationViews.GetUntouchedSubgraphs().empty()); } // The input subgraph contains only unsupported layers (only convolutions are unsupported by the mock backend) @@ -615,30 +614,30 @@ void FullyUnsupporteSubgraphTestImpl2() // Create an unsupported subgraph SubgraphView::SubgraphViewPtr subgraphPtr = BuildFullyUnsupportedSubgraph2(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 3); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 3); - BOOST_TEST(Contains(layersInGraph, "pooling1 layer")); - BOOST_TEST(Contains(layersInGraph, "pooling2 layer")); - BOOST_TEST(Contains(layersInGraph, "pooling3 layer")); + CHECK(Contains(layersInGraph, "pooling1 layer")); + CHECK(Contains(layersInGraph, "pooling2 layer")); + CHECK(Contains(layersInGraph, "pooling3 layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly, but no optimization is performed - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // ======================================================================= // The expected results are: @@ -651,18 +650,18 @@ void FullyUnsupporteSubgraphTestImpl2() // Check the substitutions // ----------------------- - BOOST_TEST(optimizationViews.GetSubstitutions().empty()); + CHECK(optimizationViews.GetSubstitutions().empty()); // -------------------------- // Check the failed subgraphs // -------------------------- const OptimizationViews::Subgraphs& failedSubgraphs = optimizationViews.GetFailedSubgraphs(); - BOOST_TEST(failedSubgraphs.size() == 1); + CHECK(failedSubgraphs.size() == 1); - std::vector<Layer*> expectedFailedLayers{ layersInGraph.at("pooling1 layer"), - layersInGraph.at("pooling2 layer"), - layersInGraph.at("pooling3 layer") }; + std::list<Layer*> expectedFailedLayers{ layersInGraph.at("pooling1 layer"), + layersInGraph.at("pooling2 layer"), + layersInGraph.at("pooling3 layer") }; const SubgraphView& failedSubgraph = failedSubgraphs.at(0); @@ -674,15 +673,15 @@ void FullyUnsupporteSubgraphTestImpl2() const SubgraphView::Layers& failedSubgraphLayers = failedSubgraph.GetLayers(); - BOOST_TEST(failedSubgraphLayers.front() + 0, expectedFailedLayers.at(0)); - BOOST_TEST(failedSubgraphLayers.front() + 1, expectedFailedLayers.at(1)); - BOOST_TEST(failedSubgraphLayers.front() + 2, expectedFailedLayers.at(2)); + CHECK_EQ(failedSubgraphLayers.front() + 0, expectedFailedLayers.front() + 0); + CHECK_EQ(failedSubgraphLayers.front() + 1, expectedFailedLayers.front() + 1); + CHECK_EQ(failedSubgraphLayers.front() + 2, expectedFailedLayers.front() + 2); // ----------------------------- // Check the untouched subgraphs // ----------------------------- - BOOST_TEST(optimizationViews.GetUntouchedSubgraphs().empty()); + CHECK(optimizationViews.GetUntouchedSubgraphs().empty()); } // A simple case with only one layer (convolution) to optimize, supported by the mock backend @@ -693,28 +692,28 @@ void FullyOptimizableSubgraphTestImpl1() // Create a fully optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildFullyOptimizableSubgraph1(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 1); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 1); - BOOST_TEST(Contains(layersInGraph, "conv layer")); + CHECK(Contains(layersInGraph, "conv layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // =========================================================================================== // The expected results are: @@ -728,7 +727,7 @@ void FullyOptimizableSubgraphTestImpl1() // ----------------------- const OptimizationViews::Substitutions& substitutions = optimizationViews.GetSubstitutions(); - BOOST_TEST(substitutions.size() == 1); + CHECK(substitutions.size() == 1); CheckSubstitution(substitutions.at(0), { subgraphInputSlots.size(), subgraphOutputSlots.size(), subgraphLayers.size() }, @@ -741,13 +740,13 @@ void FullyOptimizableSubgraphTestImpl1() // Check the failed subgraphs // -------------------------- - BOOST_TEST(optimizationViews.GetFailedSubgraphs().empty()); + CHECK(optimizationViews.GetFailedSubgraphs().empty()); // ----------------------------- // Check the untouched subgraphs // ----------------------------- - BOOST_TEST(optimizationViews.GetUntouchedSubgraphs().empty()); + CHECK(optimizationViews.GetUntouchedSubgraphs().empty()); } // A case with five layers (all convolutions) to optimize, all supported by the mock backend @@ -758,32 +757,32 @@ void FullyOptimizableSubgraphTestImpl2() // Create a fully optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildFullyOptimizableSubgraph2(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphPtr->GetInputSlots().size() == 1); - BOOST_TEST(subgraphPtr->GetOutputSlots().size() == 1); - BOOST_TEST(subgraphPtr->GetLayers().size() == 5); + CHECK(subgraphPtr->GetInputSlots().size() == 1); + CHECK(subgraphPtr->GetOutputSlots().size() == 1); + CHECK(subgraphPtr->GetLayers().size() == 5); - BOOST_TEST(Contains(layersInGraph, "conv1 layer")); - BOOST_TEST(Contains(layersInGraph, "conv2 layer")); - BOOST_TEST(Contains(layersInGraph, "conv3 layer")); - BOOST_TEST(Contains(layersInGraph, "conv4 layer")); - BOOST_TEST(Contains(layersInGraph, "conv5 layer")); + CHECK(Contains(layersInGraph, "conv1 layer")); + CHECK(Contains(layersInGraph, "conv2 layer")); + CHECK(Contains(layersInGraph, "conv3 layer")); + CHECK(Contains(layersInGraph, "conv4 layer")); + CHECK(Contains(layersInGraph, "conv5 layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // =========================================================================================== // The expected results are: @@ -797,7 +796,7 @@ void FullyOptimizableSubgraphTestImpl2() // ----------------------- const OptimizationViews::Substitutions& substitutions = optimizationViews.GetSubstitutions(); - BOOST_TEST(substitutions.size() == 1); + CHECK(substitutions.size() == 1); std::list<Layer*> expectedSubstitutableLayers{ layersInGraph.at("conv1 layer"), layersInGraph.at("conv2 layer"), @@ -816,23 +815,23 @@ void FullyOptimizableSubgraphTestImpl2() const SubgraphView::Layers& substitutableSubgraphLayers = substitution.m_SubstitutableSubgraph.GetLayers(); - BOOST_TEST(substitutableSubgraphLayers.front() + 0, expectedSubstitutableLayers.front() + 0); - BOOST_TEST(substitutableSubgraphLayers.front() + 1, expectedSubstitutableLayers.front() + 1); - BOOST_TEST(substitutableSubgraphLayers.front() + 2, expectedSubstitutableLayers.front() + 2); - BOOST_TEST(substitutableSubgraphLayers.front() + 3, expectedSubstitutableLayers.front() + 3); - BOOST_TEST(substitutableSubgraphLayers.front() + 4, expectedSubstitutableLayers.front() + 4); + CHECK_EQ(substitutableSubgraphLayers.front() + 0, expectedSubstitutableLayers.front() + 0); + CHECK_EQ(substitutableSubgraphLayers.front() + 1, expectedSubstitutableLayers.front() + 1); + CHECK_EQ(substitutableSubgraphLayers.front() + 2, expectedSubstitutableLayers.front() + 2); + CHECK_EQ(substitutableSubgraphLayers.front() + 3, expectedSubstitutableLayers.front() + 3); + CHECK_EQ(substitutableSubgraphLayers.front() + 4, expectedSubstitutableLayers.front() + 4); // -------------------------- // Check the failed subgraphs // -------------------------- - BOOST_TEST(optimizationViews.GetFailedSubgraphs().empty()); + CHECK(optimizationViews.GetFailedSubgraphs().empty()); // ----------------------------- // Check the untouched subgraphs // ----------------------------- - BOOST_TEST(optimizationViews.GetUntouchedSubgraphs().empty()); + CHECK(optimizationViews.GetUntouchedSubgraphs().empty()); } // The input subgraph contaions both supported and unsupported layers @@ -844,32 +843,32 @@ void PartiallySupportedSubgraphTestImpl() // Create a fully optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildPartiallySupportedSubgraph(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 5); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 5); - BOOST_TEST(Contains(layersInGraph, "conv1 layer")); - BOOST_TEST(Contains(layersInGraph, "pooling1 layer")); - BOOST_TEST(Contains(layersInGraph, "pooling2 layer")); - BOOST_TEST(Contains(layersInGraph, "conv2 layer")); - BOOST_TEST(Contains(layersInGraph, "pooling3 layer")); + CHECK(Contains(layersInGraph, "conv1 layer")); + CHECK(Contains(layersInGraph, "pooling1 layer")); + CHECK(Contains(layersInGraph, "pooling2 layer")); + CHECK(Contains(layersInGraph, "conv2 layer")); + CHECK(Contains(layersInGraph, "pooling3 layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // ======================================================================== // The expected results are: @@ -883,7 +882,7 @@ void PartiallySupportedSubgraphTestImpl() // ----------------------- OptimizationViews::Substitutions substitutions = optimizationViews.GetSubstitutions(); - BOOST_TEST(substitutions.size() == 2); + CHECK(substitutions.size() == 2); // Sort into a consistent order std::sort(substitutions.begin(), substitutions.end(), [](auto s1, auto s2) { return strcmp(s1.m_SubstitutableSubgraph.GetLayers().front()->GetName(), @@ -925,7 +924,7 @@ void PartiallySupportedSubgraphTestImpl() // -------------------------- OptimizationViews::Subgraphs failedSubgraphs = optimizationViews.GetFailedSubgraphs(); - BOOST_TEST(failedSubgraphs.size() == 2); + CHECK(failedSubgraphs.size() == 2); // Sort into a consistent order std::sort(failedSubgraphs.begin(), failedSubgraphs.end(), [](auto s1, auto s2) { return strcmp(s1.GetLayers().front()->GetName(), s2.GetLayers().front()->GetName()) < 0; @@ -963,7 +962,7 @@ void PartiallySupportedSubgraphTestImpl() // Check the untouched subgraphs // ----------------------------- - BOOST_TEST(optimizationViews.GetUntouchedSubgraphs().empty()); + CHECK(optimizationViews.GetUntouchedSubgraphs().empty()); } // The input subgraph contains only unoptimizable layers ("unoptimizable" is added to the layer's name) @@ -974,28 +973,28 @@ void FullyUnoptimizableSubgraphTestImpl1() // Create a fully optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildFullyUnoptimizableSubgraph1(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 1); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 1); - BOOST_TEST(Contains(layersInGraph, "conv layer unoptimizable")); + CHECK(Contains(layersInGraph, "conv layer unoptimizable")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // ============================================================================ // The expected results are: @@ -1008,20 +1007,20 @@ void FullyUnoptimizableSubgraphTestImpl1() // Check the substitutions // ----------------------- - BOOST_TEST(optimizationViews.GetSubstitutions().empty()); + CHECK(optimizationViews.GetSubstitutions().empty()); // -------------------------- // Check the failed subgraphs // -------------------------- - BOOST_TEST(optimizationViews.GetFailedSubgraphs().empty()); + CHECK(optimizationViews.GetFailedSubgraphs().empty()); // ----------------------------- // Check the untouched subgraphs // ----------------------------- const OptimizationViews::Subgraphs& untouchedSubgraphs = optimizationViews.GetUntouchedSubgraphs(); - BOOST_TEST(untouchedSubgraphs.size() == 1); + CHECK(untouchedSubgraphs.size() == 1); CheckUntouchedSubgraph(untouchedSubgraphs.at(0), { subgraphInputSlots.size(), subgraphOutputSlots.size(), subgraphLayers.size() }, @@ -1038,32 +1037,32 @@ void PartiallyOptimizableSubgraphTestImpl1() // Create a fully optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildPartiallyOptimizableSubgraph1(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 1); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 5); + CHECK(subgraphInputSlots.size() == 1); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 5); - BOOST_TEST(Contains(layersInGraph, "conv1 layer")); - BOOST_TEST(Contains(layersInGraph, "conv2 layer unoptimizable")); - BOOST_TEST(Contains(layersInGraph, "conv3 layer")); - BOOST_TEST(Contains(layersInGraph, "conv4 layer unoptimizable")); - BOOST_TEST(Contains(layersInGraph, "conv5 layer")); + CHECK(Contains(layersInGraph, "conv1 layer")); + CHECK(Contains(layersInGraph, "conv2 layer unoptimizable")); + CHECK(Contains(layersInGraph, "conv3 layer")); + CHECK(Contains(layersInGraph, "conv4 layer unoptimizable")); + CHECK(Contains(layersInGraph, "conv5 layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // =============================================================================== // The expected results are: @@ -1077,7 +1076,7 @@ void PartiallyOptimizableSubgraphTestImpl1() // ----------------------- OptimizationViews::Substitutions substitutions = optimizationViews.GetSubstitutions(); - BOOST_TEST(substitutions.size() == 3); + CHECK(substitutions.size() == 3); // Sort into a consistent order std::sort(substitutions.begin(), substitutions.end(), [](auto s1, auto s2) { return strcmp(s1.m_SubstitutableSubgraph.GetLayers().front()->GetName(), @@ -1122,14 +1121,14 @@ void PartiallyOptimizableSubgraphTestImpl1() // Check the failed subgraphs // -------------------------- - BOOST_TEST(optimizationViews.GetFailedSubgraphs().empty()); + CHECK(optimizationViews.GetFailedSubgraphs().empty()); // ----------------------------- // Check the untouched subgraphs // ----------------------------- OptimizationViews::Subgraphs untouchedSubgraphs = optimizationViews.GetUntouchedSubgraphs(); - BOOST_TEST(untouchedSubgraphs.size() == 2); + CHECK(untouchedSubgraphs.size() == 2); // Sort into a consistent order std::sort(untouchedSubgraphs.begin(), untouchedSubgraphs.end(), [](auto s1, auto s2) { return strcmp(s1.GetLayers().front()->GetName(), s2.GetLayers().front()->GetName()) < 0; @@ -1172,31 +1171,31 @@ void PartiallyOptimizableSubgraphTestImpl2() // Create a partially optimizable subgraph SubgraphViewSelector::SubgraphViewPtr subgraphPtr = BuildPartiallyOptimizableSubgraph2(graph, layersInGraph); - BOOST_TEST((subgraphPtr != nullptr)); + CHECK((subgraphPtr != nullptr)); const SubgraphView::InputSlots& subgraphInputSlots = subgraphPtr->GetInputSlots(); const SubgraphView::OutputSlots& subgraphOutputSlots = subgraphPtr->GetOutputSlots(); const SubgraphView::Layers& subgraphLayers = subgraphPtr->GetLayers(); - BOOST_TEST(subgraphInputSlots.size() == 2); - BOOST_TEST(subgraphOutputSlots.size() == 1); - BOOST_TEST(subgraphLayers.size() == 4); + CHECK(subgraphInputSlots.size() == 2); + CHECK(subgraphOutputSlots.size() == 1); + CHECK(subgraphLayers.size() == 4); - BOOST_TEST(Contains(layersInGraph, "conv1 layer")); - BOOST_TEST(Contains(layersInGraph, "conv2 layer unoptimizable")); - BOOST_TEST(Contains(layersInGraph, "conv3 layer")); - BOOST_TEST(Contains(layersInGraph, "add layer")); + CHECK(Contains(layersInGraph, "conv1 layer")); + CHECK(Contains(layersInGraph, "conv2 layer unoptimizable")); + CHECK(Contains(layersInGraph, "conv3 layer")); + CHECK(Contains(layersInGraph, "add layer")); // Create a mock backend object MockBackendInitialiser initialiser; // Register the Mock Backend auto backendObjPtr = CreateBackendObject(MockBackendId()); - BOOST_TEST((backendObjPtr != nullptr)); + CHECK((backendObjPtr != nullptr)); // Optimize the subgraph OptimizationViews optimizationViews; // Check that the optimization is carried out correctly - BOOST_CHECK_NO_THROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); + CHECK_NOTHROW(optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraphPtr)); // ============================================================================== // The expected results are: @@ -1210,7 +1209,7 @@ void PartiallyOptimizableSubgraphTestImpl2() // ----------------------- const OptimizationViews::Substitutions& substitutions = optimizationViews.GetSubstitutions(); - BOOST_TEST(substitutions.size() == 1); + CHECK(substitutions.size() == 1); ExpectedSubgraphSize expectedSubstitutableSubgraphSizes{ 2, 1, 3 }; ExpectedSubgraphSize expectedReplacementSubgraphSizes{ 2, 1, 1 }; @@ -1241,14 +1240,14 @@ void PartiallyOptimizableSubgraphTestImpl2() // Check the failed subgraphs // -------------------------- - BOOST_TEST(optimizationViews.GetFailedSubgraphs().empty()); + CHECK(optimizationViews.GetFailedSubgraphs().empty()); // ----------------------------- // Check the untouched subgraphs // ----------------------------- const OptimizationViews::Subgraphs& untouchedSubgraphs = optimizationViews.GetUntouchedSubgraphs(); - BOOST_TEST(untouchedSubgraphs.size() == 1); + CHECK(untouchedSubgraphs.size() == 1); std::vector<ExpectedSubgraphSize> expectedUntouchedSubgraphSizes{ { 1, 1, 1 } }; std::vector<SubgraphView::InputSlots> expectedUntouchedInputSlots @@ -1276,15 +1275,15 @@ void PartiallyOptimizableSubgraphTestImpl2() } // Anonymous namespace -BOOST_AUTO_TEST_SUITE(OptimizeSubGraph) - -BOOST_AUTO_TEST_CASE(FullyUnsupportedSubgraph1) { FullyUnsupporteSubgraphTestImpl1(); } -BOOST_AUTO_TEST_CASE(FullyUnsupportedSubgraph2) { FullyUnsupporteSubgraphTestImpl2(); } -BOOST_AUTO_TEST_CASE(FullyOptimizableSubgraph1) { FullyOptimizableSubgraphTestImpl1(); } -BOOST_AUTO_TEST_CASE(FullyOptimizableSubgraph2) { FullyOptimizableSubgraphTestImpl2(); } -BOOST_AUTO_TEST_CASE(PartiallySupportedSubgraph) { PartiallySupportedSubgraphTestImpl(); } -BOOST_AUTO_TEST_CASE(FullyUnoptimizableSubgraph) { FullyUnoptimizableSubgraphTestImpl1(); } -BOOST_AUTO_TEST_CASE(PartiallyOptimizableSubgraph1) { PartiallyOptimizableSubgraphTestImpl1(); } -BOOST_AUTO_TEST_CASE(PartiallyOptimizableSubgraph2) { PartiallyOptimizableSubgraphTestImpl2(); } +TEST_SUITE("OptimizeSubGraph") +{ +TEST_CASE("FullyUnsupportedSubgraph1") { FullyUnsupporteSubgraphTestImpl1(); } +TEST_CASE("FullyUnsupportedSubgraph2") { FullyUnsupporteSubgraphTestImpl2(); } +TEST_CASE("FullyOptimizableSubgraph1") { FullyOptimizableSubgraphTestImpl1(); } +TEST_CASE("FullyOptimizableSubgraph2") { FullyOptimizableSubgraphTestImpl2(); } +TEST_CASE("PartiallySupportedSubgraph") { PartiallySupportedSubgraphTestImpl(); } +TEST_CASE("FullyUnoptimizableSubgraph") { FullyUnoptimizableSubgraphTestImpl1(); } +TEST_CASE("PartiallyOptimizableSubgraph1") { PartiallyOptimizableSubgraphTestImpl1(); } +TEST_CASE("PartiallyOptimizableSubgraph2") { PartiallyOptimizableSubgraphTestImpl2(); } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp index 66d166fc08..2c74690e6e 100644 --- a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp +++ b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp @@ -3,17 +3,16 @@ // SPDX-License-Identifier: MIT // - #include <Graph.hpp> #include <Network.hpp> #include <reference/RefWorkloadFactory.hpp> -#include <boost/test/unit_test.hpp> - -BOOST_AUTO_TEST_SUITE(OptimizedNetwork) +#include <doctest/doctest.h> -BOOST_AUTO_TEST_CASE(SerializeToDot) +TEST_SUITE("OptimizedNetwork") +{ +TEST_CASE("SerializeToDot") { // build up the structure of the network armnn::INetworkPtr net(armnn::INetwork::Create()); @@ -62,10 +61,10 @@ BOOST_AUTO_TEST_CASE(SerializeToDot) " " << addId << " -> " << outputId << " [label=< [4] >];\n" "}\n"; - BOOST_TEST(ss.str() == expected.str()); + CHECK(ss.str() == expected.str()); } -BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerNoFallback) +TEST_CASE("OptimizeValidateDeviceNonSupportLayerNoFallback") { // build up the structure of the network armnn::INetworkPtr net(armnn::INetwork::Create()); @@ -93,16 +92,16 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerNoFallback) try { Optimize(*net, backends, runtime->GetDeviceSpec(), armnn::OptimizerOptions(), errMessages); - BOOST_FAIL("Should have thrown an exception."); + FAIL("Should have thrown an exception."); } catch (const armnn::InvalidArgumentException& e) { // Different exceptions are thrown on different backends } - BOOST_CHECK(errMessages.size() > 0); + CHECK(errMessages.size() > 0); } -BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerWithFallback) +TEST_CASE("OptimizeValidateDeviceNonSupportLayerWithFallback") { // build up the structure of the network armnn::INetworkPtr net(armnn::INetwork::Create()); @@ -126,7 +125,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerWithFallback) std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, armnn::Compute::CpuRef }; armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_REQUIRE(optNet); + REQUIRE(optNet); armnn::Graph& graph = GetGraphForTesting(optNet.get()); graph.AllocateDynamicBuffers(); @@ -139,19 +138,19 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerWithFallback) #if defined(ARMCOMPUTENEON_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); + CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); } else if (layer->GetType() == armnn::LayerType::Normalization) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); } #else - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); #endif } } -BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDevice) +TEST_CASE("OptimizeValidateWorkloadsUndefinedComputeDevice") { const armnn::TensorInfo desc({3, 5}, armnn::DataType::Float32); @@ -213,16 +212,16 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDevice) try { Optimize(*net, backends, runtime->GetDeviceSpec(), armnn::OptimizerOptions(), errMessages); - BOOST_FAIL("Should have thrown an exception."); + FAIL("Should have thrown an exception."); } catch (const armnn::InvalidArgumentException& e) { // Different exceptions are thrown on different backends } - BOOST_CHECK(errMessages.size() > 0); + CHECK(errMessages.size() > 0); } -BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback) +TEST_CASE("OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback") { const armnn::TensorInfo desc({3, 5}, armnn::DataType::Float32); @@ -281,7 +280,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback std::vector<armnn::BackendId> backends = { armnn::Compute::Undefined, armnn::Compute::CpuRef }; armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_CHECK(optNet); + CHECK(optNet); armnn::Graph& graph = GetGraphForTesting(optNet.get()); graph.AllocateDynamicBuffers(); @@ -290,13 +289,13 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback armnn::RefWorkloadFactory fact; for (auto&& layer : graph) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); - BOOST_CHECK_NO_THROW( + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK_NOTHROW( layer->CreateWorkload(fact)); } } -BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback) +TEST_CASE("OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback") { // build up the structure of the network armnn::INetworkPtr net(armnn::INetwork::Create()); @@ -323,7 +322,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback armnn::Compute::CpuRef }; armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec()); - BOOST_REQUIRE(optNet); + REQUIRE(optNet); armnn::Graph& graph = GetGraphForTesting(optNet.get()); graph.AllocateDynamicBuffers(); @@ -338,25 +337,25 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback #if defined(ARMCOMPUTENEON_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); + CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); } else if (layer->GetType() == armnn::LayerType::Normalization) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); } #elif defined(ARMCOMPUTECL_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::GpuAcc); + CHECK(layer->GetBackendId() == armnn::Compute::GpuAcc); } else if (layer->GetType() == armnn::LayerType::Normalization) { - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); } #else - BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); + CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); #endif } } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/PreluEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/PreluEndToEndTestImpl.hpp index 0dc1e78ced..e11553dd38 100644 --- a/src/backends/backendsCommon/test/PreluEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/PreluEndToEndTestImpl.hpp @@ -10,6 +10,8 @@ #include <backendsCommon/test/CommonTestUtils.hpp> +#include <doctest/doctest.h> + namespace { template<typename armnn::DataType DataType> @@ -56,7 +58,7 @@ void PreluEndToEnd(const std::vector<BackendId>& backends, INetworkPtr net = CreatePreluNetwork<ArmnnType>(inputInfo, alphaInfo, outputInfo); - BOOST_TEST_CHECKPOINT("Create a network"); + CHECK(net); std::map<int, std::vector<T>> inputTensorData = { { 0, inputData }, { 1, alphaData} }; std::map<int, std::vector<T>> expectedOutputTensorData = { { 0, expectedOutputData } }; diff --git a/src/backends/backendsCommon/test/QLstmEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/QLstmEndToEndTestImpl.cpp index 9949824c2e..281bed18e7 100644 --- a/src/backends/backendsCommon/test/QLstmEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/QLstmEndToEndTestImpl.cpp @@ -11,7 +11,7 @@ #include <armnn/INetwork.hpp> #include <armnn/LstmParams.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> namespace { @@ -260,11 +260,11 @@ void QLstmEndToEnd(const std::vector<armnn::BackendId>& backends) constexpr int8_t toleranceInt8 = 1; for (unsigned int i = 0u; i < outputStateOutResult.size(); ++i) { - BOOST_TEST(IsCloseEnough(outputStateOutVector[i], outputStateOutResult[i], toleranceInt8)); + CHECK(IsCloseEnough(outputStateOutVector[i], outputStateOutResult[i], toleranceInt8)); } for (unsigned int i = 0u; i < outputResult.size(); ++i) { - BOOST_TEST(IsCloseEnough(outputVector[i], outputResult[i], toleranceInt8)); + CHECK(IsCloseEnough(outputVector[i], outputResult[i], toleranceInt8)); } }
\ No newline at end of file diff --git a/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp index c68051c8ca..a2fadc7b92 100644 --- a/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp @@ -17,7 +17,7 @@ #include <test/TensorHelpers.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <type_traits> @@ -196,8 +196,6 @@ void QuantizedLstmEndToEnd(const std::vector<armnn::BackendId>& backends) // Builds up the structure of the network armnn::INetworkPtr net = CreateQuantizedLstmNetwork(inputDesc.GetShape(), outputDesc.GetShape()); - BOOST_TEST_CHECKPOINT("create a network"); - IRuntime::CreationOptions options; IRuntimePtr runtime(IRuntime::Create(options)); @@ -232,12 +230,12 @@ void QuantizedLstmEndToEnd(const std::vector<armnn::BackendId>& backends) constexpr int16_t toleranceInt16 = 2; for (unsigned int i = 0u; i < cellStateOutResult.size(); ++i) { - BOOST_CHECK(IsCloseEnough(cellStateOutVector[i], cellStateOutResult[i], toleranceInt16)); + CHECK(IsCloseEnough(cellStateOutVector[i], cellStateOutResult[i], toleranceInt16)); } constexpr uint8_t toleranceUint8 = 1; for (unsigned int i = 0u; i < outputStateOutResult.size(); ++i) { - BOOST_TEST(IsCloseEnough(outputStateOutVector[i], outputStateOutResult[i], toleranceUint8)); + CHECK(IsCloseEnough(outputStateOutVector[i], outputStateOutResult[i], toleranceUint8)); } } diff --git a/src/backends/backendsCommon/test/RankEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/RankEndToEndTestImpl.hpp index a67bd46982..461b3b9be8 100644 --- a/src/backends/backendsCommon/test/RankEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/RankEndToEndTestImpl.hpp @@ -12,6 +12,8 @@ #include <ResolveType.hpp> +#include <doctest/doctest.h> + namespace { @@ -50,7 +52,7 @@ void RankEndToEnd(const std::vector<armnn::BackendId>& backends) armnn::INetworkPtr network = CreateRankNetwork(inputInfo, outputInfo); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(network); std::map<int, std::vector<T>> inputTensorData = {{ 0, inputData }}; std::map<int, std::vector<int32_t>> expectedOutputTensorData = {{ 0, expectedOutputData }}; diff --git a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp index cde85caf7d..aa7af11feb 100644 --- a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp @@ -14,8 +14,6 @@ #include <backendsCommon/test/CommonTestUtils.hpp> -#include <boost/test/unit_test.hpp> - #include <map> #include <vector> diff --git a/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp index 6d1a7b0556..4e5baade27 100644 --- a/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp @@ -16,7 +16,7 @@ #include <test/TestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> namespace { @@ -81,7 +81,7 @@ void SpaceToDepthEndToEnd(const std::vector<armnn::BackendId>& backends, dataLayout, blockSize); - BOOST_TEST_CHECKPOINT("Create a network"); + CHECK(net); std::map<int, std::vector<float>> inputTensorData = { { 0, inputData } }; std::map<int, std::vector<float>> expectedOutputTensorData = { { 0, expectedOutputData } }; diff --git a/src/backends/backendsCommon/test/SplitterEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/SplitterEndToEndTestImpl.hpp index 257a81b50b..64e24e54aa 100644 --- a/src/backends/backendsCommon/test/SplitterEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/SplitterEndToEndTestImpl.hpp @@ -12,7 +12,7 @@ #include <backendsCommon/test/CommonTestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -86,7 +86,7 @@ void Splitter1dEndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ 1, 2, 3, 4 }; @@ -114,7 +114,7 @@ void Splitter2dDim0EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -149,7 +149,7 @@ void Splitter2dDim1EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -187,7 +187,7 @@ void Splitter3dDim0EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -235,7 +235,7 @@ void Splitter3dDim1EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -283,7 +283,7 @@ void Splitter3dDim2EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -323,7 +323,7 @@ void Splitter4dDim0EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -403,7 +403,7 @@ void Splitter4dDim1EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -483,7 +483,7 @@ void Splitter4dDim2EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ @@ -562,7 +562,7 @@ void Splitter4dDim3EndToEnd(const std::vector<BackendId>& backends) // Builds up the structure of the network INetworkPtr net = CreateSplitterNetwork<ArmnnType>(inputShape, outputShapes, splitAxis, numSplit); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ diff --git a/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp b/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp index 0ad6bc4964..a552a6a7da 100644 --- a/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp +++ b/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp @@ -14,7 +14,7 @@ #include <AsyncExecutionCallback.hpp> #include <backendsCommon/test/CommonTestUtils.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <vector> @@ -109,7 +109,7 @@ void AsyncThreadedEndToEndTestImpl(INetworkPtr network, std::vector<TOutput> out = outputStorageVec[i].at(it.first); for (unsigned int j = 0; j < out.size(); ++j) { - BOOST_CHECK(Compare<ArmnnOType>(it.second[j], out[j], tolerance) == true); + CHECK(Compare<ArmnnOType>(it.second[j], out[j], tolerance) == true); } } } @@ -197,7 +197,7 @@ void AsyncEndToEndTestImpl(INetworkPtr network, cb->Wait(); // Checks the results. - BOOST_CHECK(cb->GetStatus() == Status::Success); + CHECK(cb->GetStatus() == Status::Success); } } @@ -207,7 +207,7 @@ void AsyncEndToEndTestImpl(INetworkPtr network, for (unsigned int i = 0; i < out.size(); ++i) { - BOOST_CHECK(Compare<ArmnnOType>(it.second[i], out[i], tolerance) == true); + CHECK(Compare<ArmnnOType>(it.second[i], out[i], tolerance) == true); } } } @@ -282,8 +282,7 @@ void StridedSlicedEndToEndTest(const std::vector<BackendId>& backends, size_t nu ellipsisMask, newAxisMask); - BOOST_TEST_CHECKPOINT("create a network"); - + CHECK(net); // Creates structures for input & output. std::vector<T> inputData{ 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, @@ -337,7 +336,7 @@ void StridedSlicedMultiThreadedEndToEndTest(const std::vector<BackendId>& backen ellipsisMask, newAxisMask); - BOOST_TEST_CHECKPOINT("create a network"); + CHECK(net); // Creates structures for input & output. std::vector<T> inputData1{ diff --git a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp index 57fc200a30..133829c43b 100644 --- a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp @@ -14,8 +14,6 @@ #include <backendsCommon/test/CommonTestUtils.hpp> -#include <boost/test/unit_test.hpp> - #include <map> #include <vector> diff --git a/src/backends/backendsCommon/test/WorkloadDataValidation.cpp b/src/backends/backendsCommon/test/WorkloadDataValidation.cpp index 182c913777..2034a65f6d 100644 --- a/src/backends/backendsCommon/test/WorkloadDataValidation.cpp +++ b/src/backends/backendsCommon/test/WorkloadDataValidation.cpp @@ -13,13 +13,13 @@ #include <reference/workloads/RefWorkloads.hpp> #include <reference/RefWorkloadFactory.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> using namespace armnn; -BOOST_AUTO_TEST_SUITE(WorkloadInfoValidation) - -BOOST_AUTO_TEST_CASE(BatchNormalizationQueueDescriptor_Validate_DifferentQuantizationData) +TEST_SUITE("WorkloadInfoValidation") +{ +TEST_CASE("BatchNormalizationQueueDescriptor_Validate_DifferentQuantizationData") { TensorShape inputShape { 1, 3, 2, 2 }; TensorShape outputShape { 1, 3, 2, 2 }; @@ -42,18 +42,18 @@ BOOST_AUTO_TEST_CASE(BatchNormalizationQueueDescriptor_Validate_DifferentQuantiz invalidData.m_Beta= &sameTensor; invalidData.m_Gamma = &sameTensor; - BOOST_CHECK_NO_THROW(RefBatchNormalizationWorkload(invalidData, invalidInfo)); + CHECK_NOTHROW(RefBatchNormalizationWorkload(invalidData, invalidInfo)); } -BOOST_AUTO_TEST_CASE(QueueDescriptor_Validate_WrongNumOfInputsOutputs) +TEST_CASE("QueueDescriptor_Validate_WrongNumOfInputsOutputs") { InputQueueDescriptor invalidData; WorkloadInfo invalidInfo; //Invalid argument exception is expected, because no inputs and no outputs were defined. - BOOST_CHECK_THROW(RefWorkloadFactory().CreateInput(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefWorkloadFactory().CreateInput(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(RefPooling2dFloat32Workload_Validate_WrongDimTensor) +TEST_CASE("RefPooling2dFloat32Workload_Validate_WrongDimTensor") { armnn::TensorInfo inputTensorInfo; armnn::TensorInfo outputTensorInfo; @@ -71,10 +71,10 @@ BOOST_AUTO_TEST_CASE(RefPooling2dFloat32Workload_Validate_WrongDimTensor) AddInputToWorkload(invalidData, invalidInfo, inputTensorInfo, nullptr); // Invalid argument exception is expected, input tensor has to be 4D. - BOOST_CHECK_THROW(RefPooling2dWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefPooling2dWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(SoftmaxQueueDescriptor_Validate_WrongInputHeight) +TEST_CASE("SoftmaxQueueDescriptor_Validate_WrongInputHeight") { unsigned int inputHeight = 1; unsigned int inputWidth = 1; @@ -102,10 +102,10 @@ BOOST_AUTO_TEST_CASE(SoftmaxQueueDescriptor_Validate_WrongInputHeight) AddOutputToWorkload(invalidData, invalidInfo, outputTensorInfo, nullptr); //Invalid argument exception is expected, because height != 1. - BOOST_CHECK_THROW(RefSoftmaxWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefSoftmaxWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(FullyConnectedQueueDescriptor_Validate_RequiredDataMissing) +TEST_CASE("FullyConnectedQueueDescriptor_Validate_RequiredDataMissing") { unsigned int inputWidth = 1; unsigned int inputHeight = 1; @@ -149,11 +149,11 @@ BOOST_AUTO_TEST_CASE(FullyConnectedQueueDescriptor_Validate_RequiredDataMissing) //Invalid argument exception is expected, because not all required fields have been provided. //In particular inputsData[0], outputsData[0] and weightsData can not be null. - BOOST_CHECK_THROW(RefFullyConnectedWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefFullyConnectedWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(NormalizationQueueDescriptor_Validate_WrongInputHeight) +TEST_CASE("NormalizationQueueDescriptor_Validate_WrongInputHeight") { constexpr unsigned int inputNum = 5; constexpr unsigned int inputHeight = 32; @@ -197,10 +197,10 @@ BOOST_AUTO_TEST_CASE(NormalizationQueueDescriptor_Validate_WrongInputHeight) invalidData.m_Parameters.m_K = kappa; //Invalid argument exception is expected, because input height != output height. - BOOST_CHECK_THROW(RefNormalizationWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefNormalizationWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(SplitterQueueDescriptor_Validate_WrongWindow) +TEST_CASE("SplitterQueueDescriptor_Validate_WrongWindow") { constexpr unsigned int inputNum = 1; constexpr unsigned int inputHeight = 32; @@ -233,16 +233,15 @@ BOOST_AUTO_TEST_CASE(SplitterQueueDescriptor_Validate_WrongWindow) armnn::SplitterQueueDescriptor::ViewOrigin window(wOrigin); invalidData.m_ViewOrigins.push_back(window); - BOOST_TEST_INFO("Invalid argument exception is expected, because split window dimensionality does not " - "match input."); - BOOST_CHECK_THROW(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid argument exception is expected, because split window dimensionality does not match input."); + CHECK_THROWS_AS(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); // Invalid, since window extends past the boundary of input tensor. std::vector<unsigned int> wOrigin3 = {0, 0, 15, 0}; armnn::SplitterQueueDescriptor::ViewOrigin window3(wOrigin3); invalidData.m_ViewOrigins[0] = window3; - BOOST_TEST_INFO("Invalid argument exception is expected (wOrigin3[2]+ outputHeight > inputHeight"); - BOOST_CHECK_THROW(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid argument exception is expected (wOrigin3[2]+ outputHeight > inputHeight"); + CHECK_THROWS_AS(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); std::vector<unsigned int> wOrigin4 = {0, 0, 0, 0}; @@ -253,12 +252,12 @@ BOOST_AUTO_TEST_CASE(SplitterQueueDescriptor_Validate_WrongWindow) armnn::SplitterQueueDescriptor::ViewOrigin window5(wOrigin4); invalidData.m_ViewOrigins.push_back(window5); - BOOST_TEST_INFO("Invalid exception due to number of split windows not matching number of outputs."); - BOOST_CHECK_THROW(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid exception due to number of split windows not matching number of outputs."); + CHECK_THROWS_AS(RefSplitterWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(ConcatQueueDescriptor_Validate_WrongWindow) +TEST_CASE("ConcatQueueDescriptor_Validate_WrongWindow") { constexpr unsigned int inputNum = 1; constexpr unsigned int inputChannels = 3; @@ -291,16 +290,15 @@ BOOST_AUTO_TEST_CASE(ConcatQueueDescriptor_Validate_WrongWindow) armnn::ConcatQueueDescriptor::ViewOrigin window(wOrigin); invalidData.m_ViewOrigins.push_back(window); - BOOST_TEST_INFO("Invalid argument exception is expected, because merge window dimensionality does not " - "match input."); - BOOST_CHECK_THROW(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid argument exception is expected, because merge window dimensionality does not match input."); + CHECK_THROWS_AS(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); // Invalid, since window extends past the boundary of output tensor. std::vector<unsigned int> wOrigin3 = {0, 0, 15, 0}; armnn::ConcatQueueDescriptor::ViewOrigin window3(wOrigin3); invalidData.m_ViewOrigins[0] = window3; - BOOST_TEST_INFO("Invalid argument exception is expected (wOrigin3[2]+ inputHeight > outputHeight"); - BOOST_CHECK_THROW(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid argument exception is expected (wOrigin3[2]+ inputHeight > outputHeight"); + CHECK_THROWS_AS(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); std::vector<unsigned int> wOrigin4 = {0, 0, 0, 0}; @@ -311,11 +309,11 @@ BOOST_AUTO_TEST_CASE(ConcatQueueDescriptor_Validate_WrongWindow) armnn::ConcatQueueDescriptor::ViewOrigin window5(wOrigin4); invalidData.m_ViewOrigins.push_back(window5); - BOOST_TEST_INFO("Invalid exception due to number of merge windows not matching number of inputs."); - BOOST_CHECK_THROW(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + INFO("Invalid exception due to number of merge windows not matching number of inputs."); + CHECK_THROWS_AS(RefConcatWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(AdditionQueueDescriptor_Validate_InputNumbers) +TEST_CASE("AdditionQueueDescriptor_Validate_InputNumbers") { armnn::TensorInfo input1TensorInfo; armnn::TensorInfo input2TensorInfo; @@ -336,20 +334,20 @@ BOOST_AUTO_TEST_CASE(AdditionQueueDescriptor_Validate_InputNumbers) AddOutputToWorkload(invalidData, invalidInfo, outputTensorInfo, nullptr); // Too few inputs. - BOOST_CHECK_THROW(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); AddInputToWorkload(invalidData, invalidInfo, input2TensorInfo, nullptr); // Correct. - BOOST_CHECK_NO_THROW(RefAdditionWorkload<>(invalidData, invalidInfo)); + CHECK_NOTHROW(RefAdditionWorkload<>(invalidData, invalidInfo)); AddInputToWorkload(invalidData, invalidInfo, input3TensorInfo, nullptr); // Too many inputs. - BOOST_CHECK_THROW(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(AdditionQueueDescriptor_Validate_InputShapes) +TEST_CASE("AdditionQueueDescriptor_Validate_InputShapes") { armnn::TensorInfo input1TensorInfo; armnn::TensorInfo input2TensorInfo; @@ -371,7 +369,7 @@ BOOST_AUTO_TEST_CASE(AdditionQueueDescriptor_Validate_InputShapes) AddInputToWorkload(invalidData, invalidInfo, input2TensorInfo, nullptr); AddOutputToWorkload(invalidData, invalidInfo, outputTensorInfo, nullptr); - BOOST_CHECK_THROW(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); } // Output size not compatible with input sizes. @@ -388,11 +386,11 @@ BOOST_AUTO_TEST_CASE(AdditionQueueDescriptor_Validate_InputShapes) AddOutputToWorkload(invalidData, invalidInfo, outputTensorInfo, nullptr); // Output differs. - BOOST_CHECK_THROW(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefAdditionWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); } } -BOOST_AUTO_TEST_CASE(MultiplicationQueueDescriptor_Validate_InputTensorDimensionMismatch) +TEST_CASE("MultiplicationQueueDescriptor_Validate_InputTensorDimensionMismatch") { armnn::TensorInfo input0TensorInfo; armnn::TensorInfo input1TensorInfo; @@ -423,7 +421,7 @@ BOOST_AUTO_TEST_CASE(MultiplicationQueueDescriptor_Validate_InputTensorDimension AddInputToWorkload(invalidData, invalidInfo, input0TensorInfo, nullptr); AddInputToWorkload(invalidData, invalidInfo, input1TensorInfo, nullptr); - BOOST_CHECK_THROW(RefMultiplicationWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefMultiplicationWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); } // Checks dimension consistency for input and output tensors. @@ -448,11 +446,11 @@ BOOST_AUTO_TEST_CASE(MultiplicationQueueDescriptor_Validate_InputTensorDimension AddInputToWorkload(invalidData, invalidInfo, input0TensorInfo, nullptr); AddInputToWorkload(invalidData, invalidInfo, input1TensorInfo, nullptr); - BOOST_CHECK_THROW(RefMultiplicationWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefMultiplicationWorkload<>(invalidData, invalidInfo), armnn::InvalidArgumentException); } } -BOOST_AUTO_TEST_CASE(ReshapeQueueDescriptor_Validate_MismatchingNumElements) +TEST_CASE("ReshapeQueueDescriptor_Validate_MismatchingNumElements") { armnn::TensorInfo inputTensorInfo; armnn::TensorInfo outputTensorInfo; @@ -471,11 +469,11 @@ BOOST_AUTO_TEST_CASE(ReshapeQueueDescriptor_Validate_MismatchingNumElements) AddOutputToWorkload(invalidData, invalidInfo, outputTensorInfo, nullptr); // InvalidArgumentException is expected, because the number of elements don't match. - BOOST_CHECK_THROW(RefReshapeWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); + CHECK_THROWS_AS(RefReshapeWorkload(invalidData, invalidInfo), armnn::InvalidArgumentException); } -BOOST_AUTO_TEST_CASE(LstmQueueDescriptor_Validate) +TEST_CASE("LstmQueueDescriptor_Validate") { armnn::DataType dataType = armnn::DataType::Float32; @@ -568,61 +566,61 @@ BOOST_AUTO_TEST_CASE(LstmQueueDescriptor_Validate) data.m_Parameters.m_LayerNormEnabled = true; // check wrong number of outputs - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); AddOutputToWorkload(data, info, outputTensorInfo, nullptr); // check wrong cifg parameter configuration data.m_Parameters.m_CifgEnabled = true; armnn::TensorInfo scratchBufferTensorInfo2({batchSize, numUnits * 3}, dataType, qScale, qOffset); SetWorkloadOutput(data, info, 0, scratchBufferTensorInfo2, nullptr); - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_Parameters.m_CifgEnabled = false; SetWorkloadOutput(data, info, 0, scratchBufferTensorInfo, nullptr); // check wrong inputGateBias configuration data.m_InputGateBias = nullptr; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_InputGateBias = &inputGateBiasTensor; // check inconsistant projection parameters data.m_Parameters.m_ProjectionEnabled = false; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_Parameters.m_ProjectionEnabled = true; data.m_ProjectionWeights = nullptr; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_ProjectionWeights = &projectionWeightsTensor; // check missing input layer normalisation weights data.m_InputLayerNormWeights = nullptr; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_InputLayerNormWeights = &inputLayerNormWeightsTensor; // layer norm disabled but normalisation weights are present data.m_Parameters.m_LayerNormEnabled = false; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_Parameters.m_LayerNormEnabled = true; // check invalid outputTensor shape armnn::TensorInfo incorrectOutputTensorInfo({batchSize, outputSize + 1}, dataType, qScale, qOffset); SetWorkloadOutput(data, info, 3, incorrectOutputTensorInfo, nullptr); - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); SetWorkloadOutput(data, info, 3, outputTensorInfo, nullptr); // check invalid cell clipping parameters data.m_Parameters.m_ClippingThresCell = -1.0f; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_Parameters.m_ClippingThresCell = 0.0f; // check invalid projection clipping parameters data.m_Parameters.m_ClippingThresProj = -1.0f; - BOOST_CHECK_THROW(data.Validate(info), armnn::InvalidArgumentException); + CHECK_THROWS_AS(data.Validate(info), armnn::InvalidArgumentException); data.m_Parameters.m_ClippingThresProj = 0.0f; // check correct configuration - BOOST_CHECK_NO_THROW(data.Validate(info)); + CHECK_NOTHROW(data.Validate(info)); } -BOOST_AUTO_TEST_CASE(BiasPerAxisQuantization_Validate) +TEST_CASE("BiasPerAxisQuantization_Validate") { constexpr unsigned int nInput = 1u; constexpr unsigned int cInput = 3u; @@ -667,7 +665,7 @@ BOOST_AUTO_TEST_CASE(BiasPerAxisQuantization_Validate) ScopedTensorHandle biasHandle1(biasInfo1); queueDescriptor.m_Bias = &biasHandle1; - BOOST_CHECK_NO_THROW(queueDescriptor.Validate(workloadInfo)); + CHECK_NOTHROW(queueDescriptor.Validate(workloadInfo)); // Test 2: wrong per-axis quantization values const std::vector<float> biasPerAxisScales2 = { 4.00f, 5.00f }; @@ -676,7 +674,7 @@ BOOST_AUTO_TEST_CASE(BiasPerAxisQuantization_Validate) ScopedTensorHandle biasHandle2(biasInfo2); queueDescriptor.m_Bias = &biasHandle2; - BOOST_CHECK_NO_THROW(queueDescriptor.Validate(workloadInfo)); + CHECK_NOTHROW(queueDescriptor.Validate(workloadInfo)); // Test 3: mismatched number of quantization scales const std::vector<float> biasPerAxisScales3 = { 3.75f, 5.25f, 5.25f }; @@ -685,7 +683,7 @@ BOOST_AUTO_TEST_CASE(BiasPerAxisQuantization_Validate) ScopedTensorHandle biasHandle3(biasInfo3); queueDescriptor.m_Bias = &biasHandle3; - BOOST_CHECK_THROW(queueDescriptor.Validate(workloadInfo), InvalidArgumentException); + CHECK_THROWS_AS(queueDescriptor.Validate(workloadInfo), InvalidArgumentException); } -BOOST_AUTO_TEST_SUITE_END() +} diff --git a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp index 97204750d0..0539cd1470 100644 --- a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp @@ -14,6 +14,8 @@ #include <test/TensorHelpers.hpp> +#include <doctest/doctest.h> + namespace { @@ -69,7 +71,7 @@ LayerTestResult<T, Dim> DebugTestImpl( std::cout.rdbuf(coutStreambuf); - BOOST_TEST(oss.str() == expectedStringOutput); + CHECK(oss.str() == expectedStringOutput); CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); diff --git a/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp index 143f9e06b1..2472c342ea 100644 --- a/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp @@ -18,6 +18,8 @@ #include <test/TensorHelpers.hpp> +#include <doctest/doctest.h> + namespace { @@ -221,25 +223,25 @@ void DetectionPostProcessImpl(const armnn::TensorInfo& boxEncodingsInfo, expectedDetectionBoxes, outputBoxesHandle->GetShape(), detectionBoxesInfo.GetShape()); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); result = CompareTensors(actualDetectionClassesOutput, expectedDetectionClasses, classesHandle->GetShape(), detectionClassesInfo.GetShape()); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); result = CompareTensors(actualDetectionScoresOutput, expectedDetectionScores, outputScoresHandle->GetShape(), detectionScoresInfo.GetShape()); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); result = CompareTensors(actualNumDetectionOutput, expectedNumDetections, numDetectionHandle->GetShape(), numDetectionInfo.GetShape()); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); } template<armnn::DataType QuantizedType, typename RawType = armnn::ResolveType<QuantizedType>> diff --git a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp index 11003a2e97..035c592738 100644 --- a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp @@ -20,6 +20,7 @@ #include <test/TensorHelpers.hpp> +#include <doctest/doctest.h> namespace { @@ -45,11 +46,11 @@ void LstmUtilsVectorBatchVectorAddTestImpl( // check shape and compare values auto result = CompareTensors(batchVec, expectedOutput, expectedShape, expectedShape); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); // check if iterator is back at start position batchVecEncoder->Set(1.0f); - BOOST_TEST(batchVec[0] == 1.0f); + CHECK(batchVec[0] == 1.0f); } template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> @@ -72,11 +73,11 @@ void LstmUtilsZeroVectorTestImpl( // check shape and compare values auto result = CompareTensors(input, expectedOutput, expectedShape, expectedShape); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); // check if iterator is back at start position outputEncoder->Set(1.0f); - BOOST_TEST(input[0] == 1.0f); + CHECK(input[0] == 1.0f); } @@ -100,11 +101,11 @@ void LstmUtilsMeanStddevNormalizationTestImpl( // check shape and compare values auto result = CompareTensors(input, expectedOutput, expectedShape, expectedShape); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); // check if iterator is back at start position outputEncoder->Set(1.0f); - BOOST_TEST(input[0] == 1.0f); + CHECK(input[0] == 1.0f); } template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> @@ -129,11 +130,11 @@ void LstmUtilsVectorBatchVectorCwiseProductTestImpl( // check shape and compare values auto result = CompareTensors(batchVec, expectedOutput, expectedShape, expectedShape); - BOOST_TEST(result.m_Result, result.m_Message.str()); + CHECK_MESSAGE(result.m_Result, result.m_Message.str()); // check if iterator is back at start position batchVecEncoder->Set(1.0f); - BOOST_TEST(batchVec[0] == 1.0f); + CHECK(batchVec[0] == 1.0f); } // Lstm Layer tests: diff --git a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp index cd775729cd..dae7483011 100644 --- a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp @@ -20,7 +20,7 @@ #include <test/TensorHelpers.hpp> -#include <boost/test/unit_test.hpp> +#include <doctest/doctest.h> #include <string> #include <utility> |