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} 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 stl: "libc++_static", 254 sdk_version: "current", 255 min_sdk_version: "29", 256 cflags: [ 257 "-DNN_COMPATIBILITY_LIBRARY_BUILD", 258 ], 259} 260 261cc_defaults { 262 name: "libneuralnetworks_common_cl_defaults", 263 defaults: [ 264 "neuralnetworks_cl_defaults", 265 "neuralnetworks_defaults", 266 "neuralnetworks_operations", 267 ], 268 host_supported: false, 269 apex_available: [ 270 "//apex_available:platform", 271 "com.android.neuralnetworks", 272 "test_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_float16", 366 "neuralnetworks_use_latest_utils_hal_aidl", 367 ], 368 host_supported: true, 369 shared_libs: [ 370 "android.hidl.allocator@1.0", 371 "android.hidl.memory@1.0", 372 "libcutils", 373 "libhidlbase", 374 "libhidlmemory", 375 "libneuralnetworks", 376 "libneuralnetworks_packageinfo", 377 "libutils", 378 ], 379 static_libs: [ 380 "android.hardware.neuralnetworks@1.0", 381 "android.hardware.neuralnetworks@1.1", 382 "android.hardware.neuralnetworks@1.2", 383 "android.hardware.neuralnetworks@1.3", 384 "libbase", 385 "libgmock", 386 "liblog", 387 "libneuralnetworks_common", 388 "neuralnetworks_types", 389 ], 390 target: { 391 android: { 392 shared_libs: [ 393 "libnativewindow", 394 ], 395 }, 396 host: { 397 cflags: [ 398 "-D__ANDROID_API_S__=31", 399 "-D__INTRODUCED_IN(n)=", 400 ], 401 }, 402 }, 403 local_include_dirs: ["include"], 404} 405 406cc_test { 407 name: "NeuralNetworksTest_operations", 408 defaults: ["NeuralNetworksTest_common"], 409 local_include_dirs: ["types/operations/include"], 410 srcs: [ 411 "cpu_operations/*Test.cpp", 412 ], 413 header_libs: [ 414 "gemmlowp_headers", 415 "libeigen", 416 "philox_random_headers", 417 "tensorflow_headers", 418 ], 419} 420 421cc_test { 422 name: "NeuralNetworksTest_utils", 423 defaults: ["NeuralNetworksTest_common"], 424 srcs: [ 425 "UtilsTest.cpp", 426 ], 427 header_libs: [ 428 "gemmlowp_headers", 429 "libeigen", 430 "tensorflow_headers", 431 ], 432 test_suites: [ 433 "general-tests", 434 ], 435} 436 437cc_test { 438 name: "NeuralNetworksTest_logtag", 439 defaults: ["NeuralNetworksTest_common"], 440 srcs: [ 441 "LogTagTest.cpp", 442 "LogTagTestExtra.cpp", 443 ], 444} 445