add bytes type stats in preparation to save none utf8 strings.
PiperOrigin-RevId: 304255222
Change-Id: I234ffe964aab55fab6c60aaeb15527e926196301
diff --git a/tensorflow/core/profiler/protobuf/xplane.proto b/tensorflow/core/profiler/protobuf/xplane.proto
index e1763a7..29ce1c6 100644
--- a/tensorflow/core/profiler/protobuf/xplane.proto
+++ b/tensorflow/core/profiler/protobuf/xplane.proto
@@ -91,7 +91,7 @@
// An XStat is a named value associated with an XEvent, e.g., a performance
// counter value, a metric computed by a formula applied over nested XEvents
// and XStats.
-// Next ID: 6
+// Next ID: 7
message XStat {
// XStatMetadata.id of corresponding metadata.
int64 metadata_id = 1;
@@ -102,6 +102,7 @@
uint64 uint64_value = 3;
int64 int64_value = 4;
string str_value = 5;
+ bytes bytes_value = 6;
}
}
diff --git a/tensorflow/core/profiler/utils/xplane_builder.h b/tensorflow/core/profiler/utils/xplane_builder.h
index 6b60114..60b06a6 100644
--- a/tensorflow/core/profiler/utils/xplane_builder.h
+++ b/tensorflow/core/profiler/utils/xplane_builder.h
@@ -46,11 +46,21 @@
void AddStatValue(const XStatMetadata& metadata, double value) {
AddStat(metadata)->set_double_value(value);
}
- void AddStatValue(const XStatMetadata& metadata, absl::string_view value) {
- AddStat(metadata)->set_str_value(string(value));
+ void AddStatValue(const XStatMetadata& metadata, absl::string_view value,
+ bool is_bytes = false) {
+ if (is_bytes) {
+ AddStat(metadata)->set_bytes_value(string(value));
+ } else {
+ AddStat(metadata)->set_str_value(string(value));
+ }
}
- void AddStatValue(const XStatMetadata& metadata, string&& value) {
- AddStat(metadata)->set_str_value(std::move(value));
+ void AddStatValue(const XStatMetadata& metadata, string&& value,
+ bool is_bytes = false) {
+ if (is_bytes) {
+ AddStat(metadata)->set_bytes_value(std::move(value));
+ } else {
+ AddStat(metadata)->set_str_value(std::move(value));
+ }
}
void AddStat(const XStatMetadata& metadata, const XStat& stat) {
diff --git a/tensorflow/core/profiler/utils/xplane_visitor.cc b/tensorflow/core/profiler/utils/xplane_visitor.cc
index c6e7a71..941a44c 100644
--- a/tensorflow/core/profiler/utils/xplane_visitor.cc
+++ b/tensorflow/core/profiler/utils/xplane_visitor.cc
@@ -34,6 +34,8 @@
return absl::StrCat(stat_->double_value());
case XStat::kStrValue:
return stat_->str_value();
+ case XStat::kBytesValue:
+ return "<opaque bytes>";
case XStat::VALUE_NOT_SET:
return "";
}