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(
|
package(
|
||||||
default_visibility = [
|
default_visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
@ -11,51 +13,22 @@ cc_library(
|
|||||||
"NeuralNetworksShim.h",
|
"NeuralNetworksShim.h",
|
||||||
"NeuralNetworksTypes.h",
|
"NeuralNetworksTypes.h",
|
||||||
],
|
],
|
||||||
linkopts = select({
|
linkopts = if_nnapi(["-ldl"]),
|
||||||
"//tensorflow:emscripten": [],
|
|
||||||
"//tensorflow:ios": [],
|
|
||||||
"//tensorflow:macos": [],
|
|
||||||
"//tensorflow:windows": [],
|
|
||||||
"//conditions:default": ["-ldl"],
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "nnapi_implementation",
|
name = "nnapi_implementation",
|
||||||
srcs = select({
|
srcs = if_nnapi(
|
||||||
"//tensorflow:emscripten": [
|
not_supported = ["nnapi_implementation_disabled.cc"],
|
||||||
"nnapi_implementation_disabled.cc",
|
supported = ["nnapi_implementation.cc"],
|
||||||
],
|
),
|
||||||
"//tensorflow:ios": [
|
|
||||||
"nnapi_implementation_disabled.cc",
|
|
||||||
],
|
|
||||||
"//tensorflow:macos": [
|
|
||||||
"nnapi_implementation_disabled.cc",
|
|
||||||
],
|
|
||||||
"//tensorflow:windows": [
|
|
||||||
"nnapi_implementation_disabled.cc",
|
|
||||||
],
|
|
||||||
"//conditions:default": [
|
|
||||||
"nnapi_implementation.cc",
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
hdrs = [
|
hdrs = [
|
||||||
"nnapi_implementation.h",
|
"nnapi_implementation.h",
|
||||||
],
|
],
|
||||||
linkopts = select({
|
linkopts = if_nnapi(["-ldl"]) + if_nnapi(
|
||||||
"//tensorflow:emscripten": [],
|
supported = ["-lrt"],
|
||||||
"//tensorflow:ios": [],
|
supported_android = [],
|
||||||
"//tensorflow:macos": [],
|
),
|
||||||
"//tensorflow:windows": [],
|
|
||||||
"//conditions:default": ["-ldl"],
|
|
||||||
}) + select({
|
|
||||||
"//tensorflow:android": [],
|
|
||||||
"//tensorflow:emscripten": [],
|
|
||||||
"//tensorflow:ios": [],
|
|
||||||
"//tensorflow:macos": [],
|
|
||||||
"//tensorflow:windows": [],
|
|
||||||
"//conditions:default": ["-lrt"],
|
|
||||||
}),
|
|
||||||
deps = [
|
deps = [
|
||||||
":nnapi_lib",
|
":nnapi_lib",
|
||||||
],
|
],
|
||||||
@ -84,16 +57,8 @@ cc_test(
|
|||||||
# Cannot inject NNAPI instance on ios and windows
|
# Cannot inject NNAPI instance on ios and windows
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "nnapi_handler",
|
name = "nnapi_handler",
|
||||||
srcs = select({
|
srcs = if_nnapi(["nnapi_handler.cc"]),
|
||||||
"//tensorflow:ios": [],
|
hdrs = if_nnapi(["nnapi_handler.h"]),
|
||||||
"//tensorflow:windows": [],
|
|
||||||
"//conditions:default": ["nnapi_handler.cc"],
|
|
||||||
}),
|
|
||||||
hdrs = select({
|
|
||||||
"//tensorflow:ios": [],
|
|
||||||
"//tensorflow:windows": [],
|
|
||||||
"//conditions:default": ["nnapi_handler.h"],
|
|
||||||
}),
|
|
||||||
deps = [
|
deps = [
|
||||||
":nnapi_implementation",
|
":nnapi_implementation",
|
||||||
":nnapi_lib",
|
":nnapi_lib",
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
"""External versions of build rules that differ outside of Google."""
|
"""External versions of build rules that differ outside of Google."""
|
||||||
|
|
||||||
|
load(
|
||||||
|
"//tensorflow:tensorflow.bzl",
|
||||||
|
"clean_dep",
|
||||||
|
)
|
||||||
|
|
||||||
def tflite_portable_test_suite(**kwargs):
|
def tflite_portable_test_suite(**kwargs):
|
||||||
"""This is a no-op outside of Google."""
|
"""This is a no-op outside of Google."""
|
||||||
_ignore = [kwargs]
|
_ignore = [kwargs]
|
||||||
@ -26,3 +31,17 @@ def tflite_extra_gles_deps():
|
|||||||
def tflite_ios_lab_runner(version):
|
def tflite_ios_lab_runner(version):
|
||||||
"""This is a no-op outside of Google."""
|
"""This is a no-op outside of Google."""
|
||||||
return None
|
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