From 8234da468e9739a5bd147fa3fb762318c62fcce6 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Wed, 17 Feb 2021 11:01:00 +0000 Subject: IVGCVSW-5734 Building armnn failed in our Backends CI job * CreateTestNetwork() and CreateTransposeTestNetwork should only be defined if Ref enabled; the same as the test its called in otherwise it's defined but not called. Signed-off-by: Francis Murtagh Change-Id: I7bc522a7884d216d1a8e51afd7cec7a66e4e2947 --- .../PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp | 124 ++++++++++----------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp b/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp index b47e3c7296..ab990e7c82 100644 --- a/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp +++ b/src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp @@ -18,37 +18,6 @@ using namespace armnn::optimizations; namespace { -/// Shared function for the below tests, so that we test the same network in both cases. -INetworkPtr CreateTestNetwork() -{ - // Create a network - INetworkPtr network = INetwork::Create(); - - auto input = network->AddInputLayer(0, "input"); - const TensorInfo inputInfo({ 1, 2, 3, 4 }, DataType::Float32); - input->GetOutputSlot(0).SetTensorInfo(inputInfo); - - // Insert Permute which swaps batches and channels dimensions - auto permute = network->AddPermuteLayer(PermuteDescriptor(PermutationVector{ 3, 1, 2, 0 }), "permute"); - const TensorInfo permuteInfo({ 4, 2, 3, 1 }, DataType::Float32); - permute->GetOutputSlot(0).SetTensorInfo(permuteInfo); - input->GetOutputSlot(0).Connect(permute->GetInputSlot(0)); - - // Insert BatchToSpace - BatchToSpaceNdDescriptor batchToSpaceDesc; - batchToSpaceDesc.m_BlockShape = { 2, 2 }; - batchToSpaceDesc.m_DataLayout = DataLayout::NHWC; - auto batchToSpace = network->AddBatchToSpaceNdLayer(batchToSpaceDesc, "batchToSpace"); - const TensorInfo batchToSpaceInfo({ 1, 4, 6, 1 }, DataType::Float32); - batchToSpace->GetOutputSlot(0).SetTensorInfo(batchToSpaceInfo); - permute->GetOutputSlot(0).Connect(batchToSpace->GetInputSlot(0)); - - auto output = network->AddOutputLayer(0, "output"); - batchToSpace->GetOutputSlot(0).Connect(output->GetInputSlot(0)); - - return network; -} - /// Shared function for the below tests, so that we test the same network in both cases. std::unique_ptr CreateTestNetworkImpl() { @@ -79,37 +48,6 @@ std::unique_ptr CreateTestNetworkImpl() return network; } -/// Shared function for the below tests, so that we test the same network in both cases. -INetworkPtr CreateTransposeTestNetwork() -{ - // Create a network - INetworkPtr network = INetwork::Create(); - - auto input = network->AddInputLayer(0, "input"); - const TensorInfo inputInfo({ 1, 2, 3, 4 }, DataType::Float32); - input->GetOutputSlot(0).SetTensorInfo(inputInfo); - - // Insert Permute which swaps batches and channels dimensions - auto permute = network->AddTransposeLayer(TransposeDescriptor(PermutationVector{ 3, 1, 2, 0 }), "permute"); - const TensorInfo permuteInfo({ 4, 2, 3, 1 }, DataType::Float32); - permute->GetOutputSlot(0).SetTensorInfo(permuteInfo); - input->GetOutputSlot(0).Connect(permute->GetInputSlot(0)); - - // Insert BatchToSpace - BatchToSpaceNdDescriptor batchToSpaceDesc; - batchToSpaceDesc.m_BlockShape = { 2, 2 }; - batchToSpaceDesc.m_DataLayout = DataLayout::NHWC; - auto batchToSpace = network->AddBatchToSpaceNdLayer(batchToSpaceDesc, "batchToSpace"); - const TensorInfo batchToSpaceInfo({ 1, 4, 6, 1 }, DataType::Float32); - batchToSpace->GetOutputSlot(0).SetTensorInfo(batchToSpaceInfo); - permute->GetOutputSlot(0).Connect(batchToSpace->GetInputSlot(0)); - - auto output = network->AddOutputLayer(0, "output"); - batchToSpace->GetOutputSlot(0).Connect(output->GetInputSlot(0)); - - return network; -} - /// Shared function for the below tests, so that we test the same network in both cases. std::unique_ptr CreateTransposeTestNetworkImpl() { @@ -206,6 +144,68 @@ BOOST_AUTO_TEST_CASE(TransposeAndBatchToSpaceAsDepthToSpaceOptimizerTest) // This unit test needs the reference backend, it's not available if the reference backend is not built #if defined(ARMNNREF_ENABLED) +/// Shared function for the below tests, so that we test the same network in both cases. +INetworkPtr CreateTestNetwork() +{ + // Create a network + INetworkPtr network = INetwork::Create(); + + auto input = network->AddInputLayer(0, "input"); + const TensorInfo inputInfo({ 1, 2, 3, 4 }, DataType::Float32); + input->GetOutputSlot(0).SetTensorInfo(inputInfo); + + // Insert Permute which swaps batches and channels dimensions + auto permute = network->AddPermuteLayer(PermuteDescriptor(PermutationVector{ 3, 1, 2, 0 }), "permute"); + const TensorInfo permuteInfo({ 4, 2, 3, 1 }, DataType::Float32); + permute->GetOutputSlot(0).SetTensorInfo(permuteInfo); + input->GetOutputSlot(0).Connect(permute->GetInputSlot(0)); + + // Insert BatchToSpace + BatchToSpaceNdDescriptor batchToSpaceDesc; + batchToSpaceDesc.m_BlockShape = { 2, 2 }; + batchToSpaceDesc.m_DataLayout = DataLayout::NHWC; + auto batchToSpace = network->AddBatchToSpaceNdLayer(batchToSpaceDesc, "batchToSpace"); + const TensorInfo batchToSpaceInfo({ 1, 4, 6, 1 }, DataType::Float32); + batchToSpace->GetOutputSlot(0).SetTensorInfo(batchToSpaceInfo); + permute->GetOutputSlot(0).Connect(batchToSpace->GetInputSlot(0)); + + auto output = network->AddOutputLayer(0, "output"); + batchToSpace->GetOutputSlot(0).Connect(output->GetInputSlot(0)); + + return network; +} + +/// Shared function for the below tests, so that we test the same network in both cases. +INetworkPtr CreateTransposeTestNetwork() +{ + // Create a network + INetworkPtr network = INetwork::Create(); + + auto input = network->AddInputLayer(0, "input"); + const TensorInfo inputInfo({ 1, 2, 3, 4 }, DataType::Float32); + input->GetOutputSlot(0).SetTensorInfo(inputInfo); + + // Insert Permute which swaps batches and channels dimensions + auto permute = network->AddTransposeLayer(TransposeDescriptor(PermutationVector{ 3, 1, 2, 0 }), "permute"); + const TensorInfo permuteInfo({ 4, 2, 3, 1 }, DataType::Float32); + permute->GetOutputSlot(0).SetTensorInfo(permuteInfo); + input->GetOutputSlot(0).Connect(permute->GetInputSlot(0)); + + // Insert BatchToSpace + BatchToSpaceNdDescriptor batchToSpaceDesc; + batchToSpaceDesc.m_BlockShape = { 2, 2 }; + batchToSpaceDesc.m_DataLayout = DataLayout::NHWC; + auto batchToSpace = network->AddBatchToSpaceNdLayer(batchToSpaceDesc, "batchToSpace"); + const TensorInfo batchToSpaceInfo({ 1, 4, 6, 1 }, DataType::Float32); + batchToSpace->GetOutputSlot(0).SetTensorInfo(batchToSpaceInfo); + permute->GetOutputSlot(0).Connect(batchToSpace->GetInputSlot(0)); + + auto output = network->AddOutputLayer(0, "output"); + batchToSpace->GetOutputSlot(0).Connect(output->GetInputSlot(0)); + + return network; +} + /// 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) -- cgit v1.2.1