aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/graph
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-07-27 14:03:25 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-27 14:07:05 -0700
commit81d927bfc7e1e4c7b28aabdb0c64a12cec2833fe (patch)
treedb8ce58fcb792df76624a5e3f94d502a16aba1bf /tensorflow/core/graph
parent388d0d860110a19a9d133fe4de85f8f6fa060cde (diff)
Adding NodeDef names to error messages for better debuggability.
The format used is as follows: {{node <node_name>}} PiperOrigin-RevId: 206370355
Diffstat (limited to 'tensorflow/core/graph')
-rw-r--r--tensorflow/core/graph/control_flow.cc37
-rw-r--r--tensorflow/core/graph/control_flow_test.cc17
2 files changed, 36 insertions, 18 deletions
diff --git a/tensorflow/core/graph/control_flow.cc b/tensorflow/core/graph/control_flow.cc
index 1778e48ef6..8e1e56d29b 100644
--- a/tensorflow/core/graph/control_flow.cc
+++ b/tensorflow/core/graph/control_flow.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <deque>
#include <vector>
+#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/graph/node_builder.h"
#include "tensorflow/core/lib/core/errors.h"
@@ -54,10 +55,11 @@ Status ValidateControlFlowInfo(const Graph* graph,
frame.parent = parent;
frame.name = cf.frame_name;
} else if (frame.parent != parent) {
- return errors::InvalidArgument(
+ return errors::Internal(
"Invalid loop structure: Mismatched parent frames for \"",
cf.frame_name, "\": \"", parent->name, "\" vs \"", frame.parent->name,
- "\". This is an internal bug, please file a bug report with "
+ "\". The node giving this error: ", FormatNodeForError(*node),
+ "This is an internal bug, please file a bug report with "
"instructions on how to reproduce the error.");
}
if (IsLoopCond(node)) {
@@ -69,9 +71,9 @@ Status ValidateControlFlowInfo(const Graph* graph,
!str_util::StrContains(node->name(), "LoopCounter")) {
return errors::InvalidArgument(
"Invalid loop structure: Loop \"", cf.frame_name,
- "\" has more than one LoopCond node: \"", node->name(), "\" and \"",
- frame.loop_cond->name(),
- "\". This is an internal bug, please file a bug report with "
+ "\" has more than one LoopCond node: ", FormatNodeForError(*node),
+ " and ", FormatNodeForError(*frame.loop_cond),
+ ". This is an internal bug, please file a bug report with "
"instructions on how to reproduce the error.");
}
frame.loop_cond = node;
@@ -135,12 +137,11 @@ Status BuildControlFlowInfo(const Graph* g, std::vector<ControlFlowInfo>* info,
const string& parent_frame = (*info)[out_parent->id()].frame_name;
if (parent_frame != frame_name) {
return errors::InvalidArgument(
- "The node '", out->name(),
- "' has inputs from different "
- "frames. The input '",
- curr_node->name(), "' is in frame '", frame_name,
- "'. The input '", parent_nodes[out->id()]->name(),
- "' is in frame '", parent_frame, "'.");
+ FormatNodeForError(*out),
+ " has inputs from different frames. The input ",
+ FormatNodeForError(*curr_node), " is in frame '", frame_name,
+ "'. The input ", FormatNodeForError(*parent_nodes[out->id()]),
+ " is in frame '", parent_frame, "'.");
}
} else {
out_info->frame = out;
@@ -148,7 +149,8 @@ Status BuildControlFlowInfo(const Graph* g, std::vector<ControlFlowInfo>* info,
TF_RETURN_IF_ERROR(
GetNodeAttr(out->attrs(), "frame_name", &out_info->frame_name));
if (out_info->frame_name.empty()) {
- return errors::InvalidArgument("The Enter node ", out->name(),
+ return errors::InvalidArgument("The Enter ",
+ FormatNodeForError(*out),
" must have a frame name.");
}
}
@@ -156,12 +158,11 @@ Status BuildControlFlowInfo(const Graph* g, std::vector<ControlFlowInfo>* info,
if (is_visited) {
if (out_info->frame_name != frame_name) {
return errors::InvalidArgument(
- "The node '", out->name(),
- "' has inputs from different "
- "frames. The input '",
- curr_node->name(), "' is in frame '", frame_name,
- "'. The input '", parent_nodes[out->id()]->name(),
- "' is in frame '", out_info->frame_name, "'.");
+ FormatNodeForError(*out),
+ " has inputs from different frames. The input ",
+ FormatNodeForError(*curr_node), " is in frame '", frame_name,
+ "'. The input ", FormatNodeForError(*parent_nodes[out->id()]),
+ " is in frame '", out_info->frame_name, "'.");
}
} else {
out_info->frame = frame;
diff --git a/tensorflow/core/graph/control_flow_test.cc b/tensorflow/core/graph/control_flow_test.cc
index eb7937400f..803c757c3f 100644
--- a/tensorflow/core/graph/control_flow_test.cc
+++ b/tensorflow/core/graph/control_flow_test.cc
@@ -63,6 +63,15 @@ TEST(ValidateControlFlowTest, InputsFromDifferentFrames) {
EXPECT_TRUE(str_util::StrContains(status.error_message(),
"has inputs from different frames"))
<< status.error_message();
+ EXPECT_TRUE(str_util::StrContains(status.error_message(),
+ "{{node outer/body/inner/Merge}}"))
+ << status.error_message();
+ EXPECT_TRUE(str_util::StrContains(status.error_message(),
+ "{{node outer/body/inner/Enter}}"))
+ << status.error_message();
+ EXPECT_TRUE(
+ str_util::StrContains(status.error_message(), "{{node outer/Switch}}"))
+ << status.error_message();
}
TEST(ValidateControlFlowTest, MismatchedParentFrames) {
@@ -102,6 +111,8 @@ TEST(ValidateControlFlowTest, MismatchedParentFrames) {
EXPECT_TRUE(
str_util::StrContains(status.error_message(), "Mismatched parent frames"))
<< status.error_message();
+ EXPECT_TRUE(str_util::StrContains(status.error_message(), "{{node Enter2}}"))
+ << status.error_message();
}
TEST(ValidateControlFlowTest, TwoLoopCond) {
@@ -125,6 +136,12 @@ TEST(ValidateControlFlowTest, TwoLoopCond) {
EXPECT_TRUE(str_util::StrContains(status.error_message(),
"more than one LoopCond node"))
<< status.error_message();
+ EXPECT_TRUE(
+ str_util::StrContains(status.error_message(), "{{node sub/LoopCond}}"))
+ << status.error_message();
+ EXPECT_TRUE(
+ str_util::StrContains(status.error_message(), "{{node LoopCond}}"))
+ << status.error_message();
}
} // namespace