Release 18.05.01
[platform/upstream/armnn.git] / tests / CMakeLists.txt
1 # UnitTests
2 include(CheckIncludeFiles)
3
4 include_directories(SYSTEM "${THIRD_PARTY_INCLUDE_DIRS}")
5
6 # Setup the inference test framework
7 set(inference_test_sources
8     ClassifierTestCaseData.hpp
9     InferenceModel.hpp
10     InferenceTest.hpp
11     InferenceTest.inl
12     InferenceTest.cpp
13     InferenceTestImage.hpp
14     InferenceTestImage.cpp)
15 add_library_ex(inferenceTest STATIC ${inference_test_sources})
16 target_include_directories(inferenceTest PRIVATE ../src/armnnUtils)
17
18 if(BUILD_CAFFE_PARSER)
19     macro(CaffeParserTest testName sources)
20         add_executable_ex(${testName} ${sources})
21         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
22         set_target_properties(${testName} PROPERTIES COMPILE_FLAGS "${CAFFE_PARSER_TEST_ADDITIONAL_COMPILE_FLAGS}")
23
24         target_link_libraries(${testName} inferenceTest)
25         target_link_libraries(${testName} armnnCaffeParser)
26         target_link_libraries(${testName} armnn)
27         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
28         if(OPENCL_LIBRARIES)
29             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
30         endif()
31         target_link_libraries(${testName}
32             ${Boost_SYSTEM_LIBRARY}
33             ${Boost_FILESYSTEM_LIBRARY}
34             ${Boost_PROGRAM_OPTIONS_LIBRARY})
35         addDllCopyCommands(${testName})
36     endmacro()
37
38     set(CaffeCifar10AcrossChannels-Armnn_sources
39         CaffeCifar10AcrossChannels-Armnn/CaffeCifar10AcrossChannels-Armnn.cpp
40         Cifar10Database.hpp
41         Cifar10Database.cpp)
42     CaffeParserTest(CaffeCifar10AcrossChannels-Armnn "${CaffeCifar10AcrossChannels-Armnn_sources}")
43
44     set(CaffeMnist-Armnn_sources
45         CaffeMnist-Armnn/CaffeMnist-Armnn.cpp
46         MnistDatabase.hpp
47         MnistDatabase.cpp)
48     CaffeParserTest(CaffeMnist-Armnn "${CaffeMnist-Armnn_sources}")
49
50     set(CaffeAlexNet-Armnn_sources
51         CaffeAlexNet-Armnn/CaffeAlexNet-Armnn.cpp
52         ImageNetDatabase.hpp
53         ImageNetDatabase.cpp)
54     CaffeParserTest(CaffeAlexNet-Armnn "${CaffeAlexNet-Armnn_sources}")
55
56     set(MultipleNetworksCifar10_SRC
57         MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
58         Cifar10Database.hpp
59         Cifar10Database.cpp)
60     CaffeParserTest(MultipleNetworksCifar10 "${MultipleNetworksCifar10_SRC}")
61
62     set(CaffeResNet-Armnn_sources
63         CaffeResNet-Armnn/CaffeResNet-Armnn.cpp
64         ImageNetDatabase.hpp
65         ImageNetDatabase.cpp)
66     CaffeParserTest(CaffeResNet-Armnn "${CaffeResNet-Armnn_sources}")
67
68     set(CaffeVGG-Armnn_sources
69         CaffeVGG-Armnn/CaffeVGG-Armnn.cpp
70         ImageNetDatabase.hpp
71         ImageNetDatabase.cpp)
72     CaffeParserTest(CaffeVGG-Armnn "${CaffeVGG-Armnn_sources}")
73
74     set(CaffeInception_BN-Armnn_sources
75         CaffeInception_BN-Armnn/CaffeInception_BN-Armnn.cpp
76         ImageNetDatabase.hpp
77         ImageNetDatabase.cpp)
78     CaffeParserTest(CaffeInception_BN-Armnn "${CaffeInception_BN-Armnn_sources}")
79
80     set(CaffeYolo-Armnn_sources
81         CaffeYolo-Armnn/CaffeYolo-Armnn.cpp
82         YoloDatabase.hpp
83         YoloDatabase.cpp
84         YoloInferenceTest.hpp)
85     CaffeParserTest(CaffeYolo-Armnn "${CaffeYolo-Armnn_sources}")
86 endif()
87
88 if(BUILD_TF_PARSER)
89     macro(TfParserTest testName sources)
90         add_executable_ex(${testName} ${sources})
91         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
92
93         target_link_libraries(${testName} inferenceTest)
94         target_link_libraries(${testName} armnnTfParser)
95         target_link_libraries(${testName} armnn)
96         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
97         if(OPENCL_LIBRARIES)
98             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
99         endif()
100         target_link_libraries(${testName}
101             ${Boost_SYSTEM_LIBRARY}
102             ${Boost_FILESYSTEM_LIBRARY}
103             ${Boost_PROGRAM_OPTIONS_LIBRARY})
104         addDllCopyCommands(${testName})
105     endmacro()
106
107     set(TfMnist-Armnn_sources
108         TfMnist-Armnn/TfMnist-Armnn.cpp
109         MnistDatabase.hpp
110         MnistDatabase.cpp)
111     TfParserTest(TfMnist-Armnn "${TfMnist-Armnn_sources}")
112
113     set(TfCifar10-Armnn_sources
114         TfCifar10-Armnn/TfCifar10-Armnn.cpp
115         Cifar10Database.hpp
116         Cifar10Database.cpp)
117     TfParserTest(TfCifar10-Armnn "${TfCifar10-Armnn_sources}")
118
119     set(TfMobileNet-Armnn_sources
120         TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
121         MobileNetDatabase.hpp
122         MobileNetDatabase.cpp)
123     TfParserTest(TfMobileNet-Armnn "${TfMobileNet-Armnn_sources}")
124
125     set(TfInceptionV3-Armnn_sources
126         TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
127         MobileNetDatabase.hpp
128         MobileNetDatabase.cpp)
129     TfParserTest(TfInceptionV3-Armnn "${TfInceptionV3-Armnn_sources}")
130
131     set(TfResNext-Armnn_sources
132         TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
133         ImageNetDatabase.hpp
134         ImageNetDatabase.cpp)
135     TfParserTest(TfResNext-Armnn "${TfResNext-Armnn_sources}")
136 endif()
137
138 if (BUILD_CAFFE_PARSER OR BUILD_TF_PARSER)
139     set(ExecuteNetwork_sources
140         ExecuteNetwork/ExecuteNetwork.cpp)
141
142     add_executable_ex(ExecuteNetwork ${ExecuteNetwork_sources})
143     target_include_directories(ExecuteNetwork PRIVATE ../src/armnnUtils)
144
145     if (BUILD_CAFFE_PARSER)
146         target_link_libraries(ExecuteNetwork armnnCaffeParser)
147     endif()
148     if (BUILD_TF_PARSER)
149         target_link_libraries(ExecuteNetwork armnnTfParser)
150     endif()
151     target_link_libraries(ExecuteNetwork armnn)
152     target_link_libraries(ExecuteNetwork ${CMAKE_THREAD_LIBS_INIT})
153     if(OPENCL_LIBRARIES)
154         target_link_libraries(ExecuteNetwork ${OPENCL_LIBRARIES})
155     endif()
156     target_link_libraries(ExecuteNetwork
157         ${Boost_SYSTEM_LIBRARY}
158         ${Boost_FILESYSTEM_LIBRARY}
159         ${Boost_PROGRAM_OPTIONS_LIBRARY})
160     addDllCopyCommands(ExecuteNetwork)
161 endif()