2 # Copyright © 2017 Arm Ltd. All rights reserved.
3 # SPDX-License-Identifier: MIT
6 list(APPEND armnnBackendsCommonUnitTests_sources
10 BackendRegistryTests.cpp
15 ConvertFp16ToFp32TestImpl.hpp
16 ConvertFp32ToFp16TestImpl.hpp
18 DequantizeTestImpl.hpp
19 DequantizeEndToEndTestImpl.hpp
20 DetectionPostProcessLayerTestImpl.hpp
21 DetectionPostProcessTestImpl.hpp
22 DynamicBackendTests.cpp
23 DynamicBackendTests.hpp
25 FullyConnectedTestImpl.hpp
27 GatherEndToEndTestImpl.hpp
28 IsLayerSupportedTestImpl.hpp
29 JsonPrinterTestImpl.cpp
30 JsonPrinterTestImpl.hpp
31 LayerReleaseConstantDataTest.cpp
40 OptimizeSubgraphViewTests.cpp
41 OptimizationViewsTests.cpp
44 PreluEndToEndTestImpl.hpp
47 QuantizedLstmEndToEndTestImpl.hpp
48 ResizeEndToEndTestImpl.hpp
51 SpaceToDepthTestImpl.hpp
52 SpaceToDepthEndToEndTestImpl.hpp
53 SplitterEndToEndTestImpl.hpp
55 StridedSliceTestImpl.hpp
58 WorkloadFactoryHelper.hpp
63 list(APPEND armnnBackendsCommonUnitTests_sources
64 OptimizedNetworkTests.cpp
65 WorkloadDataValidation.cpp
69 if(ARMCOMPUTENEON AND ARMCOMPUTECL)
70 list(APPEND armnnBackendsCommonUnitTests_sources
71 CompatibilityTests.cpp)
74 add_library(armnnBackendsCommonUnitTests OBJECT ${armnnBackendsCommonUnitTests_sources})
75 target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
76 target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
77 target_include_directories(armnnBackendsCommonUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
79 # Dummy shared object for testing.
80 # This is a simple library used to test the utility functions that will be used to handle the shared objects.
82 list(APPEND testSharedObject_sources
87 add_library_ex(TestSharedObject MODULE ${testSharedObject_sources})
88 set_target_properties(TestSharedObject PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testSharedObject)
89 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/testSharedObject/libNoSharedObject.txt "This is not a shared object")
91 # Dummy dynamic backends for testing.
92 # Both a valid and a number of invalid dummy dynamic backends (covering various use cases) share the
93 # same source code. The various test cases are put together in the code using compiler directives.
95 list(APPEND testDynamicBackend_sources
96 TestDynamicBackend.cpp
97 TestDynamicBackend.hpp
100 add_library_ex(ValidTestDynamicBackend MODULE ${testDynamicBackend_sources})
101 target_compile_definitions(ValidTestDynamicBackend PRIVATE -DVALID_TEST_DYNAMIC_BACKEND_1)
102 target_include_directories(ValidTestDynamicBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
103 target_include_directories(ValidTestDynamicBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
104 target_link_libraries(ValidTestDynamicBackend armnn)
105 set_target_properties(ValidTestDynamicBackend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
107 add_library_ex(InvalidTestDynamicBackend1 MODULE ${testDynamicBackend_sources})
108 target_compile_definitions(InvalidTestDynamicBackend1 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_1)
109 target_include_directories(InvalidTestDynamicBackend1 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
110 target_include_directories(InvalidTestDynamicBackend1 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
111 target_link_libraries(InvalidTestDynamicBackend1 armnn)
112 set_target_properties(InvalidTestDynamicBackend1 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
114 add_library_ex(InvalidTestDynamicBackend2 MODULE ${testDynamicBackend_sources})
115 target_compile_definitions(InvalidTestDynamicBackend2 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_2)
116 target_include_directories(InvalidTestDynamicBackend2 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
117 target_include_directories(InvalidTestDynamicBackend2 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
118 target_link_libraries(InvalidTestDynamicBackend2 armnn)
119 set_target_properties(InvalidTestDynamicBackend2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
121 add_library_ex(InvalidTestDynamicBackend3 MODULE ${testDynamicBackend_sources})
122 target_compile_definitions(InvalidTestDynamicBackend3 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_3)
123 target_include_directories(InvalidTestDynamicBackend3 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
124 target_include_directories(InvalidTestDynamicBackend3 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
125 target_link_libraries(InvalidTestDynamicBackend3 armnn)
126 set_target_properties(InvalidTestDynamicBackend3 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
128 add_library_ex(InvalidTestDynamicBackend4 MODULE ${testDynamicBackend_sources})
129 target_compile_definitions(InvalidTestDynamicBackend4 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_4)
130 target_include_directories(InvalidTestDynamicBackend4 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
131 target_include_directories(InvalidTestDynamicBackend4 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
132 target_link_libraries(InvalidTestDynamicBackend4 armnn)
133 set_target_properties(InvalidTestDynamicBackend4 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
135 add_library_ex(InvalidTestDynamicBackend5 MODULE ${testDynamicBackend_sources})
136 target_compile_definitions(InvalidTestDynamicBackend5 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_5)
137 target_include_directories(InvalidTestDynamicBackend5 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
138 target_include_directories(InvalidTestDynamicBackend5 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
139 target_link_libraries(InvalidTestDynamicBackend5 armnn)
140 set_target_properties(InvalidTestDynamicBackend5 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
142 add_library_ex(InvalidTestDynamicBackend6 MODULE ${testDynamicBackend_sources})
143 target_compile_definitions(InvalidTestDynamicBackend6 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_6)
144 target_include_directories(InvalidTestDynamicBackend6 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
145 target_include_directories(InvalidTestDynamicBackend6 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
146 target_link_libraries(InvalidTestDynamicBackend6 armnn)
147 set_target_properties(InvalidTestDynamicBackend6 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
149 add_library_ex(InvalidTestDynamicBackend7 MODULE ${testDynamicBackend_sources})
150 target_compile_definitions(InvalidTestDynamicBackend7 PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_7)
151 target_include_directories(InvalidTestDynamicBackend7 PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
152 target_include_directories(InvalidTestDynamicBackend7 PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
153 target_link_libraries(InvalidTestDynamicBackend7 armnn)
154 set_target_properties(InvalidTestDynamicBackend7 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDynamicBackend)
156 # Dummy files and directories for testing the dynamic backend file parsing.
158 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so "Test file for dynamic backend file parsing")
159 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.1 "Test file for dynamic backend file parsing")
160 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.1.2 "Test file for dynamic backend file parsing")
161 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.1.2.3 "Test file for dynamic backend file parsing")
162 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.10.1.27 "Test file for dynamic backend file parsing")
163 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.10.1.33. "Test file for dynamic backend file parsing")
164 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.3.4..5 "Test file for dynamic backend file parsing")
165 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend.so.1,1.1 "Test file for dynamic backend file parsing")
167 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm123_GpuAcc_backend.so "Test file for dynamic backend file parsing")
168 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc456_backend.so "Test file for dynamic backend file parsing")
169 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm%Co_GpuAcc_backend.so "Test file for dynamic backend file parsing")
170 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_Gpu.Acc_backend.so "Test file for dynamic backend file parsing")
172 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/GpuAcc_backend.so "Test file for dynamic backend file parsing")
173 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/_GpuAcc_backend.so "Test file for dynamic backend file parsing")
174 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm__backend.so "Test file for dynamic backend file parsing")
175 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc.so "Test file for dynamic backend file parsing")
176 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/__backend.so "Test file for dynamic backend file parsing")
177 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/__.so "Test file for dynamic backend file parsing")
179 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend "Test file for dynamic backend file parsing")
180 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath1/Arm_GpuAcc_backend_v1.2.so "Test file for dynamic backend file parsing")
182 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath2/Arm_CpuAcc_backend.so "Test file for dynamic backend file parsing")
183 add_custom_target(link_dummy_dynamic_backend ALL
184 COMMAND ${CMAKE_COMMAND} -E create_symlink Arm_CpuAcc_backend.so backendsTestPath2/Arm_CpuAcc_backend.so.1
185 COMMAND ${CMAKE_COMMAND} -E create_symlink Arm_CpuAcc_backend.so.1 backendsTestPath2/Arm_CpuAcc_backend.so.1.2
186 COMMAND ${CMAKE_COMMAND} -E create_symlink Arm_CpuAcc_backend.so.1.2 backendsTestPath2/Arm_CpuAcc_backend.so.1.2.3
187 COMMAND ${CMAKE_COMMAND} -E create_symlink nothing backendsTestPath2/Arm_no_backend.so)
188 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath2/Arm_GpuAcc_backend.so "Test file for dynamic backend file parsing")
190 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath3)
192 # Dummy dynamic backends for testing.
193 # These shared objects are used to test the creation of dynamic backend instances in ArmNN.
195 add_library_ex(Arm_TestValid2_backend MODULE ${testDynamicBackend_sources})
196 target_compile_definitions(Arm_TestValid2_backend PRIVATE -DVALID_TEST_DYNAMIC_BACKEND_2)
197 target_include_directories(Arm_TestValid2_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
198 target_include_directories(Arm_TestValid2_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
199 target_link_libraries(Arm_TestValid2_backend armnn)
200 set_target_properties(Arm_TestValid2_backend PROPERTIES PREFIX "")
201 set_target_properties(Arm_TestValid2_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath5)
202 add_custom_command(TARGET Arm_TestValid2_backend POST_BUILD
203 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Arm_TestValid2_backend> ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath6)
205 add_library_ex(Arm_TestValid3_backend MODULE ${testDynamicBackend_sources})
206 target_compile_definitions(Arm_TestValid3_backend PRIVATE -DVALID_TEST_DYNAMIC_BACKEND_3)
207 target_include_directories(Arm_TestValid3_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
208 target_include_directories(Arm_TestValid3_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
209 target_link_libraries(Arm_TestValid3_backend armnn)
210 set_target_properties(Arm_TestValid3_backend PROPERTIES PREFIX "")
211 set_target_properties(Arm_TestValid3_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath5)
213 add_library_ex(Arm_TestInvalid8_backend MODULE ${testDynamicBackend_sources})
214 target_compile_definitions(Arm_TestInvalid8_backend PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_8)
215 target_include_directories(Arm_TestInvalid8_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
216 target_include_directories(Arm_TestInvalid8_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
217 target_link_libraries(Arm_TestInvalid8_backend armnn)
218 set_target_properties(Arm_TestInvalid8_backend PROPERTIES PREFIX "")
219 set_target_properties(Arm_TestInvalid8_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath5)
221 add_library_ex(Arm_TestValid4_backend MODULE ${testDynamicBackend_sources})
222 target_compile_definitions(Arm_TestValid4_backend PRIVATE -DVALID_TEST_DYNAMIC_BACKEND_4)
223 target_include_directories(Arm_TestValid4_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
224 target_include_directories(Arm_TestValid4_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
225 target_link_libraries(Arm_TestValid4_backend armnn)
226 set_target_properties(Arm_TestValid4_backend PROPERTIES PREFIX "")
227 set_target_properties(Arm_TestValid4_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath6)
229 add_library_ex(Arm_TestValid5_backend MODULE ${testDynamicBackend_sources})
230 target_compile_definitions(Arm_TestValid5_backend PRIVATE -DVALID_TEST_DYNAMIC_BACKEND_5)
231 target_include_directories(Arm_TestValid5_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
232 target_include_directories(Arm_TestValid5_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
233 target_link_libraries(Arm_TestValid5_backend armnn)
234 set_target_properties(Arm_TestValid5_backend PROPERTIES PREFIX "")
235 set_target_properties(Arm_TestValid5_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath6)
237 add_library_ex(Arm_TestInvalid9_backend MODULE ${testDynamicBackend_sources})
238 target_compile_definitions(Arm_TestInvalid9_backend PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_9)
239 target_include_directories(Arm_TestInvalid9_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
240 target_include_directories(Arm_TestInvalid9_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
241 target_link_libraries(Arm_TestInvalid9_backend armnn)
242 set_target_properties(Arm_TestInvalid9_backend PROPERTIES PREFIX "")
243 set_target_properties(Arm_TestInvalid9_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath6)
245 add_library_ex(Arm_TestInvalid10_backend MODULE ${testDynamicBackend_sources})
246 target_compile_definitions(Arm_TestInvalid10_backend PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_10)
247 target_include_directories(Arm_TestInvalid10_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
248 target_include_directories(Arm_TestInvalid10_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
249 target_link_libraries(Arm_TestInvalid10_backend armnn)
250 set_target_properties(Arm_TestInvalid10_backend PROPERTIES PREFIX "")
251 set_target_properties(Arm_TestInvalid10_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath9)
253 add_library_ex(Arm_TestInvalid11_backend MODULE ${testDynamicBackend_sources})
254 target_compile_definitions(Arm_TestInvalid11_backend PRIVATE -DINVALID_TEST_DYNAMIC_BACKEND_11)
255 target_include_directories(Arm_TestInvalid11_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn)
256 target_include_directories(Arm_TestInvalid11_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends)
257 target_link_libraries(Arm_TestInvalid11_backend armnn)
258 set_target_properties(Arm_TestInvalid11_backend PROPERTIES PREFIX "")
259 set_target_properties(Arm_TestInvalid11_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath9)
261 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backendsTestPath7)