1 /* Copyright 2021 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 16 #ifndef TENSORFLOW_CORE_PROFILER_CONVERT_HLO_PROTO_TO_MEMORY_VISUALIZATION_UTILS_H_ 17 #define TENSORFLOW_CORE_PROFILER_CONVERT_HLO_PROTO_TO_MEMORY_VISUALIZATION_UTILS_H_ 18 19 #include <cstdint> 20 21 #include "absl/status/statusor.h" 22 #include "tensorflow/compiler/xla/service/hlo.pb.h" 23 #include "tensorflow/core/profiler/protobuf/memory_viewer_preprocess.pb.h" 24 25 namespace tensorflow { 26 namespace profiler { 27 28 // Convert HloProto to PreprocessResult proto for memory visualization. 29 // small_buffer_size sets the byte size within which we collapse buffer entries 30 // for the max-heap display. 31 // heap_simulator_trace_id sets the index of heap simulator trace to be 32 // displayed. If it is set to -1, then HLOProto.heap_simulator_traces will not 33 // be considered during the preprocess. 34 // By default the memory color is 0, which is HBM. 35 absl::StatusOr<PreprocessResult> ConvertHloProtoToPreprocessResult( 36 const xla::HloProto& hlo_proto, int64_t small_buffer_size, 37 int64_t heap_simulator_trace_id, int64_t memory_color = 0); 38 39 // Get the heap simulator trace ID from HLO proto. 40 // By default the memory color is 0, which is HBM. 41 int64_t GetHeapSimulatorTraceId(const xla::HloProto& proto, 42 int64_t memory_color = 0); 43 44 } // namespace profiler 45 } // namespace tensorflow 46 47 #endif // TENSORFLOW_CORE_PROFILER_CONVERT_HLO_PROTO_TO_MEMORY_VISUALIZATION_UTILS_H_ 48