Use Protobuf TextFormat instead of DebugString to create a text proto
PiperOrigin-RevId: 414595206
Change-Id: Ia3a967a8392440771cd8558d3e010c89bb187f11
diff --git a/tensorflow/core/grappler/mutable_graph_view.cc b/tensorflow/core/grappler/mutable_graph_view.cc
index d70dc2e..079cee7 100644
--- a/tensorflow/core/grappler/mutable_graph_view.cc
+++ b/tensorflow/core/grappler/mutable_graph_view.cc
@@ -33,6 +33,7 @@
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/map_util.h"
+#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
@@ -500,8 +501,16 @@
std::vector<string> attr_strs;
attr_strs.reserve(attrs.size());
for (const auto& attr : attrs) {
- string attr_str = absl::Substitute("('$0', $1)", attr.first,
- attr.second.ShortDebugString());
+ std::string attr_second_text;
+ ::tensorflow::protobuf::TextFormat::Printer printer;
+ printer.SetSingleLineMode(true);
+ printer.PrintToString(attr.second, &attr_second_text);
+ if (!attr_second_text.empty() &&
+ attr_second_text[attr_second_text.size() - 1] == ' ') {
+ attr_second_text.resize(attr_second_text.size() - 1);
+ }
+ string attr_str =
+ absl::Substitute("('$0', $1)", attr.first, attr_second_text);
attr_strs.push_back(attr_str);
}
string params =