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
16 ARMNN_PROFILING_HEADER_PATH := $(LOCAL_PATH)/src/profiling
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_PROFILING_HEADER_PATH) \
69 $(ARMNN_BACKENDS_HEADER_PATH)
72 $(OPENCL_HEADER_PATH) \
74 $(ARMNN_HEADER_PATH) \
75 $(ARMNN_MAIN_HEADER_PATH) \
76 $(ARMNN_SOURCE_HEADER_PATH) \
77 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
78 $(ARMNN_PROFILING_HEADER_PATH) \
79 $(ARMNN_BACKENDS_HEADER_PATH)
82 $(ARMNN_BACKEND_SOURCES) \
83 src/armnn/BackendHelper.cpp \
84 src/armnn/BackendRegistry.cpp \
85 src/armnn/Descriptors.cpp \
86 src/armnn/Exceptions.cpp \
88 src/armnn/InternalTypes.cpp \
89 src/armnn/JsonPrinter.cpp \
91 src/armnn/LayerSupport.cpp \
92 src/armnn/LoadedNetwork.cpp \
93 src/armnn/Logging.cpp \
94 src/armnn/Network.cpp \
95 src/armnn/NetworkUtils.cpp \
96 src/armnn/Observable.cpp \
97 src/armnn/Optimizer.cpp \
98 src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.cpp \
99 src/armnn/OutputHandler.cpp \
100 src/armnn/ProfilingEvent.cpp \
101 src/armnn/Profiling.cpp \
102 src/armnn/Runtime.cpp \
103 src/armnn/SerializeLayerParameters.cpp \
104 src/armnn/SubgraphView.cpp \
105 src/armnn/SubgraphViewSelector.cpp \
106 src/armnn/Tensor.cpp \
107 src/armnn/TypesUtils.cpp \
108 src/armnn/Utils.cpp \
109 src/armnn/WallClockTimer.cpp \
110 src/armnnUtils/CsvReader.cpp \
111 src/armnnUtils/DataLayoutIndexed.cpp \
112 src/armnnUtils/DotSerializer.cpp \
113 src/armnnUtils/FloatingPointConverter.cpp \
114 src/armnnUtils/HeapProfiling.cpp \
115 src/armnnUtils/LeakChecking.cpp \
116 src/armnnUtils/ParserHelper.cpp \
117 src/armnnUtils/Permute.cpp \
118 src/armnnUtils/TensorUtils.cpp \
119 src/armnnUtils/VerificationHelpers.cpp \
120 src/armnnUtils/NetworkSockets.cpp \
121 src/armnnUtils/Filesystem.cpp \
122 src/armnnUtils/Processes.cpp \
123 src/armnn/layers/AbsLayer.cpp \
124 src/armnn/layers/ActivationLayer.cpp \
125 src/armnn/layers/AdditionLayer.cpp \
126 src/armnn/layers/ArgMinMaxLayer.cpp \
127 src/armnn/layers/BatchNormalizationLayer.cpp \
128 src/armnn/layers/BatchToSpaceNdLayer.cpp \
129 src/armnn/layers/ComparisonLayer.cpp \
130 src/armnn/layers/ConcatLayer.cpp \
131 src/armnn/layers/ConstantLayer.cpp \
132 src/armnn/layers/Convolution2dLayer.cpp \
133 src/armnn/layers/ConvertFp16ToFp32Layer.cpp \
134 src/armnn/layers/ConvertFp32ToFp16Layer.cpp \
135 src/armnn/layers/DebugLayer.cpp \
136 src/armnn/layers/DepthToSpaceLayer.cpp \
137 src/armnn/layers/DepthwiseConvolution2dLayer.cpp \
138 src/armnn/layers/DequantizeLayer.cpp \
139 src/armnn/layers/DetectionPostProcessLayer.cpp \
140 src/armnn/layers/DivisionLayer.cpp \
141 src/armnn/layers/ElementwiseBaseLayer.cpp \
142 src/armnn/layers/FakeQuantizationLayer.cpp \
143 src/armnn/layers/FloorLayer.cpp \
144 src/armnn/layers/FullyConnectedLayer.cpp \
145 src/armnn/layers/GatherLayer.cpp \
146 src/armnn/layers/InputLayer.cpp \
147 src/armnn/layers/InstanceNormalizationLayer.cpp \
148 src/armnn/layers/L2NormalizationLayer.cpp \
149 src/armnn/layers/LogSoftmaxLayer.cpp \
150 src/armnn/layers/LstmLayer.cpp \
151 src/armnn/layers/MaximumLayer.cpp \
152 src/armnn/layers/MeanLayer.cpp \
153 src/armnn/layers/MemCopyLayer.cpp \
154 src/armnn/layers/MemImportLayer.cpp \
155 src/armnn/layers/MergeLayer.cpp \
156 src/armnn/layers/MinimumLayer.cpp \
157 src/armnn/layers/MultiplicationLayer.cpp \
158 src/armnn/layers/NormalizationLayer.cpp \
159 src/armnn/layers/OutputLayer.cpp \
160 src/armnn/layers/PadLayer.cpp \
161 src/armnn/layers/PermuteLayer.cpp \
162 src/armnn/layers/Pooling2dLayer.cpp \
163 src/armnn/layers/PreCompiledLayer.cpp \
164 src/armnn/layers/PreluLayer.cpp \
165 src/armnn/layers/QuantizeLayer.cpp \
166 src/armnn/layers/QuantizedLstmLayer.cpp \
167 src/armnn/layers/ReshapeLayer.cpp \
168 src/armnn/layers/ResizeLayer.cpp \
169 src/armnn/layers/RsqrtLayer.cpp \
170 src/armnn/layers/SliceLayer.cpp \
171 src/armnn/layers/SoftmaxLayer.cpp \
172 src/armnn/layers/SpaceToBatchNdLayer.cpp \
173 src/armnn/layers/SpaceToDepthLayer.cpp \
174 src/armnn/layers/SplitterLayer.cpp \
175 src/armnn/layers/StackLayer.cpp \
176 src/armnn/layers/StandInLayer.cpp \
177 src/armnn/layers/StridedSliceLayer.cpp \
178 src/armnn/layers/SubtractionLayer.cpp \
179 src/armnn/layers/SwitchLayer.cpp \
180 src/armnn/layers/TransposeConvolution2dLayer.cpp \
181 src/profiling/BufferManager.cpp \
182 src/profiling/CommandHandler.cpp \
183 src/profiling/CommandHandlerFunctor.cpp \
184 src/profiling/CommandHandlerKey.cpp \
185 src/profiling/CommandHandlerRegistry.cpp \
186 src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
187 src/profiling/CounterDirectory.cpp \
188 src/profiling/DirectoryCaptureCommandHandler.cpp \
189 src/profiling/FileOnlyProfilingConnection.cpp \
190 src/profiling/Holder.cpp \
191 src/profiling/LabelsAndEventClasses.cpp \
192 src/profiling/PacketBuffer.cpp \
193 src/profiling/PacketVersionResolver.cpp \
194 src/profiling/PeriodicCounterCapture.cpp \
195 src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
196 src/profiling/PerJobCounterSelectionCommandHandler.cpp \
197 src/profiling/ProfilingConnectionDumpToFileDecorator.cpp \
198 src/profiling/ProfilingConnectionFactory.cpp \
199 src/profiling/ProfilingService.cpp \
200 src/profiling/ProfilingStateMachine.cpp \
201 src/profiling/ProfilingUtils.cpp \
202 src/profiling/RequestCounterDirectoryCommandHandler.cpp \
203 src/profiling/SendCounterPacket.cpp \
204 src/profiling/SendTimelinePacket.cpp \
205 src/profiling/SocketProfilingConnection.cpp \
206 src/profiling/TimelinePacketWriterFactory.cpp \
207 src/profiling/TimelineUtilityMethods.cpp
209 LOCAL_STATIC_LIBRARIES := \
216 LOCAL_SHARED_LIBRARIES := \
220 -std=$(CPP_VERSION) \
222 -Wno-unused-parameter \
225 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
226 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
228 -DARMCOMPUTECL_ENABLED
229 endif # ARMNN_COMPUTE_CL_ENABLED == 1
230 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
231 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
233 -DARMCOMPUTENEON_ENABLED
234 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
235 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
236 ifeq ($(ARMNN_REF_ENABLED),1)
239 endif # ARMNN_REF_ENABLED == 1
241 ifeq ($(Q_OR_LATER),1)
243 -DARMNN_MIXED_PRECISION_FP16_POOLING \
245 endif # PLATFORM_VERSION == Q or later
247 include $(BUILD_STATIC_LIBRARY)
252 include $(CLEAR_VARS)
254 LOCAL_MODULE := armnn-tests
255 ifeq ($(Q_OR_LATER),1)
256 # "eng" is deprecated in Android Q
257 LOCAL_MODULE_TAGS := optional
259 LOCAL_MODULE_TAGS := eng optional
261 LOCAL_ARM_MODE := arm
262 LOCAL_PROPRIETARY_MODULE := true
264 # placeholder to hold all backend unit test source files
265 ARMNN_BACKEND_TEST_SOURCES :=
268 # iterate through the backend common and specific include paths, include them into the current
269 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
270 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
272 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
273 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
274 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
275 $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
277 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
278 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
279 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
280 $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
282 # Mark source files as dependent on Android.mk
283 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
285 LOCAL_C_INCLUDES := \
286 $(OPENCL_HEADER_PATH) \
288 $(ARMNN_HEADER_PATH) \
289 $(ARMNN_MAIN_HEADER_PATH) \
290 $(ARMNN_SOURCE_HEADER_PATH) \
291 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
292 $(ARMNN_PROFILING_HEADER_PATH) \
293 $(ARMNN_BACKENDS_HEADER_PATH)
296 -std=$(CPP_VERSION) \
299 -isystem vendor/arm/android-nn-driver/boost_1_64_0
301 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
302 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
304 -DARMCOMPUTECL_ENABLED
305 endif # ARMNN_COMPUTE_CL_ENABLED == 1
306 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
307 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
309 -DARMCOMPUTENEON_ENABLED
310 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
311 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
312 ifeq ($(ARMNN_REF_ENABLED),1)
315 endif # ARMNN_REF_ENABLED == 1
317 ifeq ($(Q_OR_LATER),1)
320 endif # PLATFORM_VERSION == Q or later
323 $(ARMNN_BACKEND_TEST_SOURCES) \
324 src/armnn/test/EndToEndTest.cpp \
325 src/armnn/test/GraphTests.cpp \
326 src/armnn/test/GraphUtils.cpp \
327 src/armnn/test/InferOutputTests.cpp \
328 src/armnn/test/InstrumentTests.cpp \
329 src/armnn/test/NetworkTests.cpp \
330 src/armnn/test/ObservableTest.cpp \
331 src/armnn/test/OptionalTest.cpp \
332 src/armnn/test/ProfilingEventTest.cpp \
333 src/armnn/test/SubgraphViewTests.cpp \
334 src/armnn/test/TensorHandleStrategyTest.cpp \
335 src/armnn/test/TensorTest.cpp \
336 src/armnn/test/TestUtils.cpp \
337 src/armnn/test/UnitTests.cpp \
338 src/armnn/test/UtilsTests.cpp \
339 src/profiling/test/ProfilingTestUtils.cpp
341 ifeq ($(ARMNN_REF_ENABLED),1)
343 src/armnn/test/DebugCallbackTest.cpp \
344 src/armnn/test/RuntimeTests.cpp
347 LOCAL_STATIC_LIBRARIES := \
348 libneuralnetworks_common \
351 libboost_unit_test_framework \
353 libboost_filesystem \
356 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
358 LOCAL_SHARED_LIBRARIES := \
365 android.hardware.neuralnetworks@1.0 \
366 android.hidl.allocator@1.0 \
367 android.hidl.memory@1.0
369 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
370 LOCAL_SHARED_LIBRARIES += \
374 include $(BUILD_EXECUTABLE)