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/NetworkSockets.cpp \
96 src/armnn/BackendHelper.cpp \
97 src/armnn/BackendRegistry.cpp \
98 src/armnn/Descriptors.cpp \
99 src/armnn/Exceptions.cpp \
100 src/armnn/Graph.cpp \
101 src/armnn/InternalTypes.cpp \
102 src/armnn/JsonPrinter.cpp \
103 src/armnn/Layer.cpp \
104 src/armnn/LayerSupport.cpp \
105 src/armnn/LoadedNetwork.cpp \
106 src/armnn/Logging.cpp \
107 src/armnn/Network.cpp \
108 src/armnn/NetworkUtils.cpp \
109 src/armnn/Observable.cpp \
110 src/armnn/Optimizer.cpp \
111 src/armnn/OutputHandler.cpp \
112 src/armnn/ProfilingEvent.cpp \
113 src/armnn/Profiling.cpp \
114 src/armnn/Runtime.cpp \
115 src/armnn/SerializeLayerParameters.cpp \
116 src/armnn/SubgraphView.cpp \
117 src/armnn/SubgraphViewSelector.cpp \
118 src/armnn/Tensor.cpp \
119 src/armnn/TypesUtils.cpp \
120 src/armnn/Utils.cpp \
121 src/armnn/WallClockTimer.cpp \
122 src/armnnUtils/CsvReader.cpp \
123 src/armnnUtils/DataLayoutIndexed.cpp \
124 src/armnnUtils/DotSerializer.cpp \
125 src/armnnUtils/FloatingPointConverter.cpp \
126 src/armnnUtils/HeapProfiling.cpp \
127 src/armnnUtils/LeakChecking.cpp \
128 src/armnnUtils/ParserHelper.cpp \
129 src/armnnUtils/Permute.cpp \
130 src/armnnUtils/TensorUtils.cpp \
131 src/armnnUtils/VerificationHelpers.cpp \
132 src/armnnUtils/Filesystem.cpp \
133 src/armnnUtils/Processes.cpp \
134 src/armnnUtils/Threads.cpp \
135 src/armnnUtils/Transpose.cpp \
136 src/armnn/layers/ActivationLayer.cpp \
137 src/armnn/layers/AdditionLayer.cpp \
138 src/armnn/layers/ArgMinMaxLayer.cpp \
139 src/armnn/layers/BatchNormalizationLayer.cpp \
140 src/armnn/layers/BatchToSpaceNdLayer.cpp \
141 src/armnn/layers/ComparisonLayer.cpp \
142 src/armnn/layers/ConcatLayer.cpp \
143 src/armnn/layers/ConstantLayer.cpp \
144 src/armnn/layers/Convolution2dLayer.cpp \
145 src/armnn/layers/ConvertBf16ToFp32Layer.cpp \
146 src/armnn/layers/ConvertFp16ToFp32Layer.cpp \
147 src/armnn/layers/ConvertFp32ToBf16Layer.cpp \
148 src/armnn/layers/ConvertFp32ToFp16Layer.cpp \
149 src/armnn/layers/DebugLayer.cpp \
150 src/armnn/layers/DepthToSpaceLayer.cpp \
151 src/armnn/layers/DepthwiseConvolution2dLayer.cpp \
152 src/armnn/layers/DequantizeLayer.cpp \
153 src/armnn/layers/DetectionPostProcessLayer.cpp \
154 src/armnn/layers/DivisionLayer.cpp \
155 src/armnn/layers/ElementwiseBaseLayer.cpp \
156 src/armnn/layers/ElementwiseUnaryLayer.cpp \
157 src/armnn/layers/FakeQuantizationLayer.cpp \
158 src/armnn/layers/FillLayer.cpp \
159 src/armnn/layers/FloorLayer.cpp \
160 src/armnn/layers/FullyConnectedLayer.cpp \
161 src/armnn/layers/GatherLayer.cpp \
162 src/armnn/layers/InputLayer.cpp \
163 src/armnn/layers/InstanceNormalizationLayer.cpp \
164 src/armnn/layers/L2NormalizationLayer.cpp \
165 src/armnn/layers/LogSoftmaxLayer.cpp \
166 src/armnn/layers/LstmLayer.cpp \
167 src/armnn/layers/MaximumLayer.cpp \
168 src/armnn/layers/MeanLayer.cpp \
169 src/armnn/layers/MemCopyLayer.cpp \
170 src/armnn/layers/MemImportLayer.cpp \
171 src/armnn/layers/MergeLayer.cpp \
172 src/armnn/layers/MinimumLayer.cpp \
173 src/armnn/layers/MultiplicationLayer.cpp \
174 src/armnn/layers/NormalizationLayer.cpp \
175 src/armnn/layers/OutputLayer.cpp \
176 src/armnn/layers/PadLayer.cpp \
177 src/armnn/layers/PermuteLayer.cpp \
178 src/armnn/layers/Pooling2dLayer.cpp \
179 src/armnn/layers/PreCompiledLayer.cpp \
180 src/armnn/layers/PreluLayer.cpp \
181 src/armnn/layers/QLstmLayer.cpp \
182 src/armnn/layers/QuantizeLayer.cpp \
183 src/armnn/layers/QuantizedLstmLayer.cpp \
184 src/armnn/layers/RankLayer.cpp \
185 src/armnn/layers/ReshapeLayer.cpp \
186 src/armnn/layers/ResizeLayer.cpp \
187 src/armnn/layers/SliceLayer.cpp \
188 src/armnn/layers/SoftmaxLayer.cpp \
189 src/armnn/layers/SpaceToBatchNdLayer.cpp \
190 src/armnn/layers/SpaceToDepthLayer.cpp \
191 src/armnn/layers/SplitterLayer.cpp \
192 src/armnn/layers/StackLayer.cpp \
193 src/armnn/layers/StandInLayer.cpp \
194 src/armnn/layers/StridedSliceLayer.cpp \
195 src/armnn/layers/SubtractionLayer.cpp \
196 src/armnn/layers/SwitchLayer.cpp \
197 src/armnn/layers/TransposeConvolution2dLayer.cpp \
198 src/armnn/layers/TransposeLayer.cpp \
199 src/profiling/ActivateTimelineReportingCommandHandler.cpp \
200 src/profiling/BufferManager.cpp \
201 src/profiling/CommandHandler.cpp \
202 src/profiling/CommandHandlerFunctor.cpp \
203 src/profiling/CommandHandlerKey.cpp \
204 src/profiling/CommandHandlerRegistry.cpp \
205 src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
206 src/profiling/CounterDirectory.cpp \
207 src/profiling/CounterIdMap.cpp \
208 src/profiling/DeactivateTimelineReportingCommandHandler.cpp \
209 src/profiling/DirectoryCaptureCommandHandler.cpp \
210 src/profiling/FileOnlyProfilingConnection.cpp \
211 src/profiling/Holder.cpp \
212 src/profiling/LabelsAndEventClasses.cpp \
213 src/profiling/PacketBuffer.cpp \
214 src/profiling/PacketVersionResolver.cpp \
215 src/profiling/PeriodicCounterCapture.cpp \
216 src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
217 src/profiling/PerJobCounterSelectionCommandHandler.cpp \
218 src/profiling/ProfilingConnectionDumpToFileDecorator.cpp \
219 src/profiling/ProfilingConnectionFactory.cpp \
220 src/profiling/ProfilingService.cpp \
221 src/profiling/ProfilingStateMachine.cpp \
222 src/profiling/ProfilingUtils.cpp \
223 src/profiling/RegisterBackendCounters.cpp \
224 src/profiling/RequestCounterDirectoryCommandHandler.cpp \
225 src/profiling/SendCounterPacket.cpp \
226 src/profiling/SendThread.cpp \
227 src/profiling/SendTimelinePacket.cpp \
228 src/profiling/SocketProfilingConnection.cpp \
229 src/profiling/TimelinePacketWriterFactory.cpp \
230 src/profiling/TimelineUtilityMethods.cpp \
231 src/profiling/backends/BackendProfiling.cpp \
232 src/timelineDecoder/TimelineCaptureCommandHandler.cpp \
233 src/timelineDecoder/TimelineDecoder.cpp \
234 src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
236 LOCAL_STATIC_LIBRARIES := \
237 arm_compute_library \
243 LOCAL_SHARED_LIBRARIES := \
247 -std=$(CPP_VERSION) \
249 -Wno-unused-parameter \
252 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
253 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
255 -DARMCOMPUTECL_ENABLED
256 endif # ARMNN_COMPUTE_CL_ENABLED == 1
257 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
258 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
260 -DARMCOMPUTENEON_ENABLED
261 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
262 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
263 ifeq ($(ARMNN_REF_ENABLED),1)
266 endif # ARMNN_REF_ENABLED == 1
268 ifeq ($(Q_OR_LATER),1)
270 -DARMNN_MIXED_PRECISION_FP16_POOLING \
272 endif # PLATFORM_VERSION == Q or later
274 include $(BUILD_STATIC_LIBRARY)
279 include $(CLEAR_VARS)
281 LOCAL_MODULE := armnn-tests
282 ifeq ($(Q_OR_LATER),1)
283 # "eng" is deprecated in Android Q
284 LOCAL_MODULE_TAGS := optional
286 LOCAL_MODULE_TAGS := eng optional
288 LOCAL_ARM_MODE := arm
289 LOCAL_PROPRIETARY_MODULE := true
291 # placeholder to hold all backend unit test source files
292 ARMNN_BACKEND_TEST_SOURCES :=
295 # iterate through the backend common and specific include paths, include them into the current
296 # makefile and append the sources held by the COMMON_TEST_SOURCES and BACKEND_TEST_SOURCES
297 # (included from the given makefile) to the ARMNN_BACKEND_TEST_SOURCES list
299 $(foreach mkPath,$(ARMNN_BACKEND_COMMON_MAKEFILE_DIRS), \
300 $(eval include $(LOCAL_PATH)/$(mkPath)/common.mk) \
301 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
302 $(patsubst %,$(mkPath)/%,$(COMMON_TEST_SOURCES))))
304 $(foreach mkPath,$(ARMNN_BACKEND_MAKEFILE_DIRS), \
305 $(eval include $(LOCAL_PATH)/$(mkPath)/backend.mk) \
306 $(eval ARMNN_BACKEND_TEST_SOURCES := $(ARMNN_BACKEND_TEST_SOURCES) \
307 $(patsubst %,$(mkPath)/%,$(BACKEND_TEST_SOURCES))))
309 # Mark source files as dependent on Android.mk
310 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
312 LOCAL_C_INCLUDES := \
313 $(OPENCL_HEADER_PATH) \
315 $(ARMNN_HEADER_PATH) \
316 $(ARMNN_PROFILING_INCLUDE_PATH) \
317 $(ARMNN_PROFILING_COMMON_INCLUDE_PATH) \
318 $(ARMNN_TIMELINE_DECODER_INCLUDE_PATH) \
319 $(ARMNN_THIRD_PARTY_INCLUDE_PATH) \
320 $(ARMNN_MAIN_HEADER_PATH) \
321 $(ARMNN_SOURCE_HEADER_PATH) \
322 $(ARMNN_SOURCE_UTILS_HEADER_PATH) \
323 $(ARMNN_PROFILING_HEADER_PATH) \
324 $(ARMNN_BACKENDS_HEADER_PATH)
327 -std=$(CPP_VERSION) \
330 -isystem vendor/arm/android-nn-driver/boost_1_64_0
332 # The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk
333 ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1)
335 -DARMCOMPUTECL_ENABLED
336 endif # ARMNN_COMPUTE_CL_ENABLED == 1
337 # The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk
338 ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1)
340 -DARMCOMPUTENEON_ENABLED
341 endif # ARMNN_COMPUTE_NEON_ENABLED == 1
342 # The variable to enable/disable the REFERENCE backend (ARMNN_REF_ENABLED) is declared in android-nn-driver/Android.mk
343 ifeq ($(ARMNN_REF_ENABLED),1)
346 endif # ARMNN_REF_ENABLED == 1
348 ifeq ($(Q_OR_LATER),1)
351 endif # PLATFORM_VERSION == Q or later
354 $(ARMNN_BACKEND_TEST_SOURCES) \
355 src/armnn/test/ConstTensorLayerVisitor.cpp \
356 src/armnn/test/CsvReaderTest.cpp \
357 src/armnn/test/EndToEndTest.cpp \
358 src/armnn/ExecutionFrame.cpp \
359 src/armnn/test/ExecutionFrameTest.cpp \
360 src/armnn/test/FloatingPointConverterTest.cpp \
361 src/armnn/test/FlowControl.cpp \
362 src/armnn/test/GraphTests.cpp \
363 src/armnn/test/GraphUtils.cpp \
364 src/armnn/test/InferOutputTests.cpp \
365 src/armnn/test/InstrumentTests.cpp \
366 src/armnnUtils/ModelAccuracyChecker.cpp \
367 src/armnn/test/ModelAccuracyCheckerTest.cpp \
368 src/armnn/test/NetworkTests.cpp \
369 src/armnn/test/ObservableTest.cpp \
370 src/armnn/test/optimizations/ConvertConstantsBFloatTests.cpp \
371 src/armnn/test/optimizations/ConvertConstantsFloatToHalfTests.cpp \
372 src/armnn/test/optimizations/ConvertConstantsHalfToFloatTests.cpp \
373 src/armnn/test/optimizations/Fp32NetworkToBf16ConverterTests.cpp \
374 src/armnn/test/optimizations/Fp32NetworkToFp16ConverterTests.cpp \
375 src/armnn/test/optimizations/InsertDebugLayerTests.cpp \
376 src/armnn/test/optimizations/MovePermuteUpTests.cpp \
377 src/armnn/test/optimizations/OptimizeConsecutiveReshapesTests.cpp \
378 src/armnn/test/optimizations/OptimizeInverseConversionsTests.cpp \
379 src/armnn/test/optimizations/OptimizeInversePermutesTests.cpp \
380 src/armnn/test/optimizations/PermuteAndBatchToSpaceAsDepthToSpaceTests.cpp \
381 src/armnn/test/optimizations/PermuteAsReshapeTests.cpp \
382 src/armnn/test/optimizations/SquashEqualSiblingsTests.cpp \
383 src/armnn/test/optimizations/TransposeAsReshapeTests.cpp \
384 src/armnn/test/OptimizerTests.cpp \
385 src/armnn/test/OptionalTest.cpp \
386 src/armnn/test/ProfilerTests.cpp \
387 src/armnn/test/ProfilingEventTest.cpp \
388 src/armnnUtils/PrototxtConversions.cpp \
389 src/armnnUtils/test/PrototxtConversionsTest.cpp \
390 src/armnn/test/SubgraphViewTests.cpp \
391 src/armnn/test/TensorHandleStrategyTest.cpp \
392 src/armnn/test/TensorTest.cpp \
393 src/armnn/test/TestInputOutputLayerVisitor.cpp \
394 src/armnn/test/TestLayerVisitor.cpp \
395 src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp \
396 src/armnn/test/TestNameOnlyLayerVisitor.cpp \
397 src/armnn/test/TestUtils.cpp \
398 src/armnn/test/UnitTests.cpp \
399 src/armnn/test/UtilsTests.cpp \
400 src/armnnUtils/test/ParserHelperTest.cpp \
401 src/armnnUtils/test/QuantizeHelperTest.cpp \
402 src/armnnUtils/test/TensorUtilsTest.cpp \
403 src/profiling/test/BufferTests.cpp \
404 src/profiling/test/FileOnlyProfilingDecoratorTests.cpp \
405 src/profiling/test/PrintPacketHeaderHandler.cpp \
406 src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp \
407 src/profiling/test/ProfilingGuidTest.cpp \
408 src/profiling/test/ProfilingTests.cpp \
409 src/profiling/test/ProfilingTestUtils.cpp \
410 src/profiling/test/SendCounterPacketTests.cpp \
411 src/profiling/test/SendTimelinePacketTests.cpp \
412 src/profiling/test/TestTimelinePacketHandler.cpp \
413 src/profiling/test/TimelineModel.cpp \
414 src/profiling/test/TimelinePacketTests.cpp \
415 src/profiling/test/TimelineUtilityMethodsTests.cpp
417 ifeq ($(ARMNN_REF_ENABLED),1)
419 src/armnn/test/DebugCallbackTest.cpp \
420 src/armnn/test/RuntimeTests.cpp
423 LOCAL_STATIC_LIBRARIES := \
424 libneuralnetworks_common \
427 libboost_unit_test_framework \
429 libboost_filesystem \
432 LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
434 LOCAL_SHARED_LIBRARIES := \
441 android.hardware.neuralnetworks@1.0 \
442 android.hidl.allocator@1.0 \
443 android.hidl.memory@1.0
445 ifeq ($(ARMNN_INCLUDE_LIBOPENCL),1)
446 LOCAL_SHARED_LIBRARIES += \
450 include $(BUILD_EXECUTABLE)