Skip to content

Commit

Permalink
add accessor to stats byte vlaue.
Browse files Browse the repository at this point in the history
add a ForEachEventMetadata method to iterate through [plane's] event metadata.

PiperOrigin-RevId: 450572175
  • Loading branch information
tensorflower-gardener committed May 24, 2022
1 parent c72bc08 commit 800c8af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tensorflow/core/profiler/utils/xplane_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class XStatVisitor {

uint64 UintValue() const { return stat_->uint64_value(); }

absl::string_view BytesValue() const { return stat_->bytes_value(); }

uint64 IntOrUintValue() const {
return ValueCase() == XStat::kUint64Value ? UintValue()
: static_cast<uint64>(IntValue());
Expand Down Expand Up @@ -275,6 +277,15 @@ class XPlaneVisitor : public XStatsOwner<XPlane> {
bundle.JoinAll();
}

template <typename ForEachEventMetadataFunc>
void ForEachEventMetadata(
ForEachEventMetadataFunc&& for_each_event_metadata) {
for (const auto& event : plane_->event_metadata()) {
for_each_event_metadata(event.first,
XEventMetadataVisitor(this, &event.second));
}
}

// Returns event metadata given its id. Returns a default value if not found.
const XEventMetadata* GetEventMetadata(int64_t event_metadata_id) const;

Expand Down

0 comments on commit 800c8af

Please sign in to comment.