IVGCVSW-3634 Segmentation fault running UnitTests on Android
[platform/upstream/armnn.git] / Android.mk
1 #
2 # Copyright © 2017 ARM Ltd. All rights reserved.
3 # SPDX-License-Identifier: MIT
4 #
5
6 LOCAL_PATH := $(call my-dir)
7
8 # Configure these paths if you move the source or Khronos headers
9 #
10 OPENCL_HEADER_PATH := $(LOCAL_PATH)/../clframework/include
11 NN_HEADER_PATH := $(LOCAL_PATH)/../../../../frameworks/ml/nn/runtime/include
12 ARMNN_HEADER_PATH := $(LOCAL_PATH)/include
13 ARMNN_MAIN_HEADER_PATH := $(LOCAL_PATH)/src
14 ARMNN_SOURCE_HEADER_PATH := $(LOCAL_PATH)/src/armnn
15 ARMNN_SOURCE_UTILS_HEADER_PATH := $(LOCAL_PATH)/src/armnnUtils
16 ARMNN_BACKENDS_HEADER_PATH := $(LOCAL_PATH)/src/backends
17
18 # find the common.mk and backend.mk files in the backend source folders
19 ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/common.mk)
20 ARMNN_BACKEND_COMMON_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS))
21 ARMNN_BACKEND_COMMON_MAKEFILE_DIRS := $(subst /common.mk,,$(ARMNN_BACKEND_COMMON_MAKEFILE_PATHS))
22
23 ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/backend.mk)
24 ARMNN_BACKEND_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS))
25 ARMNN_BACKEND_MAKEFILE_DIRS := $(subst /backend.mk,,$(ARMNN_BACKEND_MAKEFILE_PATHS))
26
27 ##############
28 # libarmnn.a #
29 ##############
30 include $(CLEAR_VARS)
31
32 LOCAL_MODULE := libarmnn
33 ifeq ($(Q_OR_LATER),1)
34 # "eng" is deprecated in Android Q
35 LOCAL_MODULE_TAGS := optional
36 else
37 LOCAL_MODULE_TAGS := eng optional
38 endif
39 LOCAL_ARM_MODE := arm
40 LOCAL_PROPRIETARY_MODULE := true
41
42 # placeholder to hold all backend source files, common and specific to the backends
43 ARMNN_BACKEND_SOURCES :=
44
45 #
46 # iterate through the backend common and specific include paths, include them into the
47 # current makefile and append the sources held by the COMMON_SOURCES and BACKEND_SOURCES variable
48 # (included from the given makefile) to the ARMNN_BACKEND_SOURCES list
49 #
50 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS),\
51         $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk)\
52         $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES) $(patsubst %,$(mkPath)/%,$(COMMON_SOURCES))))
53
54 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS),\
55         $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk)\
56         $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES) $(patsubst %,$(mkPath)/%,$(BACKEND_SOURCES))))
57
58 # Mark source files as dependent on Android.mk and backend makefiles
59 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk \
60                                  $(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS)
61
62 LOCAL_EXPORT_C_INCLUDES := \
63         $(ARMNN_MAIN_HEADER_PATH) \
64         $(ARMNN_SOURCE_HEADER_PATH) \
65         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
66         $(ARMNN_BACKENDS_HEADER_PATH)
67
68 LOCAL_C_INCLUDES := \
69         $(OPENCL_HEADER_PATH) \
70         $(NN_HEADER_PATH) \
71         $(ARMNN_HEADER_PATH) \
72         $(ARMNN_MAIN_HEADER_PATH) \
73         $(ARMNN_SOURCE_HEADER_PATH) \
74         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
75         $(ARMNN_BACKENDS_HEADER_PATH)
76
77 LOCAL_SRC_FILES := \
78         $(ARMNN_BACKEND_SOURCES) \
79         src/armnnUtils/CsvReader.cpp \
80         src/armnnUtils/DataLayoutIndexed.cpp \
81         src/armnnUtils/DotSerializer.cpp \
82         src/armnnUtils/FloatingPointConverter.cpp \
83         src/armnnUtils/HeapProfiling.cpp \
84         src/armnnUtils/LeakChecking.cpp \
85         src/armnnUtils/Logging.cpp \
86         src/armnnUtils/ParserHelper.cpp \
87         src/armnnUtils/Permute.cpp \
88         src/armnnUtils/TensorUtils.cpp \
89         src/armnnUtils/VerificationHelpers.cpp \
90         src/armnn/layers/ActivationLayer.cpp \
91         src/armnn/layers/AdditionLayer.cpp \
92         src/armnn/layers/BatchNormalizationLayer.cpp \
93         src/armnn/layers/BatchToSpaceNdLayer.cpp \
94         src/armnn/layers/ConcatLayer.cpp \
95         src/armnn/layers/ConstantLayer.cpp \
96         src/armnn/layers/Convolution2dLayer.cpp \
97         src/armnn/layers/ConvertFp16ToFp32Layer.cpp \
98         src/armnn/layers/ConvertFp32ToFp16Layer.cpp \
99         src/armnn/layers/DebugLayer.cpp \
100         src/armnn/layers/DepthwiseConvolution2dLayer.cpp \
101         src/armnn/layers/DequantizeLayer.cpp \
102         src/armnn/layers/DetectionPostProcessLayer.cpp \
103         src/armnn/layers/DivisionLayer.cpp \
104         src/armnn/layers/ElementwiseBaseLayer.cpp \
105         src/armnn/layers/EqualLayer.cpp \
106         src/armnn/layers/FakeQuantizationLayer.cpp \
107         src/armnn/layers/FloorLayer.cpp \
108         src/armnn/layers/FullyConnectedLayer.cpp \
109         src/armnn/layers/GatherLayer.cpp \
110         src/armnn/layers/GreaterLayer.cpp \
111         src/armnn/layers/InputLayer.cpp \
112         src/armnn/layers/L2NormalizationLayer.cpp \
113         src/armnn/layers/LstmLayer.cpp \
114         src/armnn/layers/MaximumLayer.cpp \
115         src/armnn/layers/MeanLayer.cpp \
116         src/armnn/layers/MemCopyLayer.cpp \
117         src/armnn/layers/MemImportLayer.cpp \
118         src/armnn/layers/MergeLayer.cpp \
119         src/armnn/layers/MinimumLayer.cpp \
120         src/armnn/layers/MultiplicationLayer.cpp \
121         src/armnn/layers/NormalizationLayer.cpp \
122         src/armnn/layers/OutputLayer.cpp \
123         src/armnn/layers/PadLayer.cpp \
124         src/armnn/layers/PermuteLayer.cpp \
125         src/armnn/layers/Pooling2dLayer.cpp \
126         src/armnn/layers/PreCompiledLayer.cpp \
127         src/armnn/layers/PreluLayer.cpp \
128         src/armnn/layers/QuantizeLayer.cpp \
129         src/armnn/layers/QuantizedLstmLayer.cpp \
130         src/armnn/layers/ReshapeLayer.cpp \
131         src/armnn/layers/ResizeLayer.cpp \
132         src/armnn/layers/RsqrtLayer.cpp \
133         src/armnn/layers/SpaceToBatchNdLayer.cpp \
134         src/armnn/layers/SpaceToDepthLayer.cpp \
135         src/armnn/layers/SoftmaxLayer.cpp \
136         src/armnn/layers/SplitterLayer.cpp \
137         src/armnn/layers/StackLayer.cpp \
138         src/armnn/layers/StridedSliceLayer.cpp \
139         src/armnn/layers/SubtractionLayer.cpp \
140         src/armnn/layers/SwitchLayer.cpp \
141         src/armnn/layers/TransposeConvolution2dLayer.cpp \
142         src/armnn/BackendHelper.cpp \
143         src/armnn/Descriptors.cpp \
144         src/armnn/Exceptions.cpp \
145         src/armnn/Graph.cpp \
146         src/armnn/Optimizer.cpp \
147         src/armnn/Runtime.cpp \
148         src/armnn/SerializeLayerParameters.cpp \
149         src/armnn/SubgraphView.cpp \
150         src/armnn/SubgraphViewSelector.cpp \
151         src/armnn/InternalTypes.cpp \
152         src/armnn/Layer.cpp \
153         src/armnn/LoadedNetwork.cpp \
154         src/armnn/Network.cpp \
155         src/armnn/NetworkUtils.cpp \
156         src/armnn/WallClockTimer.cpp \
157         src/armnn/ProfilingEvent.cpp \
158         src/armnn/Profiling.cpp \
159         src/armnn/JsonPrinter.cpp \
160         src/armnn/Tensor.cpp \
161         src/armnn/TypesUtils.cpp \
162         src/armnn/Utils.cpp \
163         src/armnn/LayerSupport.cpp \
164         src/armnn/Observable.cpp
165
166 LOCAL_STATIC_LIBRARIES := \
167         armnn-arm_compute \
168         libboost_log \
169         libboost_system \
170         libboost_thread \
171         libboost_filesystem
172
173 LOCAL_SHARED_LIBRARIES := \
174         liblog
175
176 LOCAL_CFLAGS := \
177         -std=$(CPP_VERSION) \
178         -fexceptions \
179         -Wno-unused-parameter \
180         -frtti
181 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
182 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
183 LOCAL_CFLAGS += \
184         -DARMCOMPUTECL_ENABLED
185 endif # ARMNN_COMPUTE_CL_ENABLED == 1
186 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
187 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
188 LOCAL_CFLAGS += \
189         -DARMCOMPUTENEON_ENABLED
190 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
191
192 ifeq ($(Q_OR_LATER),1)
193 LOCAL_CFLAGS += \
194         -DBOOST_NO_AUTO_PTR
195 endif # PLATFORM_VERSION == Q or later
196
197 include $(BUILD_STATIC_LIBRARY)
198
199 ###############
200 # armnn-tests #
201 ###############
202 include $(CLEAR_VARS)
203
204 LOCAL_MODULE := armnn-tests
205 ifeq ($(Q_OR_LATER),1)
206 # "eng" is deprecated in Android Q
207 LOCAL_MODULE_TAGS := optional
208 else
209 LOCAL_MODULE_TAGS := eng optional
210 endif
211 LOCAL_ARM_MODE := arm
212 LOCAL_PROPRIETARY_MODULE := true
213
214 # placeholder to hold all backend unit test source files
215 ARMNN_BACKEND_TEST_SOURCES :=
216
217 #
218 # iterate through the backend common and specific include paths, include them into the current
219 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
220 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
221 #
222 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
223         $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
224         $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
225         $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
226
227 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
228         $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
229         $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
230         $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
231
232 # Mark source files as dependent on Android.mk
233 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
234
235 LOCAL_C_INCLUDES := \
236         $(OPENCL_HEADER_PATH) \
237         $(NN_HEADER_PATH) \
238         $(ARMNN_HEADER_PATH) \
239         $(ARMNN_MAIN_HEADER_PATH) \
240         $(ARMNN_SOURCE_HEADER_PATH) \
241         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
242         $(ARMNN_BACKENDS_HEADER_PATH)
243
244 LOCAL_CFLAGS := \
245         -std=$(CPP_VERSION) \
246         -fexceptions \
247         -frtti \
248         -isystem vendor/arm/android-nn-driver/boost_1_64_0
249 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
250 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
251 LOCAL_CFLAGS += \
252         -DARMCOMPUTECL_ENABLED
253 endif # ARMNN_COMPUTE_CL_ENABLED == 1
254 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
255 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
256 LOCAL_CFLAGS += \
257         -DARMCOMPUTENEON_ENABLED
258 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
259
260 ifeq ($(Q_OR_LATER),1)
261 LOCAL_CFLAGS += \
262         -DBOOST_NO_AUTO_PTR
263 endif # PLATFORM_VERSION == Q or later
264
265 LOCAL_SRC_FILES := \
266         $(ARMNN_BACKEND_TEST_SOURCES) \
267         src/armnn/test/UnitTests.cpp \
268         src/armnn/test/EndToEndTest.cpp \
269         src/armnn/test/UtilsTests.cpp \
270         src/armnn/test/GraphTests.cpp \
271         src/armnn/test/GraphUtils.cpp \
272         src/armnn/test/InferOutputTests.cpp \
273         src/armnn/test/RuntimeTests.cpp \
274         src/armnn/test/SubgraphViewTests.cpp \
275         src/armnn/test/TensorTest.cpp \
276         src/armnn/test/NetworkTests.cpp \
277         src/armnn/test/InstrumentTests.cpp \
278         src/armnn/test/ProfilingEventTest.cpp \
279         src/armnn/test/ObservableTest.cpp \
280         src/armnn/test/OptionalTest.cpp \
281         src/armnn/test/TestUtils.cpp \
282         src/armnn/test/TensorHandleStrategyTest.cpp
283
284 LOCAL_STATIC_LIBRARIES := \
285         libneuralnetworks_common \
286         libboost_log \
287         libboost_system \
288         libboost_unit_test_framework \
289         libboost_thread \
290         libboost_filesystem \
291         armnn-arm_compute
292
293 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
294
295 LOCAL_SHARED_LIBRARIES := \
296         libbase \
297         libhidlbase \
298         libhidltransport \
299         libhidlmemory \
300         liblog \
301         libutils \
302         android.hardware.neuralnetworks@1.0 \
303         android.hidl.allocator@1.0 \
304         android.hidl.memory@1.0
305
306 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
307 LOCAL_SHARED_LIBRARIES += \
308         libOpenCL
309 endif
310
311 include $(BUILD_EXECUTABLE)