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 "test_com.android.neuralnetworks", 124 ], 125 vendor_available: true, 126 // b/109953668, disable OpenMP 127 // openmp: true, 128 export_include_dirs: [ 129 "include", 130 ], 131 srcs: [ 132 "ActivationFunctor.cpp", 133 "BufferTracker.cpp", 134 "CpuExecutor.cpp", 135 "ExecutionBurstController.cpp", 136 "ExecutionBurstServer.cpp", 137 "GraphDump.cpp", 138 "HalBufferTracker.cpp", 139 "IndexedShapeWrapper.cpp", 140 "LegacyHalUtils.cpp", 141 "LegacyUtils.cpp", 142 "MemoryUtils.cpp", 143 "MetaModel.cpp", 144 "ModelUtils.cpp", 145 "OperationsExecutionUtils.cpp", 146 "QuantUtils.cpp", 147 "TokenHasher.cpp", 148 "ValidateHal.cpp", 149 "cpu_operations/ArgMinMax.cpp", 150 "cpu_operations/BidirectionalSequenceLSTM.cpp", 151 "cpu_operations/Cast.cpp", 152 "cpu_operations/EmbeddingLookup.cpp", 153 "cpu_operations/ExpandDims.cpp", 154 "cpu_operations/GroupedConv2D.cpp", 155 "cpu_operations/HashtableLookup.cpp", 156 "cpu_operations/LSHProjection.cpp", 157 "cpu_operations/LSTM.cpp", 158 "cpu_operations/MaximumMinimum.cpp", 159 "cpu_operations/Multinomial.cpp", 160 "cpu_operations/Pow.cpp", 161 "cpu_operations/QuantizedLSTM.cpp", 162 "cpu_operations/RNN.cpp", 163 "cpu_operations/Reshape.cpp", 164 "cpu_operations/SVDF.cpp", 165 "cpu_operations/SimpleMath.cpp", 166 "cpu_operations/Split.cpp", 167 "cpu_operations/Tile.cpp", 168 ], 169 shared_libs: [ 170 "android.hardware.neuralnetworks@1.0", 171 "android.hardware.neuralnetworks@1.1", 172 "android.hardware.neuralnetworks@1.2", 173 "android.hardware.neuralnetworks@1.3", 174 "android.hidl.allocator@1.0", 175 "android.hidl.memory@1.0", 176 "libbase", 177 "libcutils", 178 "libfmq", 179 "libhidlbase", 180 "libhidlmemory", 181 "liblog", 182 "libutils", 183 ], 184 target: { 185 android: { 186 shared_libs: ["libnativewindow"], 187 }, 188 host: { 189 cflags: [ 190 "-D__INTRODUCED_IN(x)=", 191 ], 192 }, 193 }, 194 header_libs: [ 195 "gemmlowp_headers", 196 "libeigen", 197 "libneuralnetworks_headers", 198 "libtextclassifier_hash_headers", 199 "philox_random_headers", 200 "tensorflow_headers", 201 ], 202 whole_static_libs: [ 203 "libarect", 204 "libtflite_kernel_utils", 205 "neuralnetworks_types", 206 "neuralnetworks_utils_hal_1_0", // TODO(b/160669116): Remove VNDK dependencies. 207 "neuralnetworks_utils_hal_1_1", 208 "neuralnetworks_utils_hal_1_2", 209 "neuralnetworks_utils_hal_1_3", 210 "neuralnetworks_utils_hal_common", 211 "philox_random", 212 ], 213 static_libs: [ 214 "libcrypto_static", 215 "libruy_static", 216 "libtextclassifier_hash_static", 217 "neuralnetworks_types", 218 ], 219 cflags: [ 220 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 221 "-DNN_INCLUDE_CPU_IMPLEMENTATION", 222 "-DTF_LITE_DISABLE_X86_NEON", 223 ], 224} 225 226cc_library_static { 227 name: "libneuralnetworks_common", 228 defaults: [ 229 "libneuralnetworks_common_defaults", 230 ], 231 min_sdk_version: "30", 232} 233 234cc_library_static { 235 name: "libneuralnetworks_common_experimental", 236 defaults: [ 237 "libneuralnetworks_common_defaults", 238 ], 239 exclude_static_libs: [ 240 "neuralnetworks_types", 241 ], 242 static_libs: [ 243 "neuralnetworks_types_experimental", 244 ], 245 cflags: [ 246 "-DNN_EXPERIMENTAL_FEATURE", 247 ], 248} 249 250cc_defaults { 251 name: "neuralnetworks_cl_defaults", 252 host_supported: false, 253 vendor_available: false, 254 cpp_std: "gnu++17", 255 stl: "libc++_static", 256 sdk_version: "current", 257 min_sdk_version: "29", 258 cflags: [ 259 "-DNN_COMPATIBILITY_LIBRARY_BUILD", 260 ], 261} 262 263cc_defaults { 264 name: "libneuralnetworks_common_cl_defaults", 265 defaults: [ 266 "neuralnetworks_cl_defaults", 267 "neuralnetworks_defaults", 268 "neuralnetworks_operations", 269 ], 270 host_supported: false, 271 apex_available: [ 272 "//apex_available:platform", 273 "com.android.neuralnetworks", 274 "test_com.android.neuralnetworks", 275 ], 276 // b/109953668, disable OpenMP 277 // openmp: true, 278 export_include_dirs: [ 279 "include", 280 ], 281 srcs: [ 282 "BufferTracker.cpp", 283 "CpuExecutor.cpp", 284 "GraphDump.cpp", 285 "IndexedShapeWrapper.cpp", 286 "LegacyUtils.cpp", 287 "MetaModel.cpp", 288 "ModelUtils.cpp", 289 "OperationsExecutionUtils.cpp", 290 "TokenHasher.cpp", 291 ], 292 header_libs: [ 293 "libneuralnetworks_headers_ndk", 294 ], 295 static_libs: [ 296 "libbase_ndk", 297 "libcrypto_static", 298 "neuralnetworks_types_cl", 299 ], 300 shared_libs: [ 301 "libnativewindow", 302 ], 303 cflags: [ 304 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 305 "-DTF_LITE_DISABLE_X86_NEON", 306 ], 307} 308 309cc_library_static { 310 name: "libneuralnetworks_common_cl", 311 defaults: ["libneuralnetworks_common_cl_defaults"], 312} 313 314cc_library_static { 315 name: "libneuralnetworks_common_cl_cpu", 316 defaults: ["libneuralnetworks_common_cl_defaults"], 317 local_include_dirs: ["types/operations/include"], 318 header_libs: [ 319 "gemmlowp_headers", 320 "libeigen", 321 "libruy_headers", 322 "libtextclassifier_hash_headers", 323 "philox_random_headers", 324 "tensorflow_headers", 325 ], 326 whole_static_libs: [ 327 "philox_random_cl", 328 ], 329 static_libs: [ 330 "libcrypto_static", 331 "libtextclassifier_hash_static", 332 ], 333 srcs: [ 334 "ActivationFunctor.cpp", 335 "QuantUtils.cpp", 336 "cpu_operations/ArgMinMax.cpp", 337 "cpu_operations/BidirectionalSequenceLSTM.cpp", 338 "cpu_operations/Cast.cpp", 339 "cpu_operations/EmbeddingLookup.cpp", 340 "cpu_operations/ExpandDims.cpp", 341 "cpu_operations/GroupedConv2D.cpp", 342 "cpu_operations/HashtableLookup.cpp", 343 "cpu_operations/LSHProjection.cpp", 344 "cpu_operations/LSTM.cpp", 345 "cpu_operations/MaximumMinimum.cpp", 346 "cpu_operations/Multinomial.cpp", 347 "cpu_operations/Pow.cpp", 348 "cpu_operations/QuantizedLSTM.cpp", 349 "cpu_operations/RNN.cpp", 350 "cpu_operations/Reshape.cpp", 351 "cpu_operations/SVDF.cpp", 352 "cpu_operations/SimpleMath.cpp", 353 "cpu_operations/Split.cpp", 354 "cpu_operations/Tile.cpp", 355 ], 356 cflags: [ 357 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 358 "-DNN_COMPATIBILITY_LIBRARY_BUILD", 359 "-DNN_INCLUDE_CPU_IMPLEMENTATION", 360 "-DTF_LITE_DISABLE_X86_NEON", 361 ], 362} 363 364cc_defaults { 365 name: "NeuralNetworksTest_common", 366 defaults: [ 367 "neuralnetworks_use_latest_utils_hal_aidl", 368 ], 369 host_supported: true, 370 shared_libs: [ 371 "android.hidl.allocator@1.0", 372 "android.hidl.memory@1.0", 373 "libcutils", 374 "libhidlbase", 375 "libhidlmemory", 376 "libneuralnetworks", 377 "libneuralnetworks_packageinfo", 378 "libutils", 379 ], 380 static_libs: [ 381 "android.hardware.neuralnetworks@1.0", 382 "android.hardware.neuralnetworks@1.1", 383 "android.hardware.neuralnetworks@1.2", 384 "android.hardware.neuralnetworks@1.3", 385 "libbase", 386 "libgmock", 387 "liblog", 388 "libneuralnetworks_common", 389 "neuralnetworks_types", 390 ], 391 target: { 392 android: { 393 shared_libs: [ 394 "libnativewindow", 395 ], 396 }, 397 host: { 398 cflags: [ 399 "-D__ANDROID_API_S__=31", 400 "-D__INTRODUCED_IN(n)=", 401 ], 402 }, 403 }, 404 local_include_dirs: ["include"], 405} 406 407cc_test { 408 name: "NeuralNetworksTest_operations", 409 defaults: ["NeuralNetworksTest_common"], 410 local_include_dirs: ["types/operations/include"], 411 srcs: [ 412 "cpu_operations/*Test.cpp", 413 ], 414 header_libs: [ 415 "gemmlowp_headers", 416 "libeigen", 417 "philox_random_headers", 418 "tensorflow_headers", 419 ], 420 test_suites: [ 421 "general-tests", 422 ], 423} 424 425cc_test { 426 name: "NeuralNetworksTest_utils", 427 defaults: ["NeuralNetworksTest_common"], 428 srcs: [ 429 "UtilsTest.cpp", 430 ], 431 header_libs: [ 432 "gemmlowp_headers", 433 "libeigen", 434 "tensorflow_headers", 435 ], 436 test_suites: [ 437 "general-tests", 438 ], 439} 440 441cc_test { 442 name: "NeuralNetworksTest_logtag", 443 defaults: ["NeuralNetworksTest_common"], 444 srcs: [ 445 "LogTagTest.cpp", 446 "LogTagTestExtra.cpp", 447 ], 448} 449