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 "test_com.android.neuralnetworks", // Due to the dependency from libneuralnetworks_common 61 // that is available to the platform 62 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 "[email protected]", 132 "[email protected]", 133 "[email protected]", 134 "[email protected]", 135 "[email protected]", 136 "[email protected]", 137 "libaidlcommonsupport", 138 "libbase", 139 "libcrypto_static", 140 "libcutils", 141 "libfmq", 142 "libhidlbase", 143 "libhidlmemory", 144 "libjsoncpp", 145 "libmath", 146 "libneuralnetworks_common", 147 "libprocessgroup", 148 "libtextclassifier_hash_static", 149 "libutils", 150 "neuralnetworks_types", 151 "neuralnetworks_utils_hal_service", 152 "server_configurable_flags", 153 ], 154 155 stl: "libc++_static", 156 157 shared_libs: [ 158 "libbinder_ndk", 159 "liblog", 160 "libneuralnetworks_packageinfo", 161 ], 162 163 header_libs: [ 164 "libneuralnetworks_headers", 165 ], 166 167 export_header_lib_headers: [ 168 "libneuralnetworks_headers", 169 ], 170} 171 172cc_defaults { 173 name: "libneuralnetworks_v2_defaults", 174 defaults: ["libneuralnetworks_defaults"], 175 srcs: [ 176 "FlatbufferModelBuilder.cpp", 177 "NeuralNetworksV2.cpp", 178 "operation_converters/AddOperationConverter.cpp", 179 "operation_converters/ArithmeticOperationConverter.cpp", 180 "operation_converters/Conv2DOperationConverter.cpp", 181 "operation_converters/DepthwiseConv2DOperationConverter.cpp", 182 "operation_converters/LogisticOperationConverter.cpp", 183 "operation_converters/OperationConverterResolver.cpp", 184 "operation_converters/SubGraphContext.cpp", 185 ], 186 187 exclude_srcs: [ 188 "NeuralNetworks.cpp", 189 ], 190 191 static_libs: [ 192 "libtflite_static", 193 ], 194 195 include_dirs: [ 196 "external/flatbuffers/include", 197 "external/tensorflow", 198 ], 199} 200 201cc_library_shared { 202 name: "libneuralnetworks", 203 llndk: { 204 symbol_file: "libneuralnetworks.map.txt", 205 override_export_include_dirs: ["include"], 206 moved_to_apex: true, 207 }, 208 defaults: [ 209 "libneuralnetworks_defaults", 210 "neuralnetworks_defaults", 211 ], 212 min_sdk_version: "30", 213 apex_available: [ 214 "com.android.neuralnetworks", 215 "test_com.android.neuralnetworks", 216 ], 217 stubs: { 218 versions: [ 219 "30", 220 "31", 221 ], 222 symbol_file: "libneuralnetworks.map.txt", 223 }, 224} 225 226// Required for tests (b/147158681) 227cc_library_static { 228 name: "libneuralnetworks_static", 229 defaults: [ 230 "libneuralnetworks_defaults", 231 "neuralnetworks_defaults", 232 ], 233 apex_available: ["//apex_available:platform"], 234} 235 236// Required for tests (b/147158681) 237cc_library_static { 238 name: "libneuralnetworks_static_experimental", 239 defaults: [ 240 "libneuralnetworks_defaults", 241 "neuralnetworks_defaults", 242 ], 243 exclude_static_libs: [ 244 "libneuralnetworks_common", 245 "neuralnetworks_types", 246 "server_configurable_flags", 247 ], 248 static_libs: [ 249 "libneuralnetworks_common_experimental", 250 "neuralnetworks_types_experimental", 251 ], 252 cflags: ["-DNN_EXPERIMENTAL_FEATURE"], 253 apex_available: ["//apex_available:platform"], 254} 255 256cc_library_static { 257 name: "libneuralnetworks_v2_static_experimental", 258 defaults: [ 259 "libneuralnetworks_v2_defaults", 260 "neuralnetworks_defaults", 261 ], 262 exclude_static_libs: [ 263 "libneuralnetworks_common", 264 "neuralnetworks_types", 265 "server_configurable_flags", 266 ], 267 static_libs: [ 268 "libneuralnetworks_common_experimental", 269 "neuralnetworks_types_experimental", 270 ], 271 cflags: ["-DNN_EXPERIMENTAL_FEATURE"], 272} 273 274cc_library_static { 275 name: "libneuralnetworks_cl", 276 defaults: [ 277 "neuralnetworks_cl_defaults", 278 "neuralnetworks_defaults", 279 ], 280 host_supported: false, 281 apex_available: ["//apex_available:platform"], 282 // b/109953668, disable OpenMP 283 // openmp: true, 284 srcs: [ 285 "BurstBuilder.cpp", 286 "CompilationBuilder.cpp", 287 "ExecutionBuilder.cpp", 288 "ExecutionCallback.cpp", 289 "ExecutionPlan.cpp", 290 "Manager.cpp", 291 "Memory.cpp", 292 "ModelArchHasher.cpp", 293 "ModelArgumentInfo.cpp", 294 "ModelBuilder.cpp", 295 "NeuralNetworks.cpp", 296 "ServerFlag.cpp", 297 "SupportLibraryDiagnostic.cpp", 298 "Telemetry.cpp", 299 "TypeManager.cpp", 300 ], 301 static_libs: [ 302 "libbase_ndk", 303 "libcrypto_static", 304 "libneuralnetworks_common_cl", 305 "neuralnetworks_types_cl", 306 ], 307 shared_libs: [ 308 "libnativewindow", 309 ], 310 header_libs: [ 311 "libneuralnetworks_headers_ndk", 312 "neuralnetworks_supportlibrary_types_ndk", 313 ], 314 export_header_lib_headers: [ 315 "libneuralnetworks_headers_ndk", 316 ], 317} 318 319ndk_headers { 320 name: "libneuralnetworks_ndk_headers", 321 from: "include", 322 to: "android", 323 srcs: [ 324 "include/NeuralNetworks.h", 325 "include/NeuralNetworksTypes.h", 326 ], 327 license: "NOTICE", 328} 329 330ndk_library { 331 name: "libneuralnetworks", 332 symbol_file: "libneuralnetworks.map.txt", 333 // Android O-MR1 334 first_version: "27", 335} 336 337genrule { 338 name: "statslog_neuralnetworks.h", 339 tools: ["stats-log-api-gen"], 340 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_neuralnetworks.h --module neuralnetworks --namespace android,nn,stats", 341 out: [ 342 "statslog_neuralnetworks.h", 343 ], 344} 345 346genrule { 347 name: "statslog_neuralnetworks.cpp", 348 tools: ["stats-log-api-gen"], 349 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_neuralnetworks.cpp --module neuralnetworks --namespace android,nn,stats --importHeader statslog_neuralnetworks.h", 350 out: [ 351 "statslog_neuralnetworks.cpp", 352 ], 353} 354