diff --git a/xla/tsl/profiler/convert/xla_op_utils.h b/xla/tsl/profiler/convert/xla_op_utils.h index 5fe3271973f2f..b743dc23f8946 100644 --- a/xla/tsl/profiler/convert/xla_op_utils.h +++ b/xla/tsl/profiler/convert/xla_op_utils.h @@ -129,6 +129,22 @@ inline bool MayHaveInnerOps(absl::string_view category) { category == kHloWhile || category == kHloMegacoreFusion; } +// File and line that the framework op corresponding to an HLO op is associated +// to in a user's program; e.g. it could be the file and line of user code that +// generated the op. +struct OpSourceInfo { + absl::string_view source_file; + int32_t source_line = -1; + std::string stack_frame; + + std::string GetSourceTopLine() const { + if (source_file.empty()) return ""; + return absl::StrCat(source_file, ":", source_line); + } + + std::string GetSourceStack() const { return stack_frame; } +}; + } // namespace profiler } // namespace tsl