diff --git a/tensorflow/core/profiler/utils/tfstreamz_utils.cc b/tensorflow/core/profiler/utils/tfstreamz_utils.cc index af957c54843ec7..0b32f5712edba5 100644 --- a/tensorflow/core/profiler/utils/tfstreamz_utils.cc +++ b/tensorflow/core/profiler/utils/tfstreamz_utils.cc @@ -112,6 +112,9 @@ Status SerializeToXPlane(const std::vector& snapshots, xevent.AddStatValue(*metadata, *xplane.GetOrCreateStatMetadata( point->string_value)); break; + case monitoring::ValueType::kDouble: + xevent.AddStatValue(*metadata, point->double_value); + break; case monitoring::ValueType::kHistogram: xevent.AddStatValue(*metadata, point->histogram_value); break; diff --git a/third_party/xla/third_party/tsl/tsl/lib/monitoring/collected_metrics.h b/third_party/xla/third_party/tsl/tsl/lib/monitoring/collected_metrics.h index 8582594922adf2..ba67299b57a952 100644 --- a/third_party/xla/third_party/tsl/tsl/lib/monitoring/collected_metrics.h +++ b/third_party/xla/third_party/tsl/tsl/lib/monitoring/collected_metrics.h @@ -90,6 +90,7 @@ struct Point { int64_t int64_value; string string_value; bool bool_value; + double double_value; HistogramProto histogram_value; Percentiles percentiles_value; diff --git a/third_party/xla/third_party/tsl/tsl/lib/monitoring/collection_registry.h b/third_party/xla/third_party/tsl/tsl/lib/monitoring/collection_registry.h index d988d2f19f15ad..7af6c87e51f0bb 100644 --- a/third_party/xla/third_party/tsl/tsl/lib/monitoring/collection_registry.h +++ b/third_party/xla/third_party/tsl/tsl/lib/monitoring/collection_registry.h @@ -352,6 +352,18 @@ inline void CollectValue(Percentiles value, Point* const point) { point->percentiles_value = std::move(value); } +template <> +inline void CollectValue(double value, Point* const point) { + point->value_type = ValueType::kDouble; + point->double_value = value; +} + +template <> +inline void CollectValue(std::function value_fn, Point* const point) { + point->value_type = ValueType::kDouble; + point->double_value = value_fn(); +} + // Used by the CollectionRegistry class to collect all the values of all the // metrics in the registry. This is an implementation detail of the // CollectionRegistry class, please do not depend on this. diff --git a/third_party/xla/third_party/tsl/tsl/lib/monitoring/gauge.h b/third_party/xla/third_party/tsl/tsl/lib/monitoring/gauge.h index 93cbe9aa928df0..2552013f3d7150 100644 --- a/third_party/xla/third_party/tsl/tsl/lib/monitoring/gauge.h +++ b/third_party/xla/third_party/tsl/tsl/lib/monitoring/gauge.h @@ -296,8 +296,10 @@ Gauge* Gauge::New( std::is_same::value || std::is_same >::value || std::is_same >::value || - std::is_same >::value, - "Gauge only allows bool, int64, and string types."); + std::is_same >::value || + std::is_same >::value || + std::is_same::value, + "Gauge only allows bool, int64, double, and string types."); return new Gauge( MetricDef( std::forward(metric_def_args)...)); diff --git a/third_party/xla/third_party/tsl/tsl/lib/monitoring/metric_def.h b/third_party/xla/third_party/tsl/tsl/lib/monitoring/metric_def.h index f8c21c360a2b09..ab454664691b1e 100644 --- a/third_party/xla/third_party/tsl/tsl/lib/monitoring/metric_def.h +++ b/third_party/xla/third_party/tsl/tsl/lib/monitoring/metric_def.h @@ -47,7 +47,8 @@ enum class ValueType : int { kHistogram, kString, kBool, - kPercentiles + kPercentiles, + kDouble }; // Everything in the internal namespace is implementation details. Do not depend @@ -97,6 +98,16 @@ inline ValueType GetValueType>() { return ValueType::kBool; } +template <> +inline ValueType GetValueType() { + return ValueType::kDouble; +} + +template <> +inline ValueType GetValueType>() { + return ValueType::kDouble; +} + } // namespace internal // Abstract base class for a metric definition.