From 1625efc870f1a8b7c6e6382277ddbb245f91a294 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 10 Jun 2021 18:24:34 +0100 Subject: IVGCVSW-5963 'Move unit tests to new framework' * Used doctest in ArmNN unit tests Signed-off-by: Sadik Armagan Change-Id: Ia9cf5fc72775878885c5f864abf2c56b3a935f1a --- .../PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp') diff --git a/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp b/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp index ab990e7c82..e91e16f132 100644 --- a/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp +++ b/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp @@ -8,11 +8,12 @@ #include #include -#include +#include using namespace armnn; -BOOST_AUTO_TEST_SUITE(Optimizer) +TEST_SUITE("Optimizer") +{ using namespace armnn::optimizations; namespace @@ -83,13 +84,13 @@ std::unique_ptr CreateTransposeTestNetworkImpl() /// Tests that the optimization performed by PermuteAndBatchToSpaceAsDepthToSpace is as expected. /// Note this does not ensure the correctness of the optimization - that is done in the below test. -BOOST_AUTO_TEST_CASE(PermuteAndBatchToSpaceAsDepthToSpaceOptimizerTest) +TEST_CASE("PermuteAndBatchToSpaceAsDepthToSpaceOptimizerTest") { std::unique_ptr network = CreateTestNetworkImpl(); Graph graph = network.get()->GetGraph(); // Confirm initial graph is as we expect - BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType, + CHECK(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType, &IsLayerOfType, &IsLayerOfType)); // Perform the optimization which should merge the two layers into a DepthToSpace @@ -103,23 +104,23 @@ BOOST_AUTO_TEST_CASE(PermuteAndBatchToSpaceAsDepthToSpaceOptimizerTest) layer->GetOutputHandler().GetTensorInfo() == TensorInfo({ 1, 4, 6, 1 }, DataType::Float32); }; - BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, checkDepthToSpace, + CHECK(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, checkDepthToSpace, &IsLayerOfType)); // Check the new layer has the two merged layers listed as related layers std::list testRelatedLayers = { "batchToSpace", "permute" }; - BOOST_TEST(CheckRelatedLayers(graph, testRelatedLayers)); + CHECK(CheckRelatedLayers(graph, testRelatedLayers)); } /// Tests that the optimization performed by PermuteAndBatchToSpaceAsDepthToSpace is as expected. /// Note this does not ensure the correctness of the optimization - that is done in the below test. -BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceOptimizerTest) +TEST_CASE("TransposeAndBatchToSpaceAsDepthToSpaceOptimizerTest") { std::unique_ptr network = CreateTransposeTestNetworkImpl(); Graph graph = network.get()->GetGraph(); // Confirm initial graph is as we expect - BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType, + CHECK(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType, &IsLayerOfType, &IsLayerOfType)); // Perform the optimization which should merge the two layers into a DepthToSpace @@ -133,12 +134,12 @@ BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceOptimizerTest) layer->GetOutputHandler().GetTensorInfo() == TensorInfo({ 1, 4, 6, 1 }, DataType::Float32); }; - BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, checkDepthToSpace, + CHECK(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, checkDepthToSpace, &IsLayerOfType)); // Check the new layer has the two merged layers listed as related layers std::list testRelatedLayers = { "batchToSpace", "permute" }; - BOOST_TEST(CheckRelatedLayers(graph, testRelatedLayers)); + CHECK(CheckRelatedLayers(graph, testRelatedLayers)); } // This unit test needs the reference backend, it's not available if the reference backend is not built @@ -208,7 +209,7 @@ INetworkPtr CreateTransposeTestNetwork() /// Tests that a optimization performed by PermuteAndBatchToSpaceAsDepthToSpace does not change the behaviour /// of the network (i.e. it still produces the correct output). -BOOST_AUTO_TEST_CASE(PermuteAndBatchToSpaceAsDepthToSpaceCorrectnessTest) +TEST_CASE("PermuteAndBatchToSpaceAsDepthToSpaceCorrectnessTest") { INetworkPtr network = CreateTestNetwork(); @@ -217,7 +218,7 @@ BOOST_AUTO_TEST_CASE(PermuteAndBatchToSpaceAsDepthToSpaceCorrectnessTest) // Confirm that the optimization has actually taken place const Graph& optGraph = GetGraphForTesting(optimizedNetwork.get()); - BOOST_TEST(CheckSequence(optGraph.cbegin(), optGraph.cend(), &IsLayerOfType, + CHECK(CheckSequence(optGraph.cbegin(), optGraph.cend(), &IsLayerOfType, &IsLayerOfType, &IsLayerOfType)); // Load the graph into a runtime so we can check it produces the correct output @@ -250,12 +251,12 @@ BOOST_AUTO_TEST_CASE(PermuteAndBatchToSpaceAsDepthToSpaceCorrectnessTest) -3.0f, -4.0f, -30.0f, -40.0f, -300.0f, -400.0f, // clang-format on }; - BOOST_TEST(outputData == expectedOutput); + CHECK(outputData == expectedOutput); } /// Tests that a optimization performed by PermuteAndBatchToSpaceAsDepthToSpace does not change the behaviour /// of the network (i.e. it still produces the correct output). -BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceCorrectnessTest) +TEST_CASE("TransposeAndBatchToSpaceAsDepthToSpaceCorrectnessTest") { INetworkPtr network = CreateTransposeTestNetwork(); @@ -264,7 +265,7 @@ BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceCorrectnessTest) // Confirm that the optimization has actually taken place const Graph& optGraph = GetGraphForTesting(optimizedNetwork.get()); - BOOST_TEST(CheckSequence(optGraph.cbegin(), optGraph.cend(), &IsLayerOfType, + CHECK(CheckSequence(optGraph.cbegin(), optGraph.cend(), &IsLayerOfType, &IsLayerOfType, &IsLayerOfType)); // Load the graph into a runtime so we can check it produces the correct output @@ -297,8 +298,8 @@ BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceCorrectnessTest) -3.0f, -4.0f, -30.0f, -40.0f, -300.0f, -400.0f, // clang-format on }; - BOOST_TEST(outputData == expectedOutput); + CHECK(outputData == expectedOutput); } #endif -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +} \ No newline at end of file -- cgit v1.2.1