@@ -1293,46 +1293,32 @@ def patch_workspace(path: Path) -> None:
12931293"""
12941294
12951295
1296- SAVED_MODEL_ANDROID_LOADER_PATCH = """--- a/tensorflow/cc/saved_model/BUILD
1297- +++ b/tensorflow/cc/saved_model/BUILD
1298- @@ -92,7 +92,7 @@
1299- cc_library(
1300- name = "loader_lite",
1301- hdrs = ["loader.h"],
1302- - deps = if_static([
1303- + deps = if_static_and_not_mobile([
1304- ":loader_lite_impl",
1305- ]) + if_not_mobile([
1306- "//tensorflow/core:core_cpu",
1296+ TF_C_API_SAVED_MODEL_ANDROID_PATCH = """--- a/tensorflow/c/c_api.cc
1297+ +++ b/tensorflow/c/c_api.cc
1298+ @@ -2189,11 +2189,11 @@
1299+ TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status) {
1300+ // TODO(sjr): Remove the IS_MOBILE_PLATFORM guard. This will require ensuring
1301+ // that the tensorflow/cc/saved_model:loader build target is mobile friendly.
1302+ -#if defined(IS_MOBILE_PLATFORM) || defined(IS_SLIM_BUILD)
1303+ +#if defined(IS_SLIM_BUILD)
1304+ status->status = tensorflow::errors::Unimplemented(
1305+ "Loading a SavedModel is not supported on mobile. File a bug at "
1306+ "https://github.com/tensorflow/tensorflow/issues if this feature is "
1307+ "important to you");
1308+ return nullptr;
1309+ #else
1310+ mutex_lock l(graph->mu);
13071311"""
13081312
13091313
1310- TENSORFLOW_FRAMEWORK_ANDROID_PATCH = """--- a/tensorflow/BUILD
1311- +++ b/tensorflow/BUILD
1312- @@ -635,8 +635,12 @@
1313- per_os_targets = True,
1314- soversion = VERSION,
1315- visibility = ["//visibility:public"],
1316- - deps = [
1317- - "//tensorflow/cc/saved_model:loader_lite_impl",
1318- + deps = select({
1319- + "//tensorflow:android": [],
1320- + "//conditions:default": [
1321- + "//tensorflow/cc/saved_model:loader_lite_impl",
1322- + ],
1323- + }) + [
1324- "//tensorflow/core:core_cpu_impl",
1325- "//tensorflow/core:framework_internal_impl",
1326- "//tensorflow/core:gpu_runtime_impl",
1327- "//tensorflow/core/grappler/optimizers:custom_graph_optimizer_registry_impl",
1328- "//tensorflow/core:lib_internal_impl",
1329- "//tensorflow/core/profiler:profiler_impl",
1330- "//tensorflow/stream_executor:stream_executor_impl",
1331- "//tensorflow:tf_framework_version_script.lds",
1332- - ] + tf_additional_binary_deps(),
1333- + ] + tf_additional_binary_deps(),
1334- )
1335- """
1314+ # Keep upstream SavedModel loader wiring on Android so the C API can resolve
1315+ # TF_LoadSessionFromSavedModel() once the mobile guard above is removed.
1316+ SAVED_MODEL_ANDROID_LOADER_PATCH = ""
1317+
1318+
1319+ # Keep upstream tensorflow_framework deps on Android so loader_lite_impl stays
1320+ # bundled into libtensorflow_framework.so.
1321+ TENSORFLOW_FRAMEWORK_ANDROID_PATCH = ""
13361322
13371323
13381324ANDROID_PORTABLE_LIB_SHIM_PATCH = """--- a/tensorflow/core/BUILD
@@ -1484,6 +1470,7 @@ def write_tensorflow_android_absl_patch(path: Path) -> None:
14841470 text += GRPC_SERVER_LIB_ANDROID_BUILD_PATCH
14851471 text += GRPC_SERVER_LIB_ANDROID_CC_PATCH
14861472 text += TF_C_API_EXPERIMENTAL_CC_PATCH
1473+ text += TF_C_API_SAVED_MODEL_ANDROID_PATCH
14871474 text += SAVED_MODEL_ANDROID_LOADER_PATCH
14881475 text += TENSORFLOW_FRAMEWORK_ANDROID_PATCH
14891476 text += normalize_unified_diff_hunk_counts (ANDROID_PORTABLE_LIB_SHIM_PATCH )
0 commit comments