Skip to content

Commit

Permalink
Move profile.proto to TSL
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 486230034
  • Loading branch information
cliveverghese authored and tensorflower-gardener committed Nov 4, 2022
1 parent 881f491 commit 32050bb
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 70 deletions.
2 changes: 1 addition & 1 deletion tensorflow/compiler/xla/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/compiler/xla/python/pprof_profile_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
7 changes: 6 additions & 1 deletion tensorflow/core/profiler/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
69 changes: 2 additions & 67 deletions tensorflow/core/profiler/profile.proto
Original file line number Diff line number Diff line change
@@ -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";
10 changes: 10 additions & 0 deletions tensorflow/tsl/profiler/protobuf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
71 changes: 71 additions & 0 deletions tensorflow/tsl/profiler/protobuf/profile.proto
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 32050bb

Please sign in to comment.