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