2 # Copyright © 2017 ARM Ltd. All rights reserved.
3 # SPDX-License-Identifier: MIT
6 LOCAL_PATH := $(call my-dir)
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_MAIN_HEADER_PATH := $(LOCAL_PATH)/src
13 ARMNN_SOURCE_HEADER_PATH := $(LOCAL_PATH)/src/armnn
14 ARMNN_SOURCE_UTILS_HEADER_PATH := $(LOCAL_PATH)/src/armnnUtils
15 ARMNN_BACKENDS_HEADER_PATH := $(LOCAL_PATH)/src/backends
17 # find the common.mk and backend.mk files in the backend source folders
18 ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/common.mk)
19 ARMNN_BACKEND_COMMON_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_COMMON_MAKEFILE_LOCAL_PATHS))
20 ARMNN_BACKEND_COMMON_MAKEFILE_DIRS := $(subst /common.mk,,$(ARMNN_BACKEND_COMMON_MAKEFILE_PATHS))
22 ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS := $(wildcard $(LOCAL_PATH)/src/backends/*/backend.mk)
23 ARMNN_BACKEND_MAKEFILE_PATHS := $(subst $(LOCAL_PATH),,$(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS))
24 ARMNN_BACKEND_MAKEFILE_DIRS := $(subst /backend.mk,,$(ARMNN_BACKEND_MAKEFILE_PATHS))
31 LOCAL_MODULE := libarmnn
32 ifeq ($(Q_OR_LATER),1)
33 # "eng" is deprecated in Android Q
34 LOCAL_MODULE_TAGS := optional
36 LOCAL_MODULE_TAGS := eng optional
39 LOCAL_PROPRIETARY_MODULE := true
41 # placeholder to hold all backend source files, common and specific to the backends
42 ARMNN_BACKEND_SOURCES :=
45 # iterate through the backend common and specific include paths, include them into the
46 # current makefile and append the sources held by the COMMON_SOURCES and BACKEND_SOURCES variable
47 # (included from the given makefile) to the ARMNN_BACKEND_SOURCES list
49 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS),\
50 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk)\
51 $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
52 $(patsubst %,$(mkPath)/%,$(COMMON_SOURCES))))
54 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS),\
55 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk)\
56 $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
57 $(patsubst %,$(mkPath)/%,$(BACKEND_SOURCES))))
59 # Mark source files as dependent on Android.mk and backend makefiles
60 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk \
61 $(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS)
63 LOCAL_EXPORT_C_INCLUDES := \
64 $(ARMNN_MAIN_HEADER_PATH) \
65 $(ARMNN_SOURCE_HEADER_PATH) \
66 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
67 $(ARMNN_BACKENDS_HEADER_PATH)
70 $(OPENCL_HEADER_PATH) \
72 $(ARMNN_HEADER_PATH) \
73 $(ARMNN_MAIN_HEADER_PATH) \
74 $(ARMNN_SOURCE_HEADER_PATH) \
75 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
76 $(ARMNN_BACKENDS_HEADER_PATH)
79 $(ARMNN_BACKEND_SOURCES) \
80 src/armnn/BackendHelper.cpp \
81 src/armnn/Descriptors.cpp \
82 src/armnn/Exceptions.cpp \
84 src/armnn/InternalTypes.cpp \
85 src/armnn/JsonPrinter.cpp \
87 src/armnn/LayerSupport.cpp \
88 src/armnn/LoadedNetwork.cpp \
89 src/armnn/Network.cpp \
90 src/armnn/NetworkUtils.cpp \
91 src/armnn/Observable.cpp \
92 src/armnn/Optimizer.cpp \
93 src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.cpp \
94 src/armnn/ProfilingEvent.cpp \
95 src/armnn/Profiling.cpp \
96 src/armnn/Runtime.cpp \
97 src/armnn/SerializeLayerParameters.cpp \
98 src/armnn/SubgraphView.cpp \
99 src/armnn/SubgraphViewSelector.cpp \
100 src/armnn/Tensor.cpp \
101 src/armnn/TypesUtils.cpp \
102 src/armnn/Utils.cpp \
103 src/armnn/WallClockTimer.cpp \
104 src/armnnUtils/CsvReader.cpp \
105 src/armnnUtils/DataLayoutIndexed.cpp \
106 src/armnnUtils/DotSerializer.cpp \
107 src/armnnUtils/FloatingPointConverter.cpp \
108 src/armnnUtils/HeapProfiling.cpp \
109 src/armnnUtils/LeakChecking.cpp \
110 src/armnnUtils/Logging.cpp \
111 src/armnnUtils/ParserHelper.cpp \
112 src/armnnUtils/Permute.cpp \
113 src/armnnUtils/TensorUtils.cpp \
114 src/armnnUtils/VerificationHelpers.cpp \
115 src/armnn/layers/AbsLayer.cpp \
116 src/armnn/layers/ActivationLayer.cpp \
117 src/armnn/layers/AdditionLayer.cpp \
118 src/armnn/layers/ArgMinMaxLayer.cpp \
119 src/armnn/layers/BatchNormalizationLayer.cpp \
120 src/armnn/layers/BatchToSpaceNdLayer.cpp \
121 src/armnn/layers/ComparisonLayer.cpp \
122 src/armnn/layers/ConcatLayer.cpp \
123 src/armnn/layers/ConstantLayer.cpp \
124 src/armnn/layers/Convolution2dLayer.cpp \
125 src/armnn/layers/ConvertFp16ToFp32Layer.cpp \
126 src/armnn/layers/ConvertFp32ToFp16Layer.cpp \
127 src/armnn/layers/DebugLayer.cpp \
128 src/armnn/layers/DepthToSpaceLayer.cpp \
129 src/armnn/layers/DepthwiseConvolution2dLayer.cpp \
130 src/armnn/layers/DequantizeLayer.cpp \
131 src/armnn/layers/DetectionPostProcessLayer.cpp \
132 src/armnn/layers/DivisionLayer.cpp \
133 src/armnn/layers/ElementwiseBaseLayer.cpp \
134 src/armnn/layers/FakeQuantizationLayer.cpp \
135 src/armnn/layers/FloorLayer.cpp \
136 src/armnn/layers/FullyConnectedLayer.cpp \
137 src/armnn/layers/GatherLayer.cpp \
138 src/armnn/layers/InputLayer.cpp \
139 src/armnn/layers/InstanceNormalizationLayer.cpp \
140 src/armnn/layers/L2NormalizationLayer.cpp \
141 src/armnn/layers/LogSoftmaxLayer.cpp \
142 src/armnn/layers/LstmLayer.cpp \
143 src/armnn/layers/MaximumLayer.cpp \
144 src/armnn/layers/MeanLayer.cpp \
145 src/armnn/layers/MemCopyLayer.cpp \
146 src/armnn/layers/MemImportLayer.cpp \
147 src/armnn/layers/MergeLayer.cpp \
148 src/armnn/layers/MinimumLayer.cpp \
149 src/armnn/layers/MultiplicationLayer.cpp \
150 src/armnn/layers/NormalizationLayer.cpp \
151 src/armnn/layers/OutputLayer.cpp \
152 src/armnn/layers/PadLayer.cpp \
153 src/armnn/layers/PermuteLayer.cpp \
154 src/armnn/layers/Pooling2dLayer.cpp \
155 src/armnn/layers/PreCompiledLayer.cpp \
156 src/armnn/layers/PreluLayer.cpp \
157 src/armnn/layers/QuantizeLayer.cpp \
158 src/armnn/layers/QuantizedLstmLayer.cpp \
159 src/armnn/layers/ReshapeLayer.cpp \
160 src/armnn/layers/ResizeLayer.cpp \
161 src/armnn/layers/RsqrtLayer.cpp \
162 src/armnn/layers/SliceLayer.cpp \
163 src/armnn/layers/SoftmaxLayer.cpp \
164 src/armnn/layers/SpaceToBatchNdLayer.cpp \
165 src/armnn/layers/SpaceToDepthLayer.cpp \
166 src/armnn/layers/SplitterLayer.cpp \
167 src/armnn/layers/StackLayer.cpp \
168 src/armnn/layers/StandInLayer.cpp \
169 src/armnn/layers/StridedSliceLayer.cpp \
170 src/armnn/layers/SubtractionLayer.cpp \
171 src/armnn/layers/SwitchLayer.cpp \
172 src/armnn/layers/TransposeConvolution2dLayer.cpp \
173 src/profiling/BufferManager.cpp \
174 src/profiling/CommandHandler.cpp \
175 src/profiling/CommandHandlerFunctor.cpp \
176 src/profiling/CommandHandlerKey.cpp \
177 src/profiling/CommandHandlerRegistry.cpp \
178 src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
179 src/profiling/CounterDirectory.cpp \
180 src/profiling/Holder.cpp \
181 src/profiling/PacketBuffer.cpp \
182 src/profiling/PacketVersionResolver.cpp \
183 src/profiling/PeriodicCounterCapture.cpp \
184 src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
185 src/profiling/PerJobCounterSelectionCommandHandler.cpp \
186 src/profiling/ProfilingConnectionDumpToFileDecorator.cpp \
187 src/profiling/ProfilingConnectionFactory.cpp \
188 src/profiling/ProfilingService.cpp \
189 src/profiling/ProfilingStateMachine.cpp \
190 src/profiling/ProfilingUtils.cpp \
191 src/profiling/RequestCounterDirectoryCommandHandler.cpp \
192 src/profiling/SendCounterPacket.cpp \
193 src/profiling/SocketProfilingConnection.cpp \
194 src/profiling/TimelineUtilityMethods.cpp
196 LOCAL_STATIC_LIBRARIES := \
203 LOCAL_SHARED_LIBRARIES := \
207 -std=$(CPP_VERSION) \
209 -Wno-unused-parameter \
212 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
213 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
215 -DARMCOMPUTECL_ENABLED
216 endif # ARMNN_COMPUTE_CL_ENABLED == 1
217 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
218 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
220 -DARMCOMPUTENEON_ENABLED
221 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
222 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
223 ifeq ($(ARMNN_REF_ENABLED),1)
226 endif # ARMNN_REF_ENABLED == 1
228 ifeq ($(Q_OR_LATER),1)
231 endif # PLATFORM_VERSION == Q or later
233 include $(BUILD_STATIC_LIBRARY)
238 include $(CLEAR_VARS)
240 LOCAL_MODULE := armnn-tests
241 ifeq ($(Q_OR_LATER),1)
242 # "eng" is deprecated in Android Q
243 LOCAL_MODULE_TAGS := optional
245 LOCAL_MODULE_TAGS := eng optional
247 LOCAL_ARM_MODE := arm
248 LOCAL_PROPRIETARY_MODULE := true
250 # placeholder to hold all backend unit test source files
251 ARMNN_BACKEND_TEST_SOURCES :=
254 # iterate through the backend common and specific include paths, include them into the current
255 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
256 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
258 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
259 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
260 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
261 $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
263 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
264 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
265 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
266 $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
268 # Mark source files as dependent on Android.mk
269 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
271 LOCAL_C_INCLUDES := \
272 $(OPENCL_HEADER_PATH) \
274 $(ARMNN_HEADER_PATH) \
275 $(ARMNN_MAIN_HEADER_PATH) \
276 $(ARMNN_SOURCE_HEADER_PATH) \
277 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
278 $(ARMNN_BACKENDS_HEADER_PATH)
281 -std=$(CPP_VERSION) \
284 -isystem vendor/arm/android-nn-driver/boost_1_64_0
286 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
287 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
289 -DARMCOMPUTECL_ENABLED
290 endif # ARMNN_COMPUTE_CL_ENABLED == 1
291 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
292 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
294 -DARMCOMPUTENEON_ENABLED
295 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
296 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
297 ifeq ($(ARMNN_REF_ENABLED),1)
300 endif # ARMNN_REF_ENABLED == 1
302 ifeq ($(Q_OR_LATER),1)
305 endif # PLATFORM_VERSION == Q or later
308 $(ARMNN_BACKEND_TEST_SOURCES) \
309 src/armnn/test/EndToEndTest.cpp \
310 src/armnn/test/GraphTests.cpp \
311 src/armnn/test/GraphUtils.cpp \
312 src/armnn/test/InferOutputTests.cpp \
313 src/armnn/test/InstrumentTests.cpp \
314 src/armnn/test/NetworkTests.cpp \
315 src/armnn/test/ObservableTest.cpp \
316 src/armnn/test/OptionalTest.cpp \
317 src/armnn/test/ProfilingEventTest.cpp \
318 src/armnn/test/SubgraphViewTests.cpp \
319 src/armnn/test/TensorHandleStrategyTest.cpp \
320 src/armnn/test/TensorTest.cpp \
321 src/armnn/test/TestUtils.cpp \
322 src/armnn/test/UnitTests.cpp \
323 src/armnn/test/UtilsTests.cpp
325 ifeq ($(ARMNN_REF_ENABLED),1)
327 src/armnn/test/DebugCallbackTest.cpp \
328 src/armnn/test/RuntimeTests.cpp
331 LOCAL_STATIC_LIBRARIES := \
332 libneuralnetworks_common \
335 libboost_unit_test_framework \
337 libboost_filesystem \
340 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
342 LOCAL_SHARED_LIBRARIES := \
349 android.hardware.neuralnetworks@1.0 \
350 android.hidl.allocator@1.0 \
351 android.hidl.memory@1.0
353 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
354 LOCAL_SHARED_LIBRARIES += \
358 include $(BUILD_EXECUTABLE)