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
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
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))
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))
32 LOCAL_MODULE := libarmnn
33 ifeq ($(Q_OR_LATER),1)
34 # "eng" is deprecated in Android Q
35 LOCAL_MODULE_TAGS := optional
37 LOCAL_MODULE_TAGS := eng optional
40 LOCAL_PROPRIETARY_MODULE := true
42 # placeholder to hold all backend source files, common and specific to the backends
43 ARMNN_BACKEND_SOURCES :=
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
50 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS),\
51 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk)\
52 $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
53 $(patsubst %,$(mkPath)/%,$(COMMON_SOURCES))))
55 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS),\
56 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk)\
57 $(eval ARMNN_BACKEND_SOURCES := $(ARMNN_BACKEND_SOURCES)\
58 $(patsubst %,$(mkPath)/%,$(BACKEND_SOURCES))))
60 # Mark source files as dependent on Android.mk and backend makefiles
61 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk \
62 $(ARMNN_BACKEND_MAKEFILE_LOCAL_PATHS)
64 LOCAL_EXPORT_C_INCLUDES := \
65 $(ARMNN_MAIN_HEADER_PATH) \
66 $(ARMNN_SOURCE_HEADER_PATH) \
67 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
68 $(ARMNN_BACKENDS_HEADER_PATH)
71 $(OPENCL_HEADER_PATH) \
73 $(ARMNN_HEADER_PATH) \
74 $(ARMNN_MAIN_HEADER_PATH) \
75 $(ARMNN_SOURCE_HEADER_PATH) \
76 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
77 $(ARMNN_BACKENDS_HEADER_PATH)
80 $(ARMNN_BACKEND_SOURCES) \
81 src/armnn/BackendHelper.cpp \
82 src/armnn/Descriptors.cpp \
83 src/armnn/Exceptions.cpp \
85 src/armnn/InternalTypes.cpp \
86 src/armnn/JsonPrinter.cpp \
88 src/armnn/LayerSupport.cpp \
89 src/armnn/LoadedNetwork.cpp \
90 src/armnn/Network.cpp \
91 src/armnn/NetworkUtils.cpp \
92 src/armnn/Observable.cpp \
93 src/armnn/Optimizer.cpp \
94 src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.cpp \
95 src/armnn/ProfilingEvent.cpp \
96 src/armnn/Profiling.cpp \
97 src/armnn/Runtime.cpp \
98 src/armnn/SerializeLayerParameters.cpp \
99 src/armnn/SubgraphView.cpp \
100 src/armnn/SubgraphViewSelector.cpp \
101 src/armnn/Tensor.cpp \
102 src/armnn/TypesUtils.cpp \
103 src/armnn/Utils.cpp \
104 src/armnn/WallClockTimer.cpp \
105 src/armnnUtils/CsvReader.cpp \
106 src/armnnUtils/DataLayoutIndexed.cpp \
107 src/armnnUtils/DotSerializer.cpp \
108 src/armnnUtils/FloatingPointConverter.cpp \
109 src/armnnUtils/HeapProfiling.cpp \
110 src/armnnUtils/LeakChecking.cpp \
111 src/armnnUtils/Logging.cpp \
112 src/armnnUtils/ParserHelper.cpp \
113 src/armnnUtils/Permute.cpp \
114 src/armnnUtils/TensorUtils.cpp \
115 src/armnnUtils/VerificationHelpers.cpp \
116 src/armnn/layers/AbsLayer.cpp \
117 src/armnn/layers/ActivationLayer.cpp \
118 src/armnn/layers/AdditionLayer.cpp \
119 src/armnn/layers/ArgMinMaxLayer.cpp \
120 src/armnn/layers/BatchNormalizationLayer.cpp \
121 src/armnn/layers/BatchToSpaceNdLayer.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/EqualLayer.cpp \
135 src/armnn/layers/FakeQuantizationLayer.cpp \
136 src/armnn/layers/FloorLayer.cpp \
137 src/armnn/layers/FullyConnectedLayer.cpp \
138 src/armnn/layers/GatherLayer.cpp \
139 src/armnn/layers/GreaterLayer.cpp \
140 src/armnn/layers/InputLayer.cpp \
141 src/armnn/layers/InstanceNormalizationLayer.cpp \
142 src/armnn/layers/L2NormalizationLayer.cpp \
143 src/armnn/layers/LstmLayer.cpp \
144 src/armnn/layers/MaximumLayer.cpp \
145 src/armnn/layers/MeanLayer.cpp \
146 src/armnn/layers/MemCopyLayer.cpp \
147 src/armnn/layers/MemImportLayer.cpp \
148 src/armnn/layers/MergeLayer.cpp \
149 src/armnn/layers/MinimumLayer.cpp \
150 src/armnn/layers/MultiplicationLayer.cpp \
151 src/armnn/layers/NormalizationLayer.cpp \
152 src/armnn/layers/OutputLayer.cpp \
153 src/armnn/layers/PadLayer.cpp \
154 src/armnn/layers/PermuteLayer.cpp \
155 src/armnn/layers/Pooling2dLayer.cpp \
156 src/armnn/layers/PreCompiledLayer.cpp \
157 src/armnn/layers/PreluLayer.cpp \
158 src/armnn/layers/QuantizeLayer.cpp \
159 src/armnn/layers/QuantizedLstmLayer.cpp \
160 src/armnn/layers/ReshapeLayer.cpp \
161 src/armnn/layers/ResizeLayer.cpp \
162 src/armnn/layers/RsqrtLayer.cpp \
163 src/armnn/layers/SliceLayer.cpp \
164 src/armnn/layers/SoftmaxLayer.cpp \
165 src/armnn/layers/SpaceToBatchNdLayer.cpp \
166 src/armnn/layers/SpaceToDepthLayer.cpp \
167 src/armnn/layers/SplitterLayer.cpp \
168 src/armnn/layers/StackLayer.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/ProfilingConnectionDumpToFileDecorator.cpp \
186 src/profiling/ProfilingConnectionFactory.cpp \
187 src/profiling/ProfilingService.cpp \
188 src/profiling/ProfilingStateMachine.cpp \
189 src/profiling/ProfilingUtils.cpp \
190 src/profiling/RequestCounterDirectoryCommandHandler.cpp \
191 src/profiling/SendCounterPacket.cpp \
192 src/profiling/SocketProfilingConnection.cpp
194 LOCAL_STATIC_LIBRARIES := \
201 LOCAL_SHARED_LIBRARIES := \
205 -std=$(CPP_VERSION) \
207 -Wno-unused-parameter \
209 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
210 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
212 -DARMCOMPUTECL_ENABLED
213 endif # ARMNN_COMPUTE_CL_ENABLED == 1
214 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
215 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
217 -DARMCOMPUTENEON_ENABLED
218 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
219 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
220 ifeq ($(ARMNN_REF_ENABLED),1)
223 endif # ARMNN_REF_ENABLED == 1
225 ifeq ($(Q_OR_LATER),1)
228 endif # PLATFORM_VERSION == Q or later
230 include $(BUILD_STATIC_LIBRARY)
235 include $(CLEAR_VARS)
237 LOCAL_MODULE := armnn-tests
238 ifeq ($(Q_OR_LATER),1)
239 # "eng" is deprecated in Android Q
240 LOCAL_MODULE_TAGS := optional
242 LOCAL_MODULE_TAGS := eng optional
244 LOCAL_ARM_MODE := arm
245 LOCAL_PROPRIETARY_MODULE := true
247 # placeholder to hold all backend unit test source files
248 ARMNN_BACKEND_TEST_SOURCES :=
251 # iterate through the backend common and specific include paths, include them into the current
252 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
253 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
255 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
256 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
257 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
258 $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
260 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
261 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
262 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
263 $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
265 # Mark source files as dependent on Android.mk
266 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
268 LOCAL_C_INCLUDES := \
269 $(OPENCL_HEADER_PATH) \
271 $(ARMNN_HEADER_PATH) \
272 $(ARMNN_MAIN_HEADER_PATH) \
273 $(ARMNN_SOURCE_HEADER_PATH) \
274 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
275 $(ARMNN_BACKENDS_HEADER_PATH)
278 -std=$(CPP_VERSION) \
281 -isystem vendor/arm/android-nn-driver/boost_1_64_0
282 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
283 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
285 -DARMCOMPUTECL_ENABLED
286 endif # ARMNN_COMPUTE_CL_ENABLED == 1
287 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
288 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
290 -DARMCOMPUTENEON_ENABLED
291 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
292 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
293 ifeq ($(ARMNN_REF_ENABLED),1)
296 endif # ARMNN_REF_ENABLED == 1
298 ifeq ($(Q_OR_LATER),1)
301 endif # PLATFORM_VERSION == Q or later
304 $(ARMNN_BACKEND_TEST_SOURCES) \
305 src/armnn/test/EndToEndTest.cpp \
306 src/armnn/test/GraphTests.cpp \
307 src/armnn/test/GraphUtils.cpp \
308 src/armnn/test/InferOutputTests.cpp \
309 src/armnn/test/InstrumentTests.cpp \
310 src/armnn/test/NetworkTests.cpp \
311 src/armnn/test/ObservableTest.cpp \
312 src/armnn/test/OptionalTest.cpp \
313 src/armnn/test/ProfilingEventTest.cpp \
314 src/armnn/test/SubgraphViewTests.cpp \
315 src/armnn/test/TensorHandleStrategyTest.cpp \
316 src/armnn/test/TensorTest.cpp \
317 src/armnn/test/TestUtils.cpp \
318 src/armnn/test/UnitTests.cpp \
319 src/armnn/test/UtilsTests.cpp
321 ifeq ($(ARMNN_REF_ENABLED),1)
323 src/armnn/test/DebugCallbackTest.cpp \
324 src/armnn/test/RuntimeTests.cpp
327 LOCAL_STATIC_LIBRARIES := \
328 libneuralnetworks_common \
331 libboost_unit_test_framework \
333 libboost_filesystem \
336 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
338 LOCAL_SHARED_LIBRARIES := \
345 android.hardware.neuralnetworks@1.0 \
346 android.hidl.allocator@1.0 \
347 android.hidl.memory@1.0
349 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
350 LOCAL_SHARED_LIBRARIES += \
354 include $(BUILD_EXECUTABLE)