Update ACL pin to 51a9558d484e812707a776efceef18b93698cec9
[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 OPENCL_HEADER_PATH := $(LOCAL_PATH)/../clframework/include
10 NN_HEADER_PATH := $(LOCAL_PATH)/../../../../frameworks/ml/nn/runtime/include
11 ARMNN_HEADER_PATH := $(LOCAL_PATH)/include
12 ARMNN_PROFILING_INCLUDE_PATH := $(LOCAL_PATH)/profiling
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 ARMNN_PROFILING_HEADER_PATH := $(LOCAL_PATH)/src/profiling
18
19 # find the common.mk and backend.mk files in the backend source folders
20 ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/common.mk)
21 ARMNN_BACKEND_COMMON_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS))
22 ARMNN_BACKEND_COMMON_MAKEFILE_DIRS := $(subst /common.mk,,$(ARMNN_BACKEND_COMMON_MAKEFILE_PATHS))
23
24 ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/backend.mk)
25 ARMNN_BACKEND_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS))
26 ARMNN_BACKEND_MAKEFILE_DIRS := $(subst /backend.mk,,$(ARMNN_BACKEND_MAKEFILE_PATHS))
27
28 ##############
29 # libarmnn.a #
30 ##############
31 include $(CLEAR_VARS)
32
33 LOCAL_MODULE := libarmnn
34 ifeq ($(Q_OR_LATER),1)
35 # "eng" is deprecated in Android Q
36 LOCAL_MODULE_TAGS := optional
37 else
38 LOCAL_MODULE_TAGS := eng optional
39 endif
40 LOCAL_ARM_MODE := arm
41 LOCAL_PROPRIETARY_MODULE := true
42
43 # placeholder to hold all backend source files, common and specific to the backends
44 ARMNN_BACKEND_SOURCES :=
45
46 #
47 # iterate through the backend common and specific include paths, include them into the
48 # current makefile and append the sources held by the COMMON_SOURCES and BACKEND_SOURCES variable
49 # (included from the given makefile) to the ARMNN_BACKEND_SOURCES list
50 #
51 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS),\
52         $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk)\
53         $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
54         $(patsubst %,$(mkPath)/%,$(COMMON_SOURCES))))
55
56 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS),\
57         $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk)\
58         $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
59         $(patsubst %,$(mkPath)/%,$(BACKEND_SOURCES))))
60
61 # Mark source files as dependent on Android.mk and backend makefiles
62 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk \
63                                  $(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS)
64
65 LOCAL_EXPORT_C_INCLUDES := \
66         $(ARMNN_MAIN_HEADER_PATH) \
67         $(ARMNN_SOURCE_HEADER_PATH) \
68         $(ARMNN_PROFILING_INCLUDE_PATH) \
69         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
70         $(ARMNN_PROFILING_HEADER_PATH) \
71         $(ARMNN_BACKENDS_HEADER_PATH)
72
73 LOCAL_C_INCLUDES := \
74         $(OPENCL_HEADER_PATH) \
75         $(NN_HEADER_PATH) \
76         $(ARMNN_HEADER_PATH) \
77         $(ARMNN_PROFILING_INCLUDE_PATH) \
78         $(ARMNN_MAIN_HEADER_PATH) \
79         $(ARMNN_SOURCE_HEADER_PATH) \
80         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
81         $(ARMNN_PROFILING_HEADER_PATH) \
82         $(ARMNN_BACKENDS_HEADER_PATH)
83
84 LOCAL_SRC_FILES := \
85         $(ARMNN_BACKEND_SOURCES) \
86         src/armnn/BackendHelper.cpp \
87         src/armnn/BackendRegistry.cpp \
88         src/armnn/Descriptors.cpp \
89         src/armnn/Exceptions.cpp \
90         src/armnn/Graph.cpp \
91         src/armnn/InternalTypes.cpp \
92         src/armnn/JsonPrinter.cpp \
93         src/armnn/Layer.cpp \
94         src/armnn/LayerSupport.cpp \
95         src/armnn/LoadedNetwork.cpp \
96         src/armnn/Logging.cpp \
97         src/armnn/Network.cpp \
98         src/armnn/NetworkUtils.cpp \
99         src/armnn/Observable.cpp \
100         src/armnn/Optimizer.cpp \
101         src/armnn/OutputHandler.cpp \
102         src/armnn/ProfilingEvent.cpp \
103         src/armnn/Profiling.cpp \
104         src/armnn/Runtime.cpp \
105         src/armnn/SerializeLayerParameters.cpp \
106         src/armnn/SubgraphView.cpp \
107         src/armnn/SubgraphViewSelector.cpp \
108         src/armnn/Tensor.cpp \
109         src/armnn/TypesUtils.cpp \
110         src/armnn/Utils.cpp \
111         src/armnn/WallClockTimer.cpp \
112         src/armnnUtils/CsvReader.cpp \
113         src/armnnUtils/DataLayoutIndexed.cpp \
114         src/armnnUtils/DotSerializer.cpp \
115         src/armnnUtils/FloatingPointConverter.cpp \
116         src/armnnUtils/HeapProfiling.cpp \
117         src/armnnUtils/LeakChecking.cpp \
118         src/armnnUtils/ParserHelper.cpp \
119         src/armnnUtils/Permute.cpp \
120         src/armnnUtils/TensorUtils.cpp \
121         src/armnnUtils/VerificationHelpers.cpp \
122         src/armnnUtils/NetworkSockets.cpp \
123         src/armnnUtils/Filesystem.cpp \
124         src/armnnUtils/Processes.cpp \
125         src/armnnUtils/Transpose.cpp \
126         src/armnn/layers/ActivationLayer.cpp \
127         src/armnn/layers/AdditionLayer.cpp \
128         src/armnn/layers/ArgMinMaxLayer.cpp \
129         src/armnn/layers/BatchNormalizationLayer.cpp \
130         src/armnn/layers/BatchToSpaceNdLayer.cpp \
131         src/armnn/layers/ComparisonLayer.cpp \
132         src/armnn/layers/ConcatLayer.cpp \
133         src/armnn/layers/ConstantLayer.cpp \
134         src/armnn/layers/Convolution2dLayer.cpp \
135         src/armnn/layers/ConvertBf16ToFp32Layer.cpp \
136         src/armnn/layers/ConvertFp16ToFp32Layer.cpp \
137         src/armnn/layers/ConvertFp32ToBf16Layer.cpp \
138         src/armnn/layers/ConvertFp32ToFp16Layer.cpp \
139         src/armnn/layers/DebugLayer.cpp \
140         src/armnn/layers/DepthToSpaceLayer.cpp \
141         src/armnn/layers/DepthwiseConvolution2dLayer.cpp \
142         src/armnn/layers/DequantizeLayer.cpp \
143         src/armnn/layers/DetectionPostProcessLayer.cpp \
144         src/armnn/layers/DivisionLayer.cpp \
145         src/armnn/layers/ElementwiseBaseLayer.cpp \
146         src/armnn/layers/ElementwiseUnaryLayer.cpp \
147         src/armnn/layers/FakeQuantizationLayer.cpp \
148         src/armnn/layers/FloorLayer.cpp \
149         src/armnn/layers/FullyConnectedLayer.cpp \
150         src/armnn/layers/GatherLayer.cpp \
151         src/armnn/layers/InputLayer.cpp \
152         src/armnn/layers/InstanceNormalizationLayer.cpp \
153         src/armnn/layers/L2NormalizationLayer.cpp \
154         src/armnn/layers/LogSoftmaxLayer.cpp \
155         src/armnn/layers/LstmLayer.cpp \
156         src/armnn/layers/MaximumLayer.cpp \
157         src/armnn/layers/MeanLayer.cpp \
158         src/armnn/layers/MemCopyLayer.cpp \
159         src/armnn/layers/MemImportLayer.cpp \
160         src/armnn/layers/MergeLayer.cpp \
161         src/armnn/layers/MinimumLayer.cpp \
162         src/armnn/layers/MultiplicationLayer.cpp \
163         src/armnn/layers/NormalizationLayer.cpp \
164         src/armnn/layers/OutputLayer.cpp \
165         src/armnn/layers/PadLayer.cpp \
166         src/armnn/layers/PermuteLayer.cpp \
167         src/armnn/layers/Pooling2dLayer.cpp \
168         src/armnn/layers/PreCompiledLayer.cpp \
169         src/armnn/layers/PreluLayer.cpp \
170         src/armnn/layers/QLstmLayer.cpp \
171         src/armnn/layers/QuantizeLayer.cpp \
172         src/armnn/layers/QuantizedLstmLayer.cpp \
173         src/armnn/layers/ReshapeLayer.cpp \
174         src/armnn/layers/ResizeLayer.cpp \
175         src/armnn/layers/SliceLayer.cpp \
176         src/armnn/layers/SoftmaxLayer.cpp \
177         src/armnn/layers/SpaceToBatchNdLayer.cpp \
178         src/armnn/layers/SpaceToDepthLayer.cpp \
179         src/armnn/layers/SplitterLayer.cpp \
180         src/armnn/layers/StackLayer.cpp \
181         src/armnn/layers/StandInLayer.cpp \
182         src/armnn/layers/StridedSliceLayer.cpp \
183         src/armnn/layers/SubtractionLayer.cpp \
184         src/armnn/layers/SwitchLayer.cpp \
185         src/armnn/layers/TransposeConvolution2dLayer.cpp \
186         src/armnn/layers/TransposeLayer.cpp \
187         src/profiling/BufferManager.cpp \
188         src/profiling/CommandHandler.cpp \
189         src/profiling/CommandHandlerFunctor.cpp \
190         src/profiling/CommandHandlerKey.cpp \
191         src/profiling/CommandHandlerRegistry.cpp \
192         src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
193         src/profiling/CounterDirectory.cpp \
194         src/profiling/CounterIdMap.cpp \
195         src/profiling/DirectoryCaptureCommandHandler.cpp \
196         src/profiling/FileOnlyProfilingConnection.cpp \
197         src/profiling/Holder.cpp \
198         src/profiling/LabelsAndEventClasses.cpp \
199         src/profiling/PacketBuffer.cpp \
200         src/profiling/PacketVersionResolver.cpp \
201         src/profiling/PeriodicCounterCapture.cpp \
202         src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
203         src/profiling/PerJobCounterSelectionCommandHandler.cpp \
204         src/profiling/ProfilingConnectionDumpToFileDecorator.cpp \
205         src/profiling/ProfilingConnectionFactory.cpp \
206         src/profiling/ProfilingService.cpp \
207         src/profiling/ProfilingStateMachine.cpp \
208         src/profiling/ProfilingUtils.cpp \
209         src/profiling/RegisterBackendCounters.cpp \
210         src/profiling/RequestCounterDirectoryCommandHandler.cpp \
211         src/profiling/SendCounterPacket.cpp \
212         src/profiling/SendThread.cpp \
213         src/profiling/SendTimelinePacket.cpp \
214         src/profiling/SocketProfilingConnection.cpp \
215         src/profiling/TimelinePacketWriterFactory.cpp \
216         src/profiling/TimelineUtilityMethods.cpp \
217         src/profiling/backends/BackendProfiling.cpp
218
219 LOCAL_STATIC_LIBRARIES := \
220         arm_compute_library \
221         libboost_log \
222         libboost_system \
223         libboost_thread \
224         libboost_filesystem
225
226 LOCAL_SHARED_LIBRARIES := \
227         liblog
228
229 LOCAL_CFLAGS := \
230         -std=$(CPP_VERSION) \
231         -fexceptions \
232         -Wno-unused-parameter \
233         -frtti
234
235 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
236 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
237 LOCAL_CFLAGS += \
238         -DARMCOMPUTECL_ENABLED
239 endif # ARMNN_COMPUTE_CL_ENABLED == 1
240 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
241 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
242 LOCAL_CFLAGS += \
243         -DARMCOMPUTENEON_ENABLED
244 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
245 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
246 ifeq ($(ARMNN_REF_ENABLED),1)
247 LOCAL_CFLAGS += \
248         -DARMNNREF_ENABLED
249 endif # ARMNN_REF_ENABLED == 1
250
251 ifeq ($(Q_OR_LATER),1)
252 LOCAL_CFLAGS += \
253         -DARMNN_MIXED_PRECISION_FP16_POOLING \
254         -DBOOST_NO_AUTO_PTR
255 endif # PLATFORM_VERSION == Q or later
256
257 include $(BUILD_STATIC_LIBRARY)
258
259 ###############
260 # armnn-tests #
261 ###############
262 include $(CLEAR_VARS)
263
264 LOCAL_MODULE := armnn-tests
265 ifeq ($(Q_OR_LATER),1)
266 # "eng" is deprecated in Android Q
267 LOCAL_MODULE_TAGS := optional
268 else
269 LOCAL_MODULE_TAGS := eng optional
270 endif
271 LOCAL_ARM_MODE := arm
272 LOCAL_PROPRIETARY_MODULE := true
273
274 # placeholder to hold all backend unit test source files
275 ARMNN_BACKEND_TEST_SOURCES :=
276
277 #
278 # iterate through the backend common and specific include paths, include them into the current
279 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
280 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
281 #
282 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
283         $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
284         $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
285         $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
286
287 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
288         $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
289         $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
290         $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
291
292 # Mark source files as dependent on Android.mk
293 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
294
295 LOCAL_C_INCLUDES := \
296         $(OPENCL_HEADER_PATH) \
297         $(NN_HEADER_PATH) \
298         $(ARMNN_HEADER_PATH) \
299         $(ARMNN_PROFILING_INCLUDE_PATH) \
300         $(ARMNN_MAIN_HEADER_PATH) \
301         $(ARMNN_SOURCE_HEADER_PATH) \
302         $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
303         $(ARMNN_PROFILING_HEADER_PATH) \
304         $(ARMNN_BACKENDS_HEADER_PATH)
305
306 LOCAL_CFLAGS := \
307         -std=$(CPP_VERSION) \
308         -fexceptions \
309         -frtti \
310         -isystem vendor/arm/android-nn-driver/boost_1_64_0
311
312 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
313 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
314 LOCAL_CFLAGS += \
315         -DARMCOMPUTECL_ENABLED
316 endif # ARMNN_COMPUTE_CL_ENABLED == 1
317 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
318 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
319 LOCAL_CFLAGS += \
320         -DARMCOMPUTENEON_ENABLED
321 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
322 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
323 ifeq ($(ARMNN_REF_ENABLED),1)
324 LOCAL_CFLAGS += \
325         -DARMNNREF_ENABLED
326 endif # ARMNN_REF_ENABLED == 1
327
328 ifeq ($(Q_OR_LATER),1)
329 LOCAL_CFLAGS += \
330         -DBOOST_NO_AUTO_PTR
331 endif # PLATFORM_VERSION == Q or later
332
333 LOCAL_SRC_FILES := \
334         $(ARMNN_BACKEND_TEST_SOURCES) \
335         src/armnn/test/ConstTensorLayerVisitor.cpp \
336         src/armnn/test/CsvReaderTest.cpp \
337         src/armnn/test/EndToEndTest.cpp \
338         src/armnn/ExecutionFrame.cpp \
339         src/armnn/test/ExecutionFrameTest.cpp \
340         src/armnn/test/FloatingPointConverterTest.cpp \
341         src/armnn/test/FlowControl.cpp \
342         src/armnn/test/GraphTests.cpp \
343         src/armnn/test/GraphUtils.cpp \
344         src/armnn/test/InferOutputTests.cpp \
345         src/armnn/test/InstrumentTests.cpp \
346         src/armnnUtils/ModelAccuracyChecker.cpp \
347         src/armnn/test/ModelAccuracyCheckerTest.cpp \
348         src/armnn/test/NetworkTests.cpp \
349         src/armnn/test/ObservableTest.cpp \
350         src/armnn/test/optimizations/ConvertConstantsBFloatTests.cpp \
351         src/armnn/test/optimizations/ConvertConstantsFloatToHalfTests.cpp \
352         src/armnn/test/optimizations/ConvertConstantsHalfToFloatTests.cpp \
353         src/armnn/test/optimizations/Fp32NetworkToBf16ConverterTests.cpp \
354         src/armnn/test/optimizations/Fp32NetworkToFp16ConverterTests.cpp \
355         src/armnn/test/optimizations/InsertDebugLayerTests.cpp \
356         src/armnn/test/optimizations/MovePermuteUpTests.cpp \
357         src/armnn/test/optimizations/OptimizeConsecutiveReshapesTests.cpp \
358         src/armnn/test/optimizations/OptimizeInverseConversionsTests.cpp \
359         src/armnn/test/optimizations/OptimizeInversePermutesTests.cpp \
360         src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp \
361         src/armnn/test/optimizations/PermuteAsReshapeTests.cpp \
362         src/armnn/test/optimizations/SquashEqualSiblingsTests.cpp \
363         src/armnn/test/optimizations/TransposeAsReshapeTests.cpp \
364         src/armnn/test/OptimizerTests.cpp \
365         src/armnn/test/OptionalTest.cpp \
366         src/armnn/test/ProfilerTests.cpp \
367         src/armnn/test/ProfilingEventTest.cpp \
368         src/armnnUtils/PrototxtConversions.cpp \
369         src/armnnUtils/test/PrototxtConversionsTest.cpp \
370         src/armnn/test/SubgraphViewTests.cpp \
371         src/armnn/test/TensorHandleStrategyTest.cpp \
372         src/armnn/test/TensorTest.cpp \
373         src/armnn/test/TestInputOutputLayerVisitor.cpp \
374         src/armnn/test/TestLayerVisitor.cpp \
375         src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp \
376         src/armnn/test/TestNameOnlyLayerVisitor.cpp \
377         src/armnn/test/TestUtils.cpp \
378         src/armnn/test/UnitTests.cpp \
379         src/armnn/test/UtilsTests.cpp \
380         src/armnnUtils/test/ParserHelperTest.cpp \
381         src/armnnUtils/test/QuantizeHelperTest.cpp \
382         src/armnnUtils/test/TensorUtilsTest.cpp \
383         src/profiling/test/BufferTests.cpp \
384         src/profiling/test/FileOnlyProfilingDecoratorTests.cpp \
385         src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp \
386         src/profiling/test/ProfilingGuidTest.cpp \
387         src/profiling/test/ProfilingTests.cpp \
388         src/profiling/test/ProfilingTestUtils.cpp \
389         src/profiling/test/SendCounterPacketTests.cpp \
390         src/profiling/test/SendTimelinePacketTests.cpp \
391         src/profiling/test/TimelinePacketTests.cpp \
392         src/profiling/test/TimelineUtilityMethodsTests.cpp
393
394 ifeq ($(ARMNN_REF_ENABLED),1)
395 LOCAL_SRC_FILES += \
396         src/armnn/test/DebugCallbackTest.cpp \
397         src/armnn/test/RuntimeTests.cpp
398 endif
399
400 LOCAL_STATIC_LIBRARIES := \
401         libneuralnetworks_common \
402         libboost_log \
403         libboost_system \
404         libboost_unit_test_framework \
405         libboost_thread \
406         libboost_filesystem \
407         arm_compute_library
408
409 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
410
411 LOCAL_SHARED_LIBRARIES := \
412         libbase \
413         libhidlbase \
414         libhidltransport \
415         libhidlmemory \
416         liblog \
417         libutils \
418         android.hardware.neuralnetworks@1.0 \
419         android.hidl.allocator@1.0 \
420         android.hidl.memory@1.0
421
422 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
423 LOCAL_SHARED_LIBRARIES += \
424         libOpenCL
425 endif
426
427 include $(BUILD_EXECUTABLE)