• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package {
18    // Inherits all licenses from parent to get Apache 2.0 and package name
19    default_applicable_licenses: [
20        "packages_modules_NeuralNetworks_license",
21    ],
22}
23
24cc_library_headers {
25    name: "libneuralnetworks_common_headers",
26    host_supported: true,
27    export_include_dirs: ["include"],
28}
29
30// The following files took too much time to compile with clang-tidy.
31tidy_disabled_common_operations_files = [
32    "cpu_operations/Activation.cpp",
33    "cpu_operations/Broadcast.cpp",
34    "cpu_operations/Concatenation.cpp",
35    "cpu_operations/Conv2D.cpp",
36    "cpu_operations/FullyConnected.cpp",
37    "cpu_operations/L2Normalization.cpp",
38    "cpu_operations/LocalResponseNormalization.cpp",
39    "cpu_operations/PRelu.cpp",
40    "cpu_operations/Pooling.cpp",
41    "cpu_operations/Reshape.cpp",
42    "cpu_operations/SimpleMath.cpp",
43    "cpu_operations/Softmax.cpp",
44    "cpu_operations/Transpose.cpp",
45]
46
47cc_defaults {
48    name: "neuralnetworks_operations",
49    host_supported: true,
50    local_include_dirs: ["types/operations/include"],
51    srcs: [
52        "OperationResolver.cpp",
53        "cpu_operations/Activation.cpp",
54        "cpu_operations/BatchMatmul.cpp",
55        "cpu_operations/BidirectionalSequenceRNN.cpp",
56        "cpu_operations/Broadcast.cpp",
57        "cpu_operations/ChannelShuffle.cpp",
58        "cpu_operations/Comparisons.cpp",
59        "cpu_operations/Concatenation.cpp",
60        "cpu_operations/Conv2D.cpp",
61        "cpu_operations/Densify.cpp",
62        "cpu_operations/DepthwiseConv2D.cpp",
63        "cpu_operations/Dequantize.cpp",
64        "cpu_operations/Elementwise.cpp",
65        "cpu_operations/Elu.cpp",
66        "cpu_operations/Fill.cpp",
67        "cpu_operations/FullyConnected.cpp",
68        "cpu_operations/Gather.cpp",
69        "cpu_operations/GenerateProposals.cpp",
70        "cpu_operations/HeatmapMaxKeypoint.cpp",
71        "cpu_operations/InstanceNormalization.cpp",
72        "cpu_operations/L2Normalization.cpp",
73        "cpu_operations/LocalResponseNormalization.cpp",
74        "cpu_operations/LogSoftmax.cpp",
75        "cpu_operations/LogicalAndOr.cpp",
76        "cpu_operations/LogicalNot.cpp",
77        "cpu_operations/MirrorPad.cpp",
78        "cpu_operations/Neg.cpp",
79        "cpu_operations/PRelu.cpp",
80        "cpu_operations/Pack.cpp",
81        "cpu_operations/Pooling.cpp",
82        "cpu_operations/QLSTM.cpp",
83        "cpu_operations/Quantize.cpp",
84        "cpu_operations/Rank.cpp",
85        "cpu_operations/Reduce.cpp",
86        "cpu_operations/ResizeImageOps.cpp",
87        "cpu_operations/Reverse.cpp",
88        "cpu_operations/RoiAlign.cpp",
89        "cpu_operations/RoiPooling.cpp",
90        "cpu_operations/Select.cpp",
91        "cpu_operations/Slice.cpp",
92        "cpu_operations/Softmax.cpp",
93        "cpu_operations/Squeeze.cpp",
94        "cpu_operations/StridedSlice.cpp",
95        "cpu_operations/TopK_V2.cpp",
96        "cpu_operations/Transpose.cpp",
97        "cpu_operations/TransposeConv2D.cpp",
98        "cpu_operations/UnidirectionalSequenceLSTM.cpp",
99        "cpu_operations/UnidirectionalSequenceRNN.cpp",
100    ],
101    tidy_disabled_srcs: tidy_disabled_common_operations_files,
102}
103
104// libneuralnetworks_common* provides common utilities for the NNAPI runtime, drivers, and tests to
105// use. Two variants of the common library are provided:
106// - libneuralnetworks_common: the common library, used by NNAPI runtime and tests.
107// - libneuralnetworks_common_experimental: the common library with NN_EXPERIMENTAL_FEATURE flag
108//   turned on, used by NNAPI drivers and tests for experimental features.
109//
110// Both variants of the common library also link against all versions (1.0-3) of the NNAPI HIDL
111// library.
112//
113cc_defaults {
114    name: "libneuralnetworks_common_defaults",
115    defaults: [
116        "neuralnetworks_defaults",
117        "neuralnetworks_operations",
118    ],
119    host_supported: true,
120    apex_available: [
121        "//apex_available:platform",
122        "com.android.neuralnetworks",
123    ],
124    vendor_available: true,
125    // b/109953668, disable OpenMP
126    // openmp: true,
127    export_include_dirs: [
128        "include",
129    ],
130    srcs: [
131        "ActivationFunctor.cpp",
132        "BufferTracker.cpp",
133        "CpuExecutor.cpp",
134        "ExecutionBurstController.cpp",
135        "ExecutionBurstServer.cpp",
136        "GraphDump.cpp",
137        "HalBufferTracker.cpp",
138        "IndexedShapeWrapper.cpp",
139        "LegacyHalUtils.cpp",
140        "LegacyUtils.cpp",
141        "MemoryUtils.cpp",
142        "MetaModel.cpp",
143        "ModelUtils.cpp",
144        "OperationsExecutionUtils.cpp",
145        "QuantUtils.cpp",
146        "TokenHasher.cpp",
147        "ValidateHal.cpp",
148        "cpu_operations/ArgMinMax.cpp",
149        "cpu_operations/BidirectionalSequenceLSTM.cpp",
150        "cpu_operations/Cast.cpp",
151        "cpu_operations/EmbeddingLookup.cpp",
152        "cpu_operations/ExpandDims.cpp",
153        "cpu_operations/GroupedConv2D.cpp",
154        "cpu_operations/HashtableLookup.cpp",
155        "cpu_operations/LSHProjection.cpp",
156        "cpu_operations/LSTM.cpp",
157        "cpu_operations/MaximumMinimum.cpp",
158        "cpu_operations/Multinomial.cpp",
159        "cpu_operations/Pow.cpp",
160        "cpu_operations/QuantizedLSTM.cpp",
161        "cpu_operations/RNN.cpp",
162        "cpu_operations/Reshape.cpp",
163        "cpu_operations/SVDF.cpp",
164        "cpu_operations/SimpleMath.cpp",
165        "cpu_operations/Split.cpp",
166        "cpu_operations/Tile.cpp",
167    ],
168    shared_libs: [
169        "android.hardware.neuralnetworks@1.0",
170        "android.hardware.neuralnetworks@1.1",
171        "android.hardware.neuralnetworks@1.2",
172        "android.hardware.neuralnetworks@1.3",
173        "android.hidl.allocator@1.0",
174        "android.hidl.memory@1.0",
175        "libbase",
176        "libcutils",
177        "libfmq",
178        "libhidlbase",
179        "libhidlmemory",
180        "liblog",
181        "libutils",
182    ],
183    target: {
184        android: {
185            shared_libs: ["libnativewindow"],
186        },
187        host: {
188            cflags: [
189                "-D__INTRODUCED_IN(x)=",
190            ],
191        },
192    },
193    header_libs: [
194        "gemmlowp_headers",
195        "libeigen",
196        "libneuralnetworks_headers",
197        "libtextclassifier_hash_headers",
198        "philox_random_headers",
199        "tensorflow_headers",
200    ],
201    whole_static_libs: [
202        "libarect",
203        "libtflite_kernel_utils",
204        "neuralnetworks_types",
205        "neuralnetworks_utils_hal_1_0", // TODO(b/160669116): Remove VNDK dependencies.
206        "neuralnetworks_utils_hal_1_1",
207        "neuralnetworks_utils_hal_1_2",
208        "neuralnetworks_utils_hal_1_3",
209        "neuralnetworks_utils_hal_common",
210        "philox_random",
211    ],
212    static_libs: [
213        "libcrypto_static",
214        "libruy_static",
215        "libtextclassifier_hash_static",
216        "neuralnetworks_types",
217    ],
218    cflags: [
219        "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
220        "-DNN_INCLUDE_CPU_IMPLEMENTATION",
221        "-DTF_LITE_DISABLE_X86_NEON",
222    ],
223}
224
225cc_library_static {
226    name: "libneuralnetworks_common",
227    defaults: [
228        "libneuralnetworks_common_defaults",
229    ],
230    min_sdk_version: "30",
231}
232
233cc_library_static {
234    name: "libneuralnetworks_common_experimental",
235    defaults: [
236        "libneuralnetworks_common_defaults",
237    ],
238    exclude_static_libs: [
239        "neuralnetworks_types",
240    ],
241    static_libs: [
242        "neuralnetworks_types_experimental",
243    ],
244    cflags: [
245        "-DNN_EXPERIMENTAL_FEATURE",
246    ],
247}
248
249cc_defaults {
250    name: "neuralnetworks_cl_defaults",
251    host_supported: false,
252    vendor_available: false,
253    cpp_std: "gnu++17",
254    stl: "libc++_static",
255    sdk_version: "current",
256    min_sdk_version: "29",
257    cflags: [
258        "-DNN_COMPATIBILITY_LIBRARY_BUILD",
259    ],
260}
261
262cc_defaults {
263    name: "libneuralnetworks_common_cl_defaults",
264    defaults: [
265        "neuralnetworks_cl_defaults",
266        "neuralnetworks_defaults",
267        "neuralnetworks_operations",
268    ],
269    host_supported: false,
270    apex_available: [
271        "//apex_available:platform",
272        "com.android.neuralnetworks",
273    ],
274    // b/109953668, disable OpenMP
275    // openmp: true,
276    export_include_dirs: [
277        "include",
278    ],
279    srcs: [
280        "BufferTracker.cpp",
281        "CpuExecutor.cpp",
282        "GraphDump.cpp",
283        "IndexedShapeWrapper.cpp",
284        "LegacyUtils.cpp",
285        "MetaModel.cpp",
286        "ModelUtils.cpp",
287        "OperationsExecutionUtils.cpp",
288        "TokenHasher.cpp",
289    ],
290    header_libs: [
291        "libneuralnetworks_headers_ndk",
292    ],
293    static_libs: [
294        "libbase_ndk",
295        "libcrypto_static",
296        "neuralnetworks_types_cl",
297    ],
298    shared_libs: [
299        "libnativewindow",
300    ],
301    cflags: [
302        "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
303        "-DTF_LITE_DISABLE_X86_NEON",
304    ],
305}
306
307cc_library_static {
308    name: "libneuralnetworks_common_cl",
309    defaults: ["libneuralnetworks_common_cl_defaults"],
310}
311
312cc_library_static {
313    name: "libneuralnetworks_common_cl_cpu",
314    defaults: ["libneuralnetworks_common_cl_defaults"],
315    local_include_dirs: ["types/operations/include"],
316    header_libs: [
317        "gemmlowp_headers",
318        "libeigen",
319        "libruy_headers",
320        "libtextclassifier_hash_headers",
321        "philox_random_headers",
322        "tensorflow_headers",
323    ],
324    whole_static_libs: [
325        "philox_random_cl",
326    ],
327    static_libs: [
328        "libcrypto_static",
329        "libtextclassifier_hash_static",
330    ],
331    srcs: [
332        "ActivationFunctor.cpp",
333        "QuantUtils.cpp",
334        "cpu_operations/ArgMinMax.cpp",
335        "cpu_operations/BidirectionalSequenceLSTM.cpp",
336        "cpu_operations/Cast.cpp",
337        "cpu_operations/EmbeddingLookup.cpp",
338        "cpu_operations/ExpandDims.cpp",
339        "cpu_operations/GroupedConv2D.cpp",
340        "cpu_operations/HashtableLookup.cpp",
341        "cpu_operations/LSHProjection.cpp",
342        "cpu_operations/LSTM.cpp",
343        "cpu_operations/MaximumMinimum.cpp",
344        "cpu_operations/Multinomial.cpp",
345        "cpu_operations/Pow.cpp",
346        "cpu_operations/QuantizedLSTM.cpp",
347        "cpu_operations/RNN.cpp",
348        "cpu_operations/Reshape.cpp",
349        "cpu_operations/SVDF.cpp",
350        "cpu_operations/SimpleMath.cpp",
351        "cpu_operations/Split.cpp",
352        "cpu_operations/Tile.cpp",
353    ],
354    cflags: [
355        "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
356        "-DNN_COMPATIBILITY_LIBRARY_BUILD",
357        "-DNN_INCLUDE_CPU_IMPLEMENTATION",
358        "-DTF_LITE_DISABLE_X86_NEON",
359    ],
360}
361
362cc_defaults {
363    name: "NeuralNetworksTest_common",
364    defaults: [
365        "neuralnetworks_use_latest_utils_hal_aidl",
366    ],
367    host_supported: true,
368    shared_libs: [
369        "android.hidl.allocator@1.0",
370        "android.hidl.memory@1.0",
371        "libcutils",
372        "libhidlbase",
373        "libhidlmemory",
374        "libneuralnetworks",
375        "libneuralnetworks_packageinfo",
376        "libutils",
377    ],
378    static_libs: [
379        "android.hardware.neuralnetworks@1.0",
380        "android.hardware.neuralnetworks@1.1",
381        "android.hardware.neuralnetworks@1.2",
382        "android.hardware.neuralnetworks@1.3",
383        "libbase",
384        "libgmock",
385        "liblog",
386        "libneuralnetworks_common",
387        "neuralnetworks_types",
388    ],
389    target: {
390        android: {
391            shared_libs: [
392                "libnativewindow",
393            ],
394        },
395        host: {
396            cflags: [
397                "-D__ANDROID_API_S__=31",
398                "-D__INTRODUCED_IN(n)=",
399            ],
400        },
401    },
402    local_include_dirs: ["include"],
403}
404
405cc_test {
406    name: "NeuralNetworksTest_operations",
407    defaults: ["NeuralNetworksTest_common"],
408    local_include_dirs: ["types/operations/include"],
409    srcs: [
410        "cpu_operations/*Test.cpp",
411    ],
412    header_libs: [
413        "gemmlowp_headers",
414        "libeigen",
415        "philox_random_headers",
416        "tensorflow_headers",
417    ],
418    test_suites: [
419        "general-tests",
420    ],
421}
422
423cc_test {
424    name: "NeuralNetworksTest_utils",
425    defaults: ["NeuralNetworksTest_common"],
426    srcs: [
427        "UtilsTest.cpp",
428    ],
429    header_libs: [
430        "gemmlowp_headers",
431        "libeigen",
432        "tensorflow_headers",
433    ],
434    test_suites: [
435        "general-tests",
436    ],
437}
438
439cc_test {
440    name: "NeuralNetworksTest_logtag",
441    defaults: ["NeuralNetworksTest_common"],
442    srcs: [
443        "LogTagTest.cpp",
444        "LogTagTestExtra.cpp",
445    ],
446}
447