IVGCVSW-2022 : fix for backend cmake files to respect BUILD_UNIT_TESTS variable
authorDavid Beck <david.beck@arm.com>
Tue, 16 Oct 2018 11:58:49 +0000 (12:58 +0100)
committerMatthew Bentham <matthew.bentham@arm.com>
Mon, 22 Oct 2018 15:57:54 +0000 (16:57 +0100)
Change-Id: I8d34419742152edd50f1ec438e32d3ccc4f38351

12 files changed:
src/backends/aclCommon/CMakeLists.txt
src/backends/aclCommon/test/CMakeLists.txt
src/backends/aclCommon/test/MemCopyTestImpl.hpp [new file with mode: 0644]
src/backends/aclCommon/test/MemCopyTests.cpp
src/backends/cl/CMakeLists.txt
src/backends/cl/backend.cmake
src/backends/cl/test/ClMemCopyTests.cpp
src/backends/neon/CMakeLists.txt
src/backends/neon/backend.cmake
src/backends/neon/test/NeonMemCopyTests.cpp
src/backends/reference/CMakeLists.txt
src/backends/test/MemCopyTestImpl.hpp [deleted file]

index 2bfd024e106b68a020b68cc3cb2ee96359e8b0cd..9282e1056aa9607188fde248fccf1a1ab6fde784 100644 (file)
@@ -23,7 +23,9 @@ list(APPEND armnnAclCommon_sources
     memory/PoolManager.hpp
 )
 
-add_subdirectory(test)
+if(BUILD_UNIT_TESTS)
+    add_subdirectory(test)
+endif()
 
 add_library(armnnAclCommon OBJECT ${armnnAclCommon_sources})
 target_include_directories(armnnAclCommon PRIVATE ${PROJECT_SOURCE_DIR}/src)
index 98008edeb57c4dada5b15f8b1f9bc4c10c0984bb..43782769618bbaadfa79139ee95a823e336023e7 100644 (file)
@@ -6,9 +6,10 @@
 list(APPEND armnnAclCommonUnitTests_sources
     CreateWorkloadClNeon.hpp
     MemCopyTests.cpp
+    MemCopyTestImpl.hpp
 )
 
 add_library(armnnAclCommonUnitTests OBJECT ${armnnAclCommonUnitTests_sources})
 target_include_directories(armnnAclCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src)
 target_include_directories(armnnAclCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
-target_include_directories(armnnAclCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
\ No newline at end of file
+target_include_directories(armnnAclCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
diff --git a/src/backends/aclCommon/test/MemCopyTestImpl.hpp b/src/backends/aclCommon/test/MemCopyTestImpl.hpp
new file mode 100644 (file)
index 0000000..322cb07
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <backends/test/LayerTests.hpp>
+#include <backends/test/TensorCopyUtils.hpp>
+#include <backends/test/WorkloadTestUtils.hpp>
+
+#include <armnn/test/TensorHelpers.hpp>
+
+#include <boost/multi_array.hpp>
+
+namespace
+{
+
+LayerTestResult<float, 4> MemCopyTest(armnn::IWorkloadFactory& srcWorkloadFactory,
+                                      armnn::IWorkloadFactory& dstWorkloadFactory,
+                                      bool withSubtensors)
+{
+    const std::array<unsigned int, 4> shapeData = { { 1u, 1u, 6u, 5u } };
+    const armnn::TensorShape tensorShape(4, shapeData.data());
+    const armnn::TensorInfo tensorInfo(tensorShape, armnn::DataType::Float32);
+    boost::multi_array<float, 4> inputData = MakeTensor<float, 4>(tensorInfo, std::vector<float>(
+        {
+            1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
+
+            6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
+
+            11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
+
+            16.0f, 17.0f, 18.0f, 19.0f, 20.0f,
+
+            21.0f, 22.0f, 23.0f, 24.0f, 25.0f,
+
+            26.0f, 27.0f, 28.0f, 29.0f, 30.0f,
+        })
+    );
+
+    LayerTestResult<float, 4> ret(tensorInfo);
+    ret.outputExpected = inputData;
+
+    boost::multi_array<float, 4> outputData(shapeData);
+
+    auto inputTensorHandle = srcWorkloadFactory.CreateTensorHandle(tensorInfo);
+    auto outputTensorHandle = dstWorkloadFactory.CreateTensorHandle(tensorInfo);
+
+    AllocateAndCopyDataToITensorHandle(inputTensorHandle.get(), inputData.data());
+    outputTensorHandle->Allocate();
+
+    armnn::MemCopyQueueDescriptor memCopyQueueDesc;
+    armnn::WorkloadInfo workloadInfo;
+
+    const unsigned int origin[4] = {};
+
+    auto workloadInput = (withSubtensors && srcWorkloadFactory.SupportsSubTensors())
+                         ? srcWorkloadFactory.CreateSubTensorHandle(*inputTensorHandle, tensorShape, origin)
+                         : std::move(inputTensorHandle);
+    auto workloadOutput = (withSubtensors && dstWorkloadFactory.SupportsSubTensors())
+                          ? dstWorkloadFactory.CreateSubTensorHandle(*outputTensorHandle, tensorShape, origin)
+                          : std::move(outputTensorHandle);
+
+    AddInputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadInput.get());
+    AddOutputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadOutput.get());
+
+    dstWorkloadFactory.CreateMemCopy(memCopyQueueDesc, workloadInfo)->Execute();
+
+    CopyDataFromITensorHandle(outputData.data(), workloadOutput.get());
+    ret.output = outputData;
+
+    return ret;
+}
+
+template<typename SrcWorkloadFactory, typename DstWorkloadFactory>
+LayerTestResult<float, 4> MemCopyTest(bool withSubtensors)
+{
+    SrcWorkloadFactory srcWorkloadFactory;
+    DstWorkloadFactory dstWorkloadFactory;
+
+    return MemCopyTest(srcWorkloadFactory, dstWorkloadFactory, withSubtensors);
+}
+
+} // anonymous namespace
index 8ecdb1014d928565d563ce0a4b9e9ce792141d60..7e503b1cdb75a2b75db03188e4cc9c13a60b28bc 100644 (file)
@@ -6,7 +6,10 @@
 #include <backends/aclCommon/ArmComputeTensorUtils.hpp>
 #include <backends/cl/ClWorkloadFactory.hpp>
 #include <backends/neon/NeonWorkloadFactory.hpp>
-#include <backends/test/MemCopyTestImpl.hpp>
+
+#if ARMCOMPUTECL_ENABLED && ARMCOMPUTENEON_ENABLED
+#include <backends/aclCommon/test/MemCopyTestImpl.hpp>
+#endif
 
 #include <boost/test/unit_test.hpp>
 
index 5704e0e8ab6706e6d10299011b8087c44e1568d6..d38fb68a0f0bdd00c7f2d9fe6ab779aec8a1a958 100644 (file)
@@ -21,7 +21,10 @@ if(ARMCOMPUTECL)
     )
 
     add_subdirectory(workloads)
-    add_subdirectory(test)
+
+    if(BUILD_UNIT_TESTS)
+        add_subdirectory(test)
+    endif()
 endif()
 
 add_library(armnnClBackend OBJECT ${armnnClBackend_sources})
index f8a1c1c62a329a4bb4693e9c238fde1a2d3f3d4e..eb621473355e545d1c10b2239ba6ef7fe31c8bf2 100644 (file)
@@ -3,12 +3,12 @@
 # SPDX-License-Identifier: MIT
 #
 
+add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/cl)
+list(APPEND armnnLibraries armnnClBackend)
+
 if(ARMCOMPUTECL)
-    add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/cl)
-    list(APPEND armnnLibraries armnnClBackend armnnClBackendWorkloads)
+    list(APPEND armnnLibraries armnnClBackendWorkloads)
     list(APPEND armnnUnitTestLibraries armnnClBackendUnitTests)
 else()
     message("CL backend is disabled")
-    add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/cl)
-    list(APPEND armnnLibraries armnnClBackend)
 endif()
index af8a36d6c0786117820bfe6bf0fda0d0f064a896..2635495e46a7e2c8bc49fd3f70a9cb1c68cbe17b 100644 (file)
@@ -5,8 +5,7 @@
 
 #include <backends/cl/ClWorkloadFactory.hpp>
 #include <backends/reference/RefWorkloadFactory.hpp>
-
-#include <backends/test/MemCopyTestImpl.hpp>
+#include <backends/aclCommon/test/MemCopyTestImpl.hpp>
 
 #include <boost/test/unit_test.hpp>
 
index c44dcc10759adbed15ab9dfea8b8696d241b5bf4..e294ff731959656ca4e6859e642ff9f27ac885a7 100644 (file)
@@ -19,7 +19,11 @@ if(ARMCOMPUTENEON)
     )
 
     add_subdirectory(workloads)
-    add_subdirectory(test)
+
+    if(BUILD_UNIT_TESTS)
+        add_subdirectory(test)
+    endif()
+
 else()
     list(APPEND armnnNeonBackend_sources
         NeonLayerSupport.cpp
index 0240d527b3b6527fbd30ea2619ca8e487f7651af..c8ff4880b0d1984c671675eee4581d4610a9a47c 100644 (file)
@@ -3,12 +3,12 @@
 # SPDX-License-Identifier: MIT
 #
 
+add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/neon)
+list(APPEND armnnLibraries armnnNeonBackend)
+
 if(ARMCOMPUTENEON)
-    add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/neon)
-    list(APPEND armnnLibraries armnnNeonBackend armnnNeonBackendWorkloads)
+    list(APPEND armnnLibraries armnnNeonBackendWorkloads)
     list(APPEND armnnUnitTestLibraries armnnNeonBackendUnitTests)
 else()
     message("NEON backend is disabled")
-    add_subdirectory(${PROJECT_SOURCE_DIR}/src/backends/neon)
-    list(APPEND armnnLibraries armnnNeonBackend)
 endif()
index ddb47343a1c30d68b36e16fb73785a2d1027704b..2b96d7c578359b3d1949ba60e4dc5cb107e9e3fe 100644 (file)
@@ -5,8 +5,7 @@
 
 #include <backends/neon/NeonWorkloadFactory.hpp>
 #include <backends/reference/RefWorkloadFactory.hpp>
-
-#include <backends/test/MemCopyTestImpl.hpp>
+#include <backends/aclCommon/test/MemCopyTestImpl.hpp>
 
 #include <boost/test/unit_test.hpp>
 
index 05ef7d5a8fe17a9bea36b7d254e2b3a5b2314165..a0d27cc38768b95c13df1278f2fe610c989e77b7 100644 (file)
@@ -18,4 +18,7 @@ target_include_directories(armnnRefBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/arm
 target_include_directories(armnnRefBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
 
 add_subdirectory(workloads)
-add_subdirectory(test)
+
+if(BUILD_UNIT_TESTS)
+    add_subdirectory(test)
+endif()
diff --git a/src/backends/test/MemCopyTestImpl.hpp b/src/backends/test/MemCopyTestImpl.hpp
deleted file mode 100644 (file)
index dab7f47..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#pragma once
-
-#include "LayerTests.hpp"
-#include "TensorCopyUtils.hpp"
-#include "WorkloadTestUtils.hpp"
-
-#include <armnn/test/TensorHelpers.hpp>
-
-#include <boost/multi_array.hpp>
-
-namespace
-{
-
-LayerTestResult<float, 4> MemCopyTest(armnn::IWorkloadFactory& srcWorkloadFactory,
-                                      armnn::IWorkloadFactory& dstWorkloadFactory,
-                                      bool withSubtensors)
-{
-    const std::array<unsigned int, 4> shapeData = { { 1u, 1u, 6u, 5u } };
-    const armnn::TensorShape tensorShape(4, shapeData.data());
-    const armnn::TensorInfo tensorInfo(tensorShape, armnn::DataType::Float32);
-    boost::multi_array<float, 4> inputData = MakeTensor<float, 4>(tensorInfo, std::vector<float>(
-        {
-            1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
-
-            6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
-
-            11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
-
-            16.0f, 17.0f, 18.0f, 19.0f, 20.0f,
-
-            21.0f, 22.0f, 23.0f, 24.0f, 25.0f,
-
-            26.0f, 27.0f, 28.0f, 29.0f, 30.0f,
-        })
-    );
-
-    LayerTestResult<float, 4> ret(tensorInfo);
-    ret.outputExpected = inputData;
-
-    boost::multi_array<float, 4> outputData(shapeData);
-
-    auto inputTensorHandle = srcWorkloadFactory.CreateTensorHandle(tensorInfo);
-    auto outputTensorHandle = dstWorkloadFactory.CreateTensorHandle(tensorInfo);
-
-    AllocateAndCopyDataToITensorHandle(inputTensorHandle.get(), inputData.data());
-    outputTensorHandle->Allocate();
-
-    armnn::MemCopyQueueDescriptor memCopyQueueDesc;
-    armnn::WorkloadInfo workloadInfo;
-
-    const unsigned int origin[4] = {};
-
-    auto workloadInput = (withSubtensors && srcWorkloadFactory.SupportsSubTensors())
-                         ? srcWorkloadFactory.CreateSubTensorHandle(*inputTensorHandle, tensorShape, origin)
-                         : std::move(inputTensorHandle);
-    auto workloadOutput = (withSubtensors && dstWorkloadFactory.SupportsSubTensors())
-                          ? dstWorkloadFactory.CreateSubTensorHandle(*outputTensorHandle, tensorShape, origin)
-                          : std::move(outputTensorHandle);
-
-    AddInputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadInput.get());
-    AddOutputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadOutput.get());
-
-    dstWorkloadFactory.CreateMemCopy(memCopyQueueDesc, workloadInfo)->Execute();
-
-    CopyDataFromITensorHandle(outputData.data(), workloadOutput.get());
-    ret.output = outputData;
-
-    return ret;
-}
-
-template<typename SrcWorkloadFactory, typename DstWorkloadFactory>
-LayerTestResult<float, 4> MemCopyTest(bool withSubtensors)
-{
-    SrcWorkloadFactory srcWorkloadFactory;
-    DstWorkloadFactory dstWorkloadFactory;
-
-    return MemCopyTest(srcWorkloadFactory, dstWorkloadFactory, withSubtensors);
-}
-
-} // anonymous namespace