xref: /aosp_15_r20/external/tensorflow/tensorflow/core/profiler/convert/xla_op_utils.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_CORE_PROFILER_CONVERT_XLA_OP_UTILS_H_
16 #define TENSORFLOW_CORE_PROFILER_CONVERT_XLA_OP_UTILS_H_
17 
18 #include <string>
19 
20 #include "absl/strings/match.h"
21 #include "absl/strings/str_cat.h"
22 #include "absl/strings/string_view.h"
23 
24 namespace tensorflow {
25 namespace profiler {
26 
27 // Return if a category is fusion.
IsFusion(absl::string_view category)28 inline bool IsFusion(absl::string_view category) {
29   return absl::EndsWith(category, " fusion");
30 }
31 
32 // Return a concatenation of the program name with program id.
HloModuleNameWithProgramId(absl::string_view hlo_module_name,uint64_t program_id)33 inline std::string HloModuleNameWithProgramId(absl::string_view hlo_module_name,
34                                               uint64_t program_id) {
35   return absl::StrCat(hlo_module_name, "(", program_id, ")");
36 }
37 
38 }  // namespace profiler
39 }  // namespace tensorflow
40 
41 #endif  // TENSORFLOW_CORE_PROFILER_CONVERT_XLA_OP_UTILS_H_
42