aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api_function.cc
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2017-12-11 14:41:17 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-11 14:45:28 -0800
commit037f036b2c76ef363148276dce83b7dd1d79e878 (patch)
tree359d2af4fcec51ccb60d42409ce09b03000cfc8e /tensorflow/c/c_api_function.cc
parentdd77f385591c8b6ef7ab8dae7429c7eff7813a1e (diff)
Mark a FunctionDef's signature as stateful when it contains a stateful node.
This fixes a bug where two calls to the same stateful function will erroneously be eliminated as common subexpressions. It is also a step towards pruning nodes from function bodies, which is necessary for a variety of `Dataset` optimizations. PiperOrigin-RevId: 178675527
Diffstat (limited to 'tensorflow/c/c_api_function.cc')
-rw-r--r--tensorflow/c/c_api_function.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/tensorflow/c/c_api_function.cc b/tensorflow/c/c_api_function.cc
index dcb818b88b..b9312c2974 100644
--- a/tensorflow/c/c_api_function.cc
+++ b/tensorflow/c/c_api_function.cc
@@ -226,6 +226,11 @@ Status FillFunctionBody(
}
node_def->add_input(strings::StrCat("^", normalized));
}
+
+ // A function is stateful if any of its nodes are stateful.
+ if (node->op_def().is_stateful()) {
+ fdef->mutable_signature()->set_is_stateful(true);
+ }
}
return Status::OK();
}