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: ["Android-Apache-2.0"], 19} 20 21cc_library_headers { 22 name: "libneuralnetworks_common_headers", 23 host_supported: false, 24 export_include_dirs: ["include"], 25} 26 27cc_defaults { 28 name: "neuralnetworks_operations", 29 srcs: [ 30 "OperationResolver.cpp", 31 "operations/Activation.cpp", 32 "operations/BidirectionalSequenceRNN.cpp", 33 "operations/Broadcast.cpp", 34 "operations/ChannelShuffle.cpp", 35 "operations/Comparisons.cpp", 36 "operations/Concatenation.cpp", 37 "operations/Conv2D.cpp", 38 "operations/DepthwiseConv2D.cpp", 39 "operations/Dequantize.cpp", 40 "operations/Elementwise.cpp", 41 "operations/Elu.cpp", 42 "operations/Fill.cpp", 43 "operations/FullyConnected.cpp", 44 "operations/Gather.cpp", 45 "operations/GenerateProposals.cpp", 46 "operations/HeatmapMaxKeypoint.cpp", 47 "operations/InstanceNormalization.cpp", 48 "operations/L2Normalization.cpp", 49 "operations/LocalResponseNormalization.cpp", 50 "operations/LogSoftmax.cpp", 51 "operations/LogicalAndOr.cpp", 52 "operations/LogicalNot.cpp", 53 "operations/Neg.cpp", 54 "operations/PRelu.cpp", 55 "operations/Pooling.cpp", 56 "operations/QLSTM.cpp", 57 "operations/Quantize.cpp", 58 "operations/Rank.cpp", 59 "operations/Reduce.cpp", 60 "operations/ResizeImageOps.cpp", 61 "operations/RoiAlign.cpp", 62 "operations/RoiPooling.cpp", 63 "operations/Select.cpp", 64 "operations/Slice.cpp", 65 "operations/Softmax.cpp", 66 "operations/Squeeze.cpp", 67 "operations/StridedSlice.cpp", 68 "operations/TopK_V2.cpp", 69 "operations/Transpose.cpp", 70 "operations/TransposeConv2D.cpp", 71 "operations/UnidirectionalSequenceLSTM.cpp", 72 "operations/UnidirectionalSequenceRNN.cpp", 73 ], 74} 75 76cc_library_static { 77 name: "libneuralnetworks_utils", 78 defaults: [ 79 "neuralnetworks_defaults", 80 "neuralnetworks_operations", 81 ], 82 host_supported: false, 83 vendor_available: true, 84 apex_available: [ 85 "//apex_available:platform", 86 "com.android.neuralnetworks", 87 "test_com.android.neuralnetworks", 88 ], 89 export_include_dirs: ["include"], 90 srcs: [ 91 "AidlHalUtils.cpp", 92 "ExecutionBurstController.cpp", 93 "ExecutionBurstServer.cpp", 94 "LegacyHalUtils.cpp", 95 "LegacyUtils.cpp", 96 "MemoryUtils.cpp", 97 ], 98 header_libs: [ 99 "gemmlowp_headers", 100 "libeigen", 101 "libneuralnetworks_headers", 102 "libruy_headers", 103 "tensorflow_headers", 104 ], 105 shared_libs: [ 106 "android.hardware.neuralnetworks-V1-ndk_platform", 107 "android.hardware.neuralnetworks@1.0", 108 "android.hardware.neuralnetworks@1.1", 109 "android.hardware.neuralnetworks@1.2", 110 "android.hardware.neuralnetworks@1.3", 111 "android.hidl.allocator@1.0", 112 "android.hidl.memory@1.0", 113 "libfmq", 114 "libhidlbase", 115 "libhidlmemory", 116 "libnativewindow", 117 ], 118 whole_static_libs: [ 119 "libarect", 120 "neuralnetworks_types", 121 "neuralnetworks_utils_hal_1_0", // TODO(b/160669116): Remove VNDK dependencies. 122 "neuralnetworks_utils_hal_1_1", 123 "neuralnetworks_utils_hal_1_2", 124 "neuralnetworks_utils_hal_1_3", 125 "neuralnetworks_utils_hal_aidl", 126 "neuralnetworks_utils_hal_common", 127 ], 128 cflags: [ 129 "-DTF_LITE_DISABLE_X86_NEON", 130 "-Wall", 131 "-Werror", 132 "-Wextra", 133 "-Wno-extern-c-compat", 134 "-Wno-invalid-partial-specialization", 135 "-Wno-sign-compare", 136 "-Wno-unused-local-typedef", 137 "-Wno-unused-parameter", 138 "-Wno-unused-private-field", 139 "-Wno-unused-variable", 140 ], 141} 142 143cc_library_static { 144 name: "libneuralnetworks_common", 145 defaults: [ 146 "neuralnetworks_defaults", 147 "neuralnetworks_operations", 148 ], 149 apex_available: [ 150 "//apex_available:platform", 151 "com.android.neuralnetworks", 152 "test_com.android.neuralnetworks", 153 ], 154 host_supported: false, 155 vendor_available: true, 156 // b/109953668, disable OpenMP 157 // openmp: true, 158 export_include_dirs: [ 159 "include", 160 ], 161 srcs: [ 162 "AidlBufferTracker.cpp", 163 "AidlHalUtils.cpp", 164 "AidlValidateHal.cpp", 165 "BufferTracker.cpp", 166 "CpuExecutor.cpp", 167 "ExecutionBurstController.cpp", 168 "ExecutionBurstServer.cpp", 169 "GraphDump.cpp", 170 "HalBufferTracker.cpp", 171 "IndexedShapeWrapper.cpp", 172 "LegacyHalUtils.cpp", 173 "LegacyUtils.cpp", 174 "MemoryUtils.cpp", 175 "MetaModel.cpp", 176 "OperationsUtils.cpp", 177 "QuantUtils.cpp", 178 "TokenHasher.cpp", 179 "ValidateHal.cpp", 180 "operations/ArgMinMax.cpp", 181 "operations/BidirectionalSequenceLSTM.cpp", 182 "operations/Cast.cpp", 183 "operations/EmbeddingLookup.cpp", 184 "operations/ExpandDims.cpp", 185 "operations/GroupedConv2D.cpp", 186 "operations/HashtableLookup.cpp", 187 "operations/LSHProjection.cpp", 188 "operations/LSTM.cpp", 189 "operations/MaximumMinimum.cpp", 190 "operations/Multinomial.cpp", 191 "operations/Pow.cpp", 192 "operations/QuantizedLSTM.cpp", 193 "operations/RNN.cpp", 194 "operations/Reshape.cpp", 195 "operations/SVDF.cpp", 196 "operations/SimpleMath.cpp", 197 "operations/Split.cpp", 198 "operations/Tile.cpp", 199 ], 200 shared_libs: [ 201 "android.hardware.neuralnetworks-V1-ndk_platform", 202 "android.hardware.neuralnetworks@1.0", 203 "android.hardware.neuralnetworks@1.1", 204 "android.hardware.neuralnetworks@1.2", 205 "android.hardware.neuralnetworks@1.3", 206 "android.hidl.allocator@1.0", 207 "android.hidl.memory@1.0", 208 "libbase", 209 "libcutils", 210 "libfmq", 211 "libhidlbase", 212 "libhidlmemory", 213 "liblog", 214 "libnativewindow", 215 "libutils", 216 ], 217 header_libs: [ 218 "gemmlowp_headers", 219 "libeigen", 220 "libneuralnetworks_headers", 221 "libtextclassifier_hash_headers", 222 "philox_random_headers", 223 "tensorflow_headers", 224 ], 225 whole_static_libs: [ 226 "libarect", 227 "libtflite_kernel_utils", 228 "neuralnetworks_types", 229 "neuralnetworks_utils_hal_1_0", // TODO(b/160669116): Remove VNDK dependencies. 230 "neuralnetworks_utils_hal_1_1", 231 "neuralnetworks_utils_hal_1_2", 232 "neuralnetworks_utils_hal_1_3", 233 "neuralnetworks_utils_hal_aidl", 234 "neuralnetworks_utils_hal_common", 235 "neuralnetworks_utils_hal_service", 236 "philox_random", 237 ], 238 static_libs: [ 239 "libcrypto_static", 240 "libruy_static", 241 "libtextclassifier_hash_static", 242 ], 243 cflags: [ 244 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 245 "-DNN_INCLUDE_CPU_IMPLEMENTATION", 246 "-DTF_LITE_DISABLE_X86_NEON", 247 "-Wall", 248 "-Werror", 249 "-Wextra", 250 "-Wno-array-bounds", 251 "-Wno-extern-c-compat", 252 "-Wno-invalid-partial-specialization", 253 "-Wno-sign-compare", 254 "-Wno-unused-local-typedef", 255 "-Wno-unused-parameter", 256 "-Wno-unused-private-field", 257 "-Wno-unused-variable", 258 ], 259} 260 261cc_defaults { 262 name: "neuralnetworks_cl_defaults", 263 host_supported: false, 264 vendor_available: false, 265 stl: "libc++_static", 266 sdk_version: "current", 267 min_sdk_version: "29", 268 cflags: [ 269 "-DNN_COMPATIBILITY_LIBRARY_BUILD", 270 ], 271} 272 273cc_defaults { 274 name: "libneuralnetworks_common_cl_defaults", 275 defaults: [ 276 "neuralnetworks_cl_defaults", 277 "neuralnetworks_defaults", 278 "neuralnetworks_operations", 279 ], 280 apex_available: [ 281 "//apex_available:platform", 282 "com.android.neuralnetworks", 283 "test_com.android.neuralnetworks", 284 ], 285 // b/109953668, disable OpenMP 286 // openmp: true, 287 export_include_dirs: [ 288 "include", 289 ], 290 srcs: [ 291 "BufferTracker.cpp", 292 "CpuExecutor.cpp", 293 "GraphDump.cpp", 294 "IndexedShapeWrapper.cpp", 295 "LegacyUtils.cpp", 296 "MetaModel.cpp", 297 "OperationsUtils.cpp", 298 "TokenHasher.cpp", 299 ], 300 header_libs: [ 301 "libneuralnetworks_headers_ndk", 302 ], 303 static_libs: [ 304 "libbase_ndk", 305 "libcrypto_static", 306 ], 307 shared_libs: [ 308 "libnativewindow", 309 ], 310 cflags: [ 311 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 312 "-DTF_LITE_DISABLE_X86_NEON", 313 "-Wall", 314 "-Werror", 315 "-Wextra", 316 "-Wno-array-bounds", 317 "-Wno-extern-c-compat", 318 "-Wno-invalid-partial-specialization", 319 "-Wno-sign-compare", 320 "-Wno-unused-local-typedef", 321 "-Wno-unused-parameter", 322 "-Wno-unused-private-field", 323 "-Wno-unused-variable", 324 ], 325} 326 327cc_library_static { 328 name: "libneuralnetworks_common_cl", 329 defaults: ["libneuralnetworks_common_cl_defaults"], 330} 331 332cc_library_static { 333 name: "libneuralnetworks_common_cl_cpu", 334 defaults: ["libneuralnetworks_common_cl_defaults"], 335 sdk_version: "", // Override neuralnetworks_cl_defaults 336 min_sdk_version: "", 337 header_libs: [ 338 "gemmlowp_headers", 339 "libeigen", 340 "libruy_headers", 341 "libtextclassifier_hash_headers", 342 "philox_random_headers", 343 "tensorflow_headers", 344 ], 345 whole_static_libs: [ 346 "libarect", 347 "libtflite_kernel_utils", 348 "neuralnetworks_types_cl", 349 "philox_random", 350 ], 351 static_libs: [ 352 "libcrypto_static", 353 "libtextclassifier_hash_static", 354 ], 355 srcs: [ 356 "QuantUtils.cpp", 357 "operations/ArgMinMax.cpp", 358 "operations/BidirectionalSequenceLSTM.cpp", 359 "operations/Cast.cpp", 360 "operations/EmbeddingLookup.cpp", 361 "operations/ExpandDims.cpp", 362 "operations/GroupedConv2D.cpp", 363 "operations/HashtableLookup.cpp", 364 "operations/LSHProjection.cpp", 365 "operations/LSTM.cpp", 366 "operations/MaximumMinimum.cpp", 367 "operations/Multinomial.cpp", 368 "operations/Pow.cpp", 369 "operations/QuantizedLSTM.cpp", 370 "operations/RNN.cpp", 371 "operations/Reshape.cpp", 372 "operations/SVDF.cpp", 373 "operations/SimpleMath.cpp", 374 "operations/Split.cpp", 375 "operations/Tile.cpp", 376 ], 377 cflags: [ 378 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 379 "-DNN_COMPATIBILITY_LIBRARY_BUILD", 380 "-DNN_INCLUDE_CPU_IMPLEMENTATION", 381 "-DTF_LITE_DISABLE_X86_NEON", 382 "-Wno-array-bounds", 383 "-Wno-extern-c-compat", 384 "-Wno-invalid-partial-specialization", 385 "-Wno-sign-compare", 386 "-Wno-unused-local-typedef", 387 "-Wno-unused-parameter", 388 "-Wno-unused-private-field", 389 "-Wno-unused-variable", 390 ], 391} 392 393cc_defaults { 394 name: "neuralnetworks_utils_defaults", 395 // b/146324523, NNAPI host build capability 396 host_supported: false, 397 vendor_available: true, 398 apex_available: [ 399 "//apex_available:platform", 400 "com.android.neuralnetworks", 401 "test_com.android.neuralnetworks", 402 ], 403 min_sdk_version: "30", 404 cflags: [ 405 "-Wall", 406 "-Werror", 407 "-Wextra", 408 ], 409} 410 411cc_library_static { 412 name: "neuralnetworks_types", 413 defaults: ["neuralnetworks_utils_defaults"], 414 srcs: [ 415 "SharedMemory.cpp", 416 "TypeUtils.cpp", 417 "Types.cpp", 418 "Validation.cpp", 419 ], 420 target: { 421 android: { 422 srcs: ["SharedMemoryAndroid.cpp"], 423 shared_libs: [ 424 "android.hidl.allocator@1.0", 425 "android.hidl.memory@1.0", 426 "libhidlbase", 427 "libhidlmemory", 428 "libnativewindow", 429 ], 430 static_libs: ["libarect"], 431 }, 432 }, 433 local_include_dirs: ["include/nnapi"], 434 export_include_dirs: ["include"], 435 shared_libs: [ 436 "libbase", 437 "libcutils", 438 "libutils", 439 ], 440 export_shared_lib_headers: [ 441 "libbase", 442 "libcutils", 443 "libutils", 444 ], 445} 446 447cc_library_static { 448 name: "neuralnetworks_types_cl", 449 defaults: [ 450 "neuralnetworks_cl_defaults", 451 "neuralnetworks_utils_defaults", 452 ], 453 srcs: [ 454 "DynamicCLDeps.cpp", 455 "SharedMemory.cpp", 456 "SharedMemoryAndroid.cpp", 457 "TypeUtils.cpp", 458 "Types.cpp", 459 "Validation.cpp", 460 ], 461 local_include_dirs: ["include/nnapi"], 462 export_include_dirs: ["include"], 463 static_libs: [ 464 "libbase_ndk", 465 ], 466 export_static_lib_headers: [ 467 "libbase_ndk", 468 ], 469 shared_libs: [ 470 "libandroid", 471 ], 472} 473 474cc_defaults { 475 name: "NeuralNetworksTest_common", 476 defaults: ["neuralnetworks_float16"], 477 shared_libs: [ 478 "android.hidl.allocator@1.0", 479 "android.hidl.memory@1.0", 480 "libhidlbase", 481 "libhidlmemory", 482 "libnativewindow", 483 "libneuralnetworks", 484 "libneuralnetworks_packageinfo", 485 "libutils", 486 ], 487 static_libs: [ 488 "android.hardware.neuralnetworks-V1-ndk_platform", 489 "android.hardware.neuralnetworks@1.0", 490 "android.hardware.neuralnetworks@1.1", 491 "android.hardware.neuralnetworks@1.2", 492 "android.hardware.neuralnetworks@1.3", 493 "libbase", 494 "libgmock", 495 "liblog", 496 "libneuralnetworks_common", 497 ], 498 cflags: [ 499 "-Wno-extern-c-compat", 500 ], 501 local_include_dirs: ["include"], 502} 503 504cc_test { 505 name: "NeuralNetworksTest_operations", 506 defaults: ["NeuralNetworksTest_common"], 507 srcs: [ 508 "operations/*Test.cpp", 509 ], 510 header_libs: [ 511 "gemmlowp_headers", 512 "libeigen", 513 "philox_random_headers", 514 "tensorflow_headers", 515 ], 516 cflags: [ 517 "-Wno-invalid-partial-specialization", 518 "-Wno-unused-parameter", 519 ], 520} 521 522cc_test { 523 name: "NeuralNetworksTest_utils", 524 defaults: ["NeuralNetworksTest_common"], 525 srcs: [ 526 "UtilsTest.cpp", 527 ], 528 header_libs: [ 529 "gemmlowp_headers", 530 "libeigen", 531 "tensorflow_headers", 532 ], 533 cflags: [ 534 "-Wno-unused-parameter", 535 "-Wno-unused-variable", 536 ], 537 test_suites: [ 538 "general-tests", 539 ], 540} 541 542cc_test { 543 name: "NeuralNetworksTest_logtag", 544 defaults: ["NeuralNetworksTest_common"], 545 srcs: [ 546 "LogTagTest.cpp", 547 "LogTagTestExtra.cpp", 548 ], 549} 550