1load("//tensorflow/lite:special_rules.bzl", "if_nnapi") 2load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable") 3 4package( 5 default_visibility = [ 6 "//visibility:public", 7 ], 8 licenses = ["notice"], # Apache 2.0 9) 10 11cc_library( 12 name = "nnapi_lib", 13 hdrs = [ 14 "NeuralNetworksShim.h", 15 "NeuralNetworksTypes.h", 16 ], 17 compatible_with = get_compatible_with_portable(), 18 linkopts = if_nnapi(["-ldl"]), 19) 20 21cc_library( 22 name = "nnapi_implementation", 23 srcs = if_nnapi( 24 not_supported = ["nnapi_implementation_disabled.cc"], 25 supported = ["nnapi_implementation.cc"], 26 ), 27 hdrs = [ 28 "nnapi_implementation.h", 29 ], 30 compatible_with = get_compatible_with_portable(), 31 linkopts = if_nnapi(["-ldl"]) + if_nnapi( 32 supported = ["-lrt"], 33 supported_android = [], 34 ), 35 deps = [ 36 ":nnapi_lib", 37 ], 38) 39 40cc_library( 41 name = "nnapi_util", 42 srcs = ["nnapi_util.cc"], 43 hdrs = ["nnapi_util.h"], 44 compatible_with = get_compatible_with_portable(), 45 deps = [ 46 ":nnapi_implementation", 47 "//tensorflow/lite:util", 48 "//tensorflow/lite/c:common", 49 ], 50) 51 52cc_test( 53 name = "nnapi_implementation_test", 54 srcs = ["nnapi_implementation_test.cc"], 55 deps = [ 56 ":nnapi_implementation", 57 "@com_google_googletest//:gtest_main", 58 ], 59) 60 61# Cannot inject NNAPI instance on ios and windows 62cc_library( 63 name = "nnapi_handler", 64 srcs = if_nnapi(["nnapi_handler.cc"]), 65 hdrs = if_nnapi(["nnapi_handler.h"]), 66 deps = [ 67 ":nnapi_implementation", 68 ":nnapi_lib", 69 "//tensorflow/core/platform:logging", 70 "//tensorflow/lite:framework", 71 ], 72) 73 74cc_test( 75 name = "nnapi_handler_test", 76 srcs = ["nnapi_handler_test.cc"], 77 tags = [ 78 "no_mac", 79 "no_windows", 80 "tflite_not_portable_ios", 81 ], 82 deps = [ 83 ":nnapi_handler", 84 ":nnapi_implementation", 85 "@com_google_googletest//:gtest_main", 86 ], 87) 88