[TF/XLA] On compilation failure, do not overflow the max size of the bad status by a huge list of function inputs
PiperOrigin-RevId: 313433935 Change-Id: Iaff5c61ce01c6eac7894bed4edd76a396f846151
This commit is contained in:
parent
7cedc771d4
commit
90b80fba1a
@ -91,7 +91,7 @@ Status CreateXlaKernel(FunctionLibraryRuntime* flr, const NodeDef& node_def,
|
||||
}
|
||||
string message = absl::StrCat(
|
||||
"Function invoked by the following node is not compilable: ",
|
||||
SummarizeNodeDef(node_def), ".\n");
|
||||
SummarizeNodeDef(node_def, /*max_inputs_in_summary=*/10), ".\n");
|
||||
absl::StrAppend(&message, "Uncompilable nodes:");
|
||||
for (const auto& node_info : uncompilable_node_info) {
|
||||
string node_message =
|
||||
|
@ -100,7 +100,7 @@ string AttrSlice::DebugString() const {
|
||||
return absl::StrJoin(attr_key_vals, ", ");
|
||||
}
|
||||
|
||||
string SummarizeNodeDef(const NodeDef& node_def) {
|
||||
string SummarizeNodeDef(const NodeDef& node_def, int max_inputs_in_summary) {
|
||||
string ret = strings::StrCat(errors::FormatNodeNameForError(node_def.name()),
|
||||
" = ", node_def.op(), "[");
|
||||
strings::StrAppend(&ret, SummarizeAttrsHelper(node_def, node_def.device()));
|
||||
@ -111,6 +111,10 @@ string SummarizeNodeDef(const NodeDef& node_def) {
|
||||
for (const string& input : node_def.input()) {
|
||||
if (!first) strings::StrAppend(&ret, ", ");
|
||||
first = false;
|
||||
if (max_inputs_in_summary-- == 0) {
|
||||
strings::StrAppend(&ret, "...");
|
||||
break;
|
||||
}
|
||||
strings::StrAppend(&ret, input);
|
||||
}
|
||||
strings::StrAppend(&ret, ")");
|
||||
|
@ -58,7 +58,12 @@ extern const char* const kColocationGroupPrefix;
|
||||
|
||||
// Produce a human-readable version of a Node or NodeDef that is more concise
|
||||
// than a text-format proto.
|
||||
string SummarizeNodeDef(const NodeDef& node_def);
|
||||
//
|
||||
// The parameter `max_inputs_in_summary` specifies how many inputs at most to
|
||||
// serialize in the output (in order not to get a string which is overly large).
|
||||
// The value `-1` specifies that all inputs will be shown.
|
||||
string SummarizeNodeDef(const NodeDef& node_def,
|
||||
int max_inputs_in_summary = -1);
|
||||
string SummarizeAttrs(const NodeDef& node_def);
|
||||
string SummarizeAttrsHelper(AttrSlice attrs, StringPiece device);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user