From 32050bb926af5a5ebaeab3f519380241d0b097f7 Mon Sep 17 00:00:00 2001 From: Clive Verghese Date: Fri, 4 Nov 2022 14:22:25 -0700 Subject: [PATCH] Move profile.proto to TSL PiperOrigin-RevId: 486230034 --- tensorflow/compiler/xla/python/BUILD | 2 +- .../xla/python/pprof_profile_builder.h | 2 +- tensorflow/core/profiler/BUILD | 7 +- tensorflow/core/profiler/profile.proto | 69 +----------------- tensorflow/tsl/profiler/protobuf/BUILD | 10 +++ .../tsl/profiler/protobuf/profile.proto | 71 +++++++++++++++++++ 6 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 tensorflow/tsl/profiler/protobuf/profile.proto diff --git a/tensorflow/compiler/xla/python/BUILD b/tensorflow/compiler/xla/python/BUILD index 01a693d38f6d76..89f5892071e7fc 100644 --- a/tensorflow/compiler/xla/python/BUILD +++ b/tensorflow/compiler/xla/python/BUILD @@ -247,8 +247,8 @@ cc_library( deps = [ "//tensorflow/compiler/xla:statusor", "//tensorflow/compiler/xla:util", - "//tensorflow/core/profiler:protos_all_cc", "//tensorflow/tsl/platform:protobuf", + "//tensorflow/tsl/profiler/protobuf:profile_proto_cc", "@com_google_absl//absl/container:flat_hash_map", "@pybind11", ], diff --git a/tensorflow/compiler/xla/python/pprof_profile_builder.h b/tensorflow/compiler/xla/python/pprof_profile_builder.h index b37c0038709ad1..055f3677a80828 100644 --- a/tensorflow/compiler/xla/python/pprof_profile_builder.h +++ b/tensorflow/compiler/xla/python/pprof_profile_builder.h @@ -22,7 +22,7 @@ limitations under the License. #include "absl/container/flat_hash_map.h" #include "pybind11/pybind11.h" #include "tensorflow/compiler/xla/statusor.h" -#include "tensorflow/core/profiler/profile.pb.h" +#include "tensorflow/tsl/profiler/protobuf/profile.pb.h" namespace xla { diff --git a/tensorflow/core/profiler/BUILD b/tensorflow/core/profiler/BUILD index 30c7d86a5bdc60..c8c0463a0150e7 100644 --- a/tensorflow/core/profiler/BUILD +++ b/tensorflow/core/profiler/BUILD @@ -82,8 +82,13 @@ tf_proto_library( "tfprof_output.proto", ], cc_api_version = 2, - protodeps = tf_additional_all_protos(), + protodeps = [ + "//tensorflow/tsl/profiler/protobuf:profile_proto", + ] + tf_additional_all_protos(), visibility = [":friends"], + exports = [ + "//tensorflow/tsl/profiler/protobuf:profile_proto", + ], ) cc_library( diff --git a/tensorflow/core/profiler/profile.proto b/tensorflow/core/profiler/profile.proto index 27aa904c4a5c20..5e630d145deebe 100644 --- a/tensorflow/core/profiler/profile.proto +++ b/tensorflow/core/profiler/profile.proto @@ -1,71 +1,6 @@ // This proto intends to match format expected by pprof tool. syntax = "proto3"; -package tensorflow.tfprof.pprof; +package tensorflow.tfprof.pprof.dummy; -message Profile { - repeated ValueType sample_type = 1; - repeated Sample sample = 2; - repeated Mapping mapping = 3; - repeated Location location = 4; - repeated Function function = 5; - repeated string string_table = 6; - int64 drop_frames = 7; - int64 keep_frames = 8; - int64 time_nanos = 9; - int64 duration_nanos = 10; - ValueType period_type = 11; - int64 period = 12; - repeated int64 comment = 13; - int64 default_sample_type = 14; -} - -message ValueType { - int64 type = 1; - int64 unit = 2; -} - -message Sample { - repeated uint64 location_id = 1; - repeated int64 value = 2; - repeated Label label = 3; -} - -message Label { - int64 key = 1; - int64 str = 2; - int64 num = 3; -} - -message Mapping { - uint64 id = 1; - uint64 memory_start = 2; - uint64 memory_limit = 3; - uint64 file_offset = 4; - int64 filename = 5; - int64 build_id = 6; - bool has_functions = 7; - bool has_filenames = 8; - bool has_line_numbers = 9; - bool has_inline_frames = 10; -} - -message Location { - uint64 id = 1; - uint64 mapping_id = 2; - uint64 address = 3; - repeated Line line = 4; -} - -message Line { - uint64 function_id = 1; - int64 line = 2; -} - -message Function { - uint64 id = 1; - int64 name = 2; - int64 system_name = 3; - int64 filename = 4; - int64 start_line = 5; -} +import public "tensorflow/tsl/profiler/protobuf/profile.proto"; diff --git a/tensorflow/tsl/profiler/protobuf/BUILD b/tensorflow/tsl/profiler/protobuf/BUILD index 3efc8ec886732f..841e906667f106 100644 --- a/tensorflow/tsl/profiler/protobuf/BUILD +++ b/tensorflow/tsl/profiler/protobuf/BUILD @@ -24,6 +24,16 @@ exports_files( ], ) +tf_proto_library( + name = "profile_proto", + srcs = ["profile.proto"], + cc_api_version = 2, + visibility = [ + "//tensorflow/compiler/xla/python:__pkg__", + "//tensorflow/core/profiler:__pkg__", + ], +) + tf_proto_library( name = "protos_all", create_go_proto = False, diff --git a/tensorflow/tsl/profiler/protobuf/profile.proto b/tensorflow/tsl/profiler/protobuf/profile.proto new file mode 100644 index 00000000000000..27aa904c4a5c20 --- /dev/null +++ b/tensorflow/tsl/profiler/protobuf/profile.proto @@ -0,0 +1,71 @@ +// This proto intends to match format expected by pprof tool. +syntax = "proto3"; + +package tensorflow.tfprof.pprof; + +message Profile { + repeated ValueType sample_type = 1; + repeated Sample sample = 2; + repeated Mapping mapping = 3; + repeated Location location = 4; + repeated Function function = 5; + repeated string string_table = 6; + int64 drop_frames = 7; + int64 keep_frames = 8; + int64 time_nanos = 9; + int64 duration_nanos = 10; + ValueType period_type = 11; + int64 period = 12; + repeated int64 comment = 13; + int64 default_sample_type = 14; +} + +message ValueType { + int64 type = 1; + int64 unit = 2; +} + +message Sample { + repeated uint64 location_id = 1; + repeated int64 value = 2; + repeated Label label = 3; +} + +message Label { + int64 key = 1; + int64 str = 2; + int64 num = 3; +} + +message Mapping { + uint64 id = 1; + uint64 memory_start = 2; + uint64 memory_limit = 3; + uint64 file_offset = 4; + int64 filename = 5; + int64 build_id = 6; + bool has_functions = 7; + bool has_filenames = 8; + bool has_line_numbers = 9; + bool has_inline_frames = 10; +} + +message Location { + uint64 id = 1; + uint64 mapping_id = 2; + uint64 address = 3; + repeated Line line = 4; +} + +message Line { + uint64 function_id = 1; + int64 line = 2; +} + +message Function { + uint64 id = 1; + int64 name = 2; + int64 system_name = 3; + int64 filename = 4; + int64 start_line = 5; +}