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