diff options
author | 2017-12-11 14:41:17 -0800 | |
---|---|---|
committer | 2017-12-11 14:45:28 -0800 | |
commit | 037f036b2c76ef363148276dce83b7dd1d79e878 (patch) | |
tree | 359d2af4fcec51ccb60d42409ce09b03000cfc8e /tensorflow/c/c_api_function.cc | |
parent | dd77f385591c8b6ef7ab8dae7429c7eff7813a1e (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.cc | 5 |
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(); } |