• 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    default_applicable_licenses: [
19        "packages_modules_NeuralNetworks_runtime_license",
20    ],
21}
22
23// Added automatically by a large-scale-change that took the approach of
24// 'apply every license found to every target'. While this makes sure we respect
25// every license restriction, it may not be entirely correct.
26//
27// e.g. GPL in an MIT project might only apply to the contrib/ directory.
28//
29// Please consider splitting the single license below into multiple licenses,
30// taking care not to lose any license_kind information, and overriding the
31// default license using the 'licenses: [...]' property on targets as needed.
32//
33// For unused files, consider creating a 'fileGroup' with "//visibility:private"
34// to attach the license to, and including a comment whether the files may be
35// used in the current project.
36// See: http://go/android-license-faq
37license {
38    name: "packages_modules_NeuralNetworks_runtime_license",
39    package_name: "Android Neural Networks API Runtime",
40    visibility: [":__subpackages__"],
41    license_kinds: [
42        "SPDX-license-identifier-Apache-2.0",
43        "SPDX-license-identifier-BSD",
44        "SPDX-license-identifier-MPL",
45        "SPDX-license-identifier-MPL-2.0",
46    ],
47    license_text: [
48        "NOTICE",
49    ],
50}
51
52cc_library_headers {
53    name: "libneuralnetworks_headers",
54    host_supported: true,
55    vendor_available: true,
56    export_include_dirs: ["include"],
57    min_sdk_version: "30",
58    apex_available: [
59        "com.android.neuralnetworks",
60
61        // Due to the dependency from libneuralnetworks_common
62        // that is available to the platform
63        "//apex_available:platform",
64    ],
65}
66
67cc_library_headers {
68    name: "libneuralnetworks_headers_ndk",
69    host_supported: true,
70    export_include_dirs: ["include"],
71    sdk_version: "current",
72}
73
74cc_library_headers {
75    name: "libneuralnetworks_private_headers",
76    host_supported: true,
77    export_include_dirs: ["."],
78}
79
80cc_defaults {
81    name: "libneuralnetworks_defaults",
82    defaults: ["neuralnetworks_use_latest_utils_hal_aidl"],
83    host_supported: true,
84    use_version_lib: true,
85    // b/109953668, disable OpenMP
86    // openmp: true,
87    srcs: [
88        "AppInfoFetcher.cpp",
89        "BurstBuilder.cpp",
90        "CompilationBuilder.cpp",
91        "ExecutionBuilder.cpp",
92        "ExecutionCallback.cpp",
93        "ExecutionPlan.cpp",
94        "Manager.cpp",
95        "Memory.cpp",
96        "ModelArchHasher.cpp",
97        "ModelArgumentInfo.cpp",
98        "ModelBuilder.cpp",
99        "NeuralNetworks.cpp",
100        "ServerFlag.cpp",
101        "Telemetry.cpp",
102        "TypeManager.cpp",
103    ],
104    target: {
105        android: {
106            version_script: "libneuralnetworks.map.txt",
107            generated_sources: ["statslog_neuralnetworks.cpp"],
108            generated_headers: ["statslog_neuralnetworks.h"],
109            srcs: [
110                "TelemetryStatsd.cpp",
111            ],
112            shared_libs: [
113                "libnativewindow",
114                "libstatssocket",
115                "libvndksupport",
116            ],
117            whole_static_libs: [
118                "libprocpartition",
119            ],
120        },
121        host: {
122            cflags: [
123                "-D__INTRODUCED_IN(n)=",
124            ],
125        },
126    },
127
128    // TODO(pszczepaniak, b/144488395): Use system libnativewindow,
129    // this would remove half of dependencies here.
130    static_libs: [
131        "android.hardware.neuralnetworks@1.0",
132        "android.hardware.neuralnetworks@1.1",
133        "android.hardware.neuralnetworks@1.2",
134        "android.hardware.neuralnetworks@1.3",
135        "android.hidl.allocator@1.0",
136        "android.hidl.memory@1.0",
137        "libaidlcommonsupport",
138        "libbase",
139        "libcrypto_static",
140        "libcutils",
141        "libfmq",
142        "libhidlbase",
143        "libhidlmemory",
144        "libmath",
145        "libneuralnetworks_common",
146        "libtextclassifier_hash_static",
147        "libutils",
148        "neuralnetworks_types",
149        "neuralnetworks_utils_hal_service",
150        "server_configurable_flags",
151    ],
152
153    stl: "libc++_static",
154
155    shared_libs: [
156        "libbinder_ndk",
157        "liblog",
158        "libneuralnetworks_packageinfo",
159    ],
160
161    header_libs: [
162        "libneuralnetworks_headers",
163    ],
164
165    export_header_lib_headers: [
166        "libneuralnetworks_headers",
167    ],
168}
169
170cc_defaults {
171    name: "libneuralnetworks_v2_defaults",
172    defaults: ["libneuralnetworks_defaults"],
173    srcs: [
174        "FlatbufferModelBuilder.cpp",
175        "NeuralNetworksV2.cpp",
176        "operation_converters/AddOperationConverter.cpp",
177        "operation_converters/ArithmeticOperationConverter.cpp",
178        "operation_converters/Conv2DOperationConverter.cpp",
179        "operation_converters/DepthwiseConv2DOperationConverter.cpp",
180        "operation_converters/LogisticOperationConverter.cpp",
181        "operation_converters/OperationConverterResolver.cpp",
182        "operation_converters/SubGraphContext.cpp",
183    ],
184
185    exclude_srcs: [
186        "NeuralNetworks.cpp",
187    ],
188
189    static_libs: [
190        "libtflite_static",
191    ],
192
193    include_dirs: [
194        "external/flatbuffers/include",
195        "external/tensorflow",
196    ],
197}
198
199cc_library_shared {
200    name: "libneuralnetworks",
201    llndk: {
202        symbol_file: "libneuralnetworks.map.txt",
203        override_export_include_dirs: ["include"],
204        moved_to_apex: true,
205    },
206    defaults: [
207        "libneuralnetworks_defaults",
208        "neuralnetworks_defaults",
209    ],
210    min_sdk_version: "30",
211    apex_available: ["com.android.neuralnetworks"],
212    stubs: {
213        versions: [
214            "30",
215            "31",
216        ],
217        symbol_file: "libneuralnetworks.map.txt",
218    },
219}
220
221// Required for tests (b/147158681)
222cc_library_static {
223    name: "libneuralnetworks_static",
224    defaults: [
225        "libneuralnetworks_defaults",
226        "neuralnetworks_defaults",
227    ],
228    apex_available: ["//apex_available:platform"],
229}
230
231// Required for tests (b/147158681)
232cc_library_static {
233    name: "libneuralnetworks_static_experimental",
234    defaults: [
235        "libneuralnetworks_defaults",
236        "neuralnetworks_defaults",
237    ],
238    exclude_static_libs: [
239        "libneuralnetworks_common",
240        "neuralnetworks_types",
241        "server_configurable_flags",
242    ],
243    static_libs: [
244        "libneuralnetworks_common_experimental",
245        "neuralnetworks_types_experimental",
246    ],
247    cflags: ["-DNN_EXPERIMENTAL_FEATURE"],
248    apex_available: ["//apex_available:platform"],
249}
250
251cc_library_static {
252    name: "libneuralnetworks_v2_static_experimental",
253    defaults: [
254        "libneuralnetworks_v2_defaults",
255        "neuralnetworks_defaults",
256    ],
257    exclude_static_libs: [
258        "libneuralnetworks_common",
259        "neuralnetworks_types",
260        "server_configurable_flags",
261    ],
262    static_libs: [
263        "libneuralnetworks_common_experimental",
264        "neuralnetworks_types_experimental",
265    ],
266    cflags: ["-DNN_EXPERIMENTAL_FEATURE"],
267}
268
269cc_library_static {
270    name: "libneuralnetworks_cl",
271    defaults: [
272        "neuralnetworks_cl_defaults",
273        "neuralnetworks_defaults",
274    ],
275    host_supported: false,
276    apex_available: ["//apex_available:platform"],
277    // b/109953668, disable OpenMP
278    // openmp: true,
279    srcs: [
280        "BurstBuilder.cpp",
281        "CompilationBuilder.cpp",
282        "ExecutionBuilder.cpp",
283        "ExecutionCallback.cpp",
284        "ExecutionPlan.cpp",
285        "Manager.cpp",
286        "Memory.cpp",
287        "ModelArchHasher.cpp",
288        "ModelArgumentInfo.cpp",
289        "ModelBuilder.cpp",
290        "NeuralNetworks.cpp",
291        "ServerFlag.cpp",
292        "SupportLibraryDiagnostic.cpp",
293        "Telemetry.cpp",
294        "TypeManager.cpp",
295    ],
296    static_libs: [
297        "libbase_ndk",
298        "libcrypto_static",
299        "libneuralnetworks_common_cl",
300        "neuralnetworks_types_cl",
301    ],
302    shared_libs: [
303        "libnativewindow",
304    ],
305    header_libs: [
306        "libneuralnetworks_headers_ndk",
307        "neuralnetworks_supportlibrary_types_ndk",
308    ],
309    export_header_lib_headers: [
310        "libneuralnetworks_headers_ndk",
311    ],
312}
313
314ndk_headers {
315    name: "libneuralnetworks_ndk_headers",
316    from: "include",
317    to: "android",
318    srcs: [
319        "include/NeuralNetworks.h",
320        "include/NeuralNetworksTypes.h",
321    ],
322    license: "NOTICE",
323}
324
325ndk_library {
326    name: "libneuralnetworks",
327    symbol_file: "libneuralnetworks.map.txt",
328    // Android O-MR1
329    first_version: "27",
330}
331
332genrule {
333    name: "statslog_neuralnetworks.h",
334    tools: ["stats-log-api-gen"],
335    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_neuralnetworks.h --module neuralnetworks --namespace android,nn,stats",
336    out: [
337        "statslog_neuralnetworks.h",
338    ],
339}
340
341genrule {
342    name: "statslog_neuralnetworks.cpp",
343    tools: ["stats-log-api-gen"],
344    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_neuralnetworks.cpp --module neuralnetworks --namespace android,nn,stats  --importHeader statslog_neuralnetworks.h",
345    out: [
346        "statslog_neuralnetworks.cpp",
347    ],
348}
349