aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Asim Shankar <ashankar@google.com>2017-02-27 10:28:30 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-02-27 10:44:09 -0800
commitd18f4c54cd5e6a009c4ab1bc01c3a5432bafa6ae (patch)
tree6e1343792b22d4b7f5481c53e2fbdc4fb36bfcaa
parent8f7e0df28846b320cc43b417ee61fc01890ffc72 (diff)
C API: Keep the TF_LoadSessionFromSavedModel symbol in Android builds.
Though, the function will return an error. Required for #7688 Change: 148664204
-rw-r--r--tensorflow/c/c_api.cc22
-rw-r--r--tensorflow/c/c_api.h5
2 files changed, 14 insertions, 13 deletions
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 5073f28a70..496ec8dc86 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -543,9 +543,8 @@ static void TF_Run_Helper(
if (handle == nullptr) {
RunOptions run_options_proto;
- if (run_options != nullptr &&
- !run_options_proto.ParseFromArray(run_options->data,
- run_options->length)) {
+ if (run_options != nullptr && !run_options_proto.ParseFromArray(
+ run_options->data, run_options->length)) {
status->status = InvalidArgument("Unparseable RunOptions proto");
return;
}
@@ -2111,11 +2110,19 @@ TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opt,
}
}
-#ifndef __ANDROID__
TF_Session* TF_LoadSessionFromSavedModel(
const TF_SessionOptions* session_options, const TF_Buffer* run_options,
const char* export_dir, const char* const* tags, int tags_len,
TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status) {
+// TODO(ashankar): Remove the __ANDROID__ guard. This will require ensuring that
+// the tensorflow/cc/saved_model:loader build target is Android friendly.
+#ifdef __ANDROID__
+ status->status = tensorflow::errors::Unimplemented(
+ "Loading a SavedModel is not supported in Android. File a bug at "
+ "https://github.com/tensorflow/tensorflow/issues if this feature is "
+ "important to you");
+ return nullptr;
+#else
mutex_lock l(graph->mu);
if (!graph->name_map.empty()) {
@@ -2124,9 +2131,8 @@ TF_Session* TF_LoadSessionFromSavedModel(
}
RunOptions run_options_proto;
- if (run_options != nullptr &&
- !run_options_proto.ParseFromArray(run_options->data,
- run_options->length)) {
+ if (run_options != nullptr && !run_options_proto.ParseFromArray(
+ run_options->data, run_options->length)) {
status->status = InvalidArgument("Unparseable RunOptions proto");
return nullptr;
}
@@ -2164,8 +2170,8 @@ TF_Session* TF_LoadSessionFromSavedModel(
graph->num_sessions += 1;
session->last_num_graph_nodes = graph->graph.num_node_ids();
return session;
-}
#endif // __ANDROID__
+}
void TF_CloseSession(TF_Session* s, TF_Status* status) {
status->status = s->session->Close();
diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
index 18bd1bc318..02ba0ac509 100644
--- a/tensorflow/c/c_api.h
+++ b/tensorflow/c/c_api.h
@@ -932,10 +932,6 @@ typedef struct TF_Session TF_Session;
extern TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opts,
TF_Status* status);
-#ifndef __ANDROID__
-// TODO(ashankar): Remove the __ANDROID__ guard. This will require ensuring that
-// the tensorflow/cc/saved_model:loader build target is Android friendly.
-
// This function creates a new TF_Session (which is created on success) using
// `session_options`, and then initializes state (restoring tensors and other
// assets) using `run_options`.
@@ -954,7 +950,6 @@ TF_Session* TF_LoadSessionFromSavedModel(
const TF_SessionOptions* session_options, const TF_Buffer* run_options,
const char* export_dir, const char* const* tags, int tags_len,
TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status);
-#endif // __ANDROID__
// Close a session.
//