aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/graph/graph.cc
diff options
context:
space:
mode:
authorGravatar Peter Hawkins <phawkins@google.com>2017-05-15 12:12:38 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-15 12:16:30 -0700
commitad24ce18411d47ab8148d8698453940c50e880d0 (patch)
tree5c86e6b087d01e805a0afab2654dd73f7e70a6b1 /tensorflow/core/graph/graph.cc
parent54efd636b504aad368eea254eca2970a16d457f6 (diff)
Fix use of incorrect OpDef from another graph's function library in Graph::CopyNode().
PiperOrigin-RevId: 156086326
Diffstat (limited to 'tensorflow/core/graph/graph.cc')
-rw-r--r--tensorflow/core/graph/graph.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/tensorflow/core/graph/graph.cc b/tensorflow/core/graph/graph.cc
index dabc5a7849..d765959ca0 100644
--- a/tensorflow/core/graph/graph.cc
+++ b/tensorflow/core/graph/graph.cc
@@ -304,6 +304,17 @@ Node* Graph::CopyNode(Node* node) {
props->Ref();
Node* copy = AllocateNode(props, node);
copy->set_assigned_device_name(node->assigned_device_name());
+
+ // Since the OpDef of a function may be owned by the Graph that owns 'node',
+ // relookup the OpDef in the target graph. If it differs, then clone the
+ // node properties with the updated OpDef.
+ const OpDef* op_def;
+ TF_CHECK_OK(ops_.LookUpOpDef(node->type_string(), &op_def));
+ if (op_def != props->op_def_) {
+ copy->MaybeCopyOnWrite();
+ copy->props_->op_def_ = op_def;
+ }
+
return copy;
}