diff --git a/tensorflow/core/profiler/internal/gpu/cupti_collector.cc b/tensorflow/core/profiler/internal/gpu/cupti_collector.cc index 840b2ee0ada..ab4061a3749 100644 --- a/tensorflow/core/profiler/internal/gpu/cupti_collector.cc +++ b/tensorflow/core/profiler/internal/gpu/cupti_collector.cc @@ -224,27 +224,25 @@ struct PerDeviceCollector { std::vector annotation_stack = ParseAnnotationStack(event.annotation); - // If multiple metadata have the same key name, show the values from the top - // of the stack (innermost annotation). Concatenate the values from - // "hlo_op". - absl::flat_hash_set key_set; - std::vector hlo_op_names; - for (auto annotation = annotation_stack.rbegin(); - annotation != annotation_stack.rend(); ++annotation) { - for (const Annotation::Metadata& metadata : annotation->metadata) { - if (metadata.key == "tf_op") { - continue; // ignored, obtained from HLO proto via DebugInfoMap - } else if (key_set.insert(metadata.key).second) { - xevent.ParseAndAddStatValue( - *plane->GetOrCreateStatMetadata(metadata.key), metadata.value); - } - } - } if (!annotation_stack.empty()) { xevent.AddStatValue( *plane->GetOrCreateStatMetadata(GetStatTypeStr(StatType::kTfOp)), *plane->GetOrCreateStatMetadata(annotation_stack.begin()->name)); } + // If multiple metadata have the same key name, show the values from the top + // of the stack (innermost annotation). Concatenate the values from + // "hlo_op". + absl::flat_hash_set key_set; + + for (auto annotation = annotation_stack.rbegin(); + annotation != annotation_stack.rend(); ++annotation) { + for (const Annotation::Metadata& metadata : annotation->metadata) { + if (key_set.insert(metadata.key).second) { + xevent.ParseAndAddStatValue( + *plane->GetOrCreateStatMetadata(metadata.key), metadata.value); + } + } + } } absl::optional GetDeviceAttribute(CUdevice device, diff --git a/tensorflow/core/profiler/lib/traceme_encode.h b/tensorflow/core/profiler/lib/traceme_encode.h index 4dcd6ea469b..1a97d8b0e19 100644 --- a/tensorflow/core/profiler/lib/traceme_encode.h +++ b/tensorflow/core/profiler/lib/traceme_encode.h @@ -133,6 +133,12 @@ TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp( absl::string_view op_name, absl::string_view op_type) { return absl::StrCat(op_name, ":", op_type); } + +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp(const char* op_name, + const char* op_type) { + return absl::StrCat(op_name, ":", op_type); +} + TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp( std::string&& op_name, absl::string_view op_type) { absl::StrAppend(&op_name, ":", op_type);