aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api.cc
diff options
context:
space:
mode:
authorGravatar Skye Wanderman-Milne <skyewm@google.com>2018-03-16 14:39:08 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-16 14:43:21 -0700
commitaf1c668e2db5bcfcd3b156800c4b982c9423e858 (patch)
tree1d784d76c84bfda2b890ba842a1fad905575c6c1 /tensorflow/c/c_api.cc
parent77c17f79399c4444ad49ac10f02e141c266c740e (diff)
Downgrade run-after-mutation error to a log warning.
This is to ease the transition to the C API. Some tests currently mutate the graph after running it but currently pass. This error was meant to guard against existing behavior, so it's not a regression to make it a warning instead for now. PiperOrigin-RevId: 189395472
Diffstat (limited to 'tensorflow/c/c_api.cc')
-rw-r--r--tensorflow/c/c_api.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 778cb667e2..18eeb28168 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -647,11 +647,11 @@ void RecordMutation(TF_Graph* graph, const TF_Operation& op,
for (auto it : graph->sessions) {
mutex_lock session_lock(it.first->mu);
if (it.first->last_num_graph_nodes > op.node.id()) {
- it.second = FailedPrecondition(
+ it.second = strings::StrCat(
"Operation '", op.node.DebugString(), "' was changed by ",
mutation_type,
- " after it was run by a session. Nodes can be mutated "
- "only before they are executed by a session. Either don't modify "
+ " after it was run by a session. This mutation will have no effect, "
+ "and will trigger an error in the future. Either don't modify "
"nodes after running them or create a new session.");
}
}
@@ -722,10 +722,11 @@ bool ExtendSessionGraphHelper(TF_Session* session, TF_Status* status) {
mutex_lock session_lock(session->mu);
const Graph& graph = session->graph->graph;
- status->status = session->graph->sessions[session];
- if (!status->status.ok()) {
- session->graph->mu.unlock();
- return false;
+ const string& mutation_warning = session->graph->sessions[session];
+ if (!mutation_warning.empty()) {
+ // TODO(b/74949947): turn this back into an error status
+ LOG(WARNING) << mutation_warning;
+ session->graph->sessions[session].clear();
}
const auto num_nodes = graph.num_node_ids();
@@ -2475,7 +2476,7 @@ TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opt,
TF_Session* new_session = new TF_Session(session, graph);
if (graph != nullptr) {
mutex_lock l(graph->mu);
- graph->sessions[new_session] = Status::OK();
+ graph->sessions[new_session] = "";
}
return new_session;
} else {
@@ -2541,7 +2542,7 @@ TF_Session* TF_LoadSessionFromSavedModel(
TF_Session* session = new TF_Session(bundle.session.release(), graph);
- graph->sessions[session] = Status::OK();
+ graph->sessions[session] = "";
session->last_num_graph_nodes = graph->graph.num_node_ids();
return session;
#endif // __ANDROID__