diff options
author | Skye Wanderman-Milne <skyewm@google.com> | 2018-09-17 15:50:12 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-17 16:03:03 -0700 |
commit | 8ea4ea95ad1e85948019daee7a9e70e97082f6d0 (patch) | |
tree | 45b9059b5d67abb4f4b12896f87f88f8fa56a85a /tensorflow/core/framework | |
parent | d5f4c3aa59aebc88f42a186a30ef6200857194ca (diff) |
Fix GraphConstructor and import_graph_def bug with variadic ops.
Prior to this change,
GraphConstructor::PopulateMissingUnusedInputMapKey() didn't correctly
compute the number of outputs for ops with variadic outputs. This
meant that missing_unused_input_map_keys could contain spurious
entries for unused variadic outputs, which could trigger a ValueError
in import_graph_def.
This also adds a new util method in node_def_util.h, NumOutputsForNode().
PiperOrigin-RevId: 213353158
Diffstat (limited to 'tensorflow/core/framework')
-rw-r--r-- | tensorflow/core/framework/node_def_util.cc | 8 | ||||
-rw-r--r-- | tensorflow/core/framework/node_def_util.h | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/tensorflow/core/framework/node_def_util.cc b/tensorflow/core/framework/node_def_util.cc index bacc1d72c4..42ec315a32 100644 --- a/tensorflow/core/framework/node_def_util.cc +++ b/tensorflow/core/framework/node_def_util.cc @@ -403,6 +403,14 @@ Status InOutTypesForNode(const NodeDef& node_def, const OpDef& op_def, return OutputTypesForNode(node_def, op_def, outputs); } +Status NumOutputsForNode(const NodeDef& node_def, const OpDef& op_def, + int* num_outputs) { + DataTypeVector outputs; + TF_RETURN_IF_ERROR(OutputTypesForNode(node_def, op_def, &outputs)); + *num_outputs = outputs.size(); + return Status::OK(); +} + Status ValidateNodeDef(const NodeDef& node_def, const OpDef& op_def) { if (node_def.op() != op_def.name()) { return errors::InvalidArgument("NodeDef op '", node_def.op(), diff --git a/tensorflow/core/framework/node_def_util.h b/tensorflow/core/framework/node_def_util.h index 499034cab2..7528d3d306 100644 --- a/tensorflow/core/framework/node_def_util.h +++ b/tensorflow/core/framework/node_def_util.h @@ -261,6 +261,10 @@ Status OutputTypesForNode(const NodeDef& node_def, const OpDef& op_def, // REQUIRES: ValidateOpDef(op_def).ok() Status InOutTypesForNode(const NodeDef& node_def, const OpDef& op_def, DataTypeVector* inputs, DataTypeVector* outputs); +// Computes the number of outputs for a specific node. +// REQUIRES: ValidateOpDef(op_def).ok() +Status NumOutputsForNode(const NodeDef& node_def, const OpDef& op_def, + int* num_outputs); // Validates that the NodeDef: // * Defines all expected attrs from the OpDef. |