Disable NNAPI on nacl
Also refactor NNAPI build rules to rely on a single gate for support checking. PiperOrigin-RevId: 304035383 Change-Id: I9192efe27a320a4a60a05e86f4f3cad896cb9842
This commit is contained in:
parent
44fe00d030
commit
6860e7fb66
@ -1,3 +1,5 @@
|
||||
load("//tensorflow/lite:special_rules.bzl", "if_nnapi")
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
"//visibility:public",
|
||||
@ -11,51 +13,22 @@ cc_library(
|
||||
"NeuralNetworksShim.h",
|
||||
"NeuralNetworksTypes.h",
|
||||
],
|
||||
linkopts = select({
|
||||
"//tensorflow:emscripten": [],
|
||||
"//tensorflow:ios": [],
|
||||
"//tensorflow:macos": [],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": ["-ldl"],
|
||||
}),
|
||||
linkopts = if_nnapi(["-ldl"]),
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "nnapi_implementation",
|
||||
srcs = select({
|
||||
"//tensorflow:emscripten": [
|
||||
"nnapi_implementation_disabled.cc",
|
||||
],
|
||||
"//tensorflow:ios": [
|
||||
"nnapi_implementation_disabled.cc",
|
||||
],
|
||||
"//tensorflow:macos": [
|
||||
"nnapi_implementation_disabled.cc",
|
||||
],
|
||||
"//tensorflow:windows": [
|
||||
"nnapi_implementation_disabled.cc",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"nnapi_implementation.cc",
|
||||
],
|
||||
}),
|
||||
srcs = if_nnapi(
|
||||
not_supported = ["nnapi_implementation_disabled.cc"],
|
||||
supported = ["nnapi_implementation.cc"],
|
||||
),
|
||||
hdrs = [
|
||||
"nnapi_implementation.h",
|
||||
],
|
||||
linkopts = select({
|
||||
"//tensorflow:emscripten": [],
|
||||
"//tensorflow:ios": [],
|
||||
"//tensorflow:macos": [],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": ["-ldl"],
|
||||
}) + select({
|
||||
"//tensorflow:android": [],
|
||||
"//tensorflow:emscripten": [],
|
||||
"//tensorflow:ios": [],
|
||||
"//tensorflow:macos": [],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": ["-lrt"],
|
||||
}),
|
||||
linkopts = if_nnapi(["-ldl"]) + if_nnapi(
|
||||
supported = ["-lrt"],
|
||||
supported_android = [],
|
||||
),
|
||||
deps = [
|
||||
":nnapi_lib",
|
||||
],
|
||||
@ -84,16 +57,8 @@ cc_test(
|
||||
# Cannot inject NNAPI instance on ios and windows
|
||||
cc_library(
|
||||
name = "nnapi_handler",
|
||||
srcs = select({
|
||||
"//tensorflow:ios": [],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": ["nnapi_handler.cc"],
|
||||
}),
|
||||
hdrs = select({
|
||||
"//tensorflow:ios": [],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": ["nnapi_handler.h"],
|
||||
}),
|
||||
srcs = if_nnapi(["nnapi_handler.cc"]),
|
||||
hdrs = if_nnapi(["nnapi_handler.h"]),
|
||||
deps = [
|
||||
":nnapi_implementation",
|
||||
":nnapi_lib",
|
||||
|
@ -1,5 +1,10 @@
|
||||
"""External versions of build rules that differ outside of Google."""
|
||||
|
||||
load(
|
||||
"//tensorflow:tensorflow.bzl",
|
||||
"clean_dep",
|
||||
)
|
||||
|
||||
def tflite_portable_test_suite(**kwargs):
|
||||
"""This is a no-op outside of Google."""
|
||||
_ignore = [kwargs]
|
||||
@ -26,3 +31,17 @@ def tflite_extra_gles_deps():
|
||||
def tflite_ios_lab_runner(version):
|
||||
"""This is a no-op outside of Google."""
|
||||
return None
|
||||
|
||||
def if_nnapi(supported, not_supported = [], supported_android = None):
|
||||
if supported_android == None:
|
||||
supported_android = supported
|
||||
|
||||
# We use a blacklist rather than a whitelist for known unsupported platforms.
|
||||
return select({
|
||||
clean_dep("//tensorflow:emscripten"): not_supported,
|
||||
clean_dep("//tensorflow:ios"): not_supported,
|
||||
clean_dep("//tensorflow:macos"): not_supported,
|
||||
clean_dep("//tensorflow:windows"): not_supported,
|
||||
clean_dep("//tensorflow:android"): supported_android,
|
||||
"//conditions:default": supported,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user