tensorboard-plugin-profile 2.19.0__cp310-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. tensorboard_plugin_profile/__init__.py +22 -0
  2. tensorboard_plugin_profile/convert/_pywrap_profiler_plugin.so +0 -0
  3. tensorboard_plugin_profile/convert/dcn_collective_stats_proto_to_gviz.py +142 -0
  4. tensorboard_plugin_profile/convert/diagnostics.py +47 -0
  5. tensorboard_plugin_profile/convert/hlo_stats_proto_to_gviz.py +162 -0
  6. tensorboard_plugin_profile/convert/inference_stats_proto_to_gviz.py +327 -0
  7. tensorboard_plugin_profile/convert/input_pipeline_proto_to_gviz.py +545 -0
  8. tensorboard_plugin_profile/convert/kernel_stats_proto_to_gviz.py +111 -0
  9. tensorboard_plugin_profile/convert/overview_page_proto_to_gviz.py +296 -0
  10. tensorboard_plugin_profile/convert/raw_to_tool_data.py +259 -0
  11. tensorboard_plugin_profile/convert/roofline_model_proto_to_gviz.py +392 -0
  12. tensorboard_plugin_profile/convert/tf_data_stats_proto_to_gviz.py +204 -0
  13. tensorboard_plugin_profile/convert/tf_stats_proto_to_gviz.py +122 -0
  14. tensorboard_plugin_profile/convert/trace_events_json.py +105 -0
  15. tensorboard_plugin_profile/integration_tests/tf_mnist.py +100 -0
  16. tensorboard_plugin_profile/integration_tests/tf_profiler_session.py +40 -0
  17. tensorboard_plugin_profile/integration_tests/tpu/tensorflow/tpu_tf2_keras_test.py +178 -0
  18. tensorboard_plugin_profile/profile_plugin.py +1006 -0
  19. tensorboard_plugin_profile/profile_plugin_loader.py +83 -0
  20. tensorboard_plugin_profile/protobuf/dcn_slack_analysis_pb2.py +31 -0
  21. tensorboard_plugin_profile/protobuf/diagnostics_pb2.py +25 -0
  22. tensorboard_plugin_profile/protobuf/hlo_stats_pb2.py +27 -0
  23. tensorboard_plugin_profile/protobuf/inference_stats_pb2.py +75 -0
  24. tensorboard_plugin_profile/protobuf/input_pipeline_pb2.py +41 -0
  25. tensorboard_plugin_profile/protobuf/kernel_stats_pb2.py +27 -0
  26. tensorboard_plugin_profile/protobuf/overview_page_pb2.py +53 -0
  27. tensorboard_plugin_profile/protobuf/power_metrics_pb2.py +27 -0
  28. tensorboard_plugin_profile/protobuf/roofline_model_pb2.py +30 -0
  29. tensorboard_plugin_profile/protobuf/tf_data_stats_pb2.py +61 -0
  30. tensorboard_plugin_profile/protobuf/tf_stats_pb2.py +29 -0
  31. tensorboard_plugin_profile/protobuf/tpu_input_pipeline_pb2.py +32 -0
  32. tensorboard_plugin_profile/protobuf/trace_events_pb2.py +43 -0
  33. tensorboard_plugin_profile/static/bundle.js +124747 -0
  34. tensorboard_plugin_profile/static/index.html +64 -0
  35. tensorboard_plugin_profile/static/index.js +3 -0
  36. tensorboard_plugin_profile/static/materialicons.woff2 +0 -0
  37. tensorboard_plugin_profile/static/styles.css +1 -0
  38. tensorboard_plugin_profile/static/trace_viewer_index.html +3902 -0
  39. tensorboard_plugin_profile/static/trace_viewer_index.js +21555 -0
  40. tensorboard_plugin_profile/static/zone.js +3558 -0
  41. tensorboard_plugin_profile/version.py +17 -0
  42. tensorboard_plugin_profile-2.19.0.dist-info/METADATA +127 -0
  43. tensorboard_plugin_profile-2.19.0.dist-info/RECORD +46 -0
  44. tensorboard_plugin_profile-2.19.0.dist-info/WHEEL +5 -0
  45. tensorboard_plugin_profile-2.19.0.dist-info/entry_points.txt +2 -0
  46. tensorboard_plugin_profile-2.19.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,22 @@
1
+ # Copyright 2019 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
+ """Entry point for the TensorBoard plugin package for performance profiling.
16
+
17
+ Public submodules:
18
+ summary: Summary-writing ops.
19
+ Private submodules:
20
+ metadata: Global constants and the like.
21
+ plugin: TensorBoard backend plugin.
22
+ """
@@ -0,0 +1,142 @@
1
+ # Copyright 2020 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
+ """For conversion of Dcn Collective Stats page protos to GViz DataTables.
16
+
17
+ Usage:
18
+ gviz_data_tables = generate_all_chart_tables(dcn_slack_analysis)
19
+ """
20
+
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+
25
+ import sys
26
+
27
+ import gviz_api
28
+
29
+ from tensorboard_plugin_profile.protobuf import dcn_slack_analysis_pb2
30
+
31
+ _BYTES_TO_GIGABITS_CONVERSION_FACTOR = 8e-9
32
+ _MICRO_TO_SECONDS_CONVERSION_FACTOR = 1e-6
33
+ _BANDWIDTH_CONVERSION_FACTOR = (
34
+ _BYTES_TO_GIGABITS_CONVERSION_FACTOR / _MICRO_TO_SECONDS_CONVERSION_FACTOR
35
+ )
36
+
37
+
38
+ def convert_bytes_to_human_readable_format(value):
39
+ """Convert number of bytes to a human readable format (e.g. 10 KB).
40
+
41
+ Args:
42
+ value: bytes to convert.
43
+
44
+ Returns:
45
+ str: Human readable representation of data.
46
+ """
47
+ suffix_list = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
48
+
49
+ base = 1000
50
+ actual_bytes = float(value)
51
+ abs_bytes = abs(actual_bytes)
52
+
53
+ if abs_bytes == 1:
54
+ return "%d Byte" % actual_bytes
55
+
56
+ if abs_bytes < base:
57
+ return "%d Bytes" % actual_bytes
58
+
59
+ unit = base**2
60
+ suffix = suffix_list[0]
61
+ index = 0
62
+ while index < len(suffix_list):
63
+ unit = base ** (index + 2)
64
+ suffix = suffix_list[index]
65
+ if abs_bytes < unit:
66
+ break
67
+ index += 1
68
+
69
+ return "{0} {1}".format(base * actual_bytes / unit, suffix)
70
+
71
+
72
+ def get_dcn_collective_stats_table_args(dcn_slack_analysis):
73
+ """Creates a gviz DataTable object from DcnSlackAnalysis proto.
74
+
75
+ Args:
76
+ dcn_slack_analysis: dcn_slack_analysis_pb2.DcnSlackAnalysis.
77
+
78
+ Returns:
79
+ Returns a gviz_api.DataTable
80
+ """
81
+
82
+ table_description = [
83
+ ("dcnCollectiveName", "string", "DCN Collective Name"),
84
+ ("recvOpName", "string", "Recv Op Name"),
85
+ ("sendOpName", "string", "Send Op Name"),
86
+ ("slackTime", "number", "Slack Time (ms)"),
87
+ ("observedDuration", "number", "Observed Duration (ms)"),
88
+ ("stallDuration", "number", "Stall Duration (ms)"),
89
+ ("occurrences", "number", "Occurrences"),
90
+ ("totalStallDuration", "number", "Aggregated Total Stall (ms)"),
91
+ ("dataTransmittedSize", "string", "Data Transmitted Size"),
92
+ ("requiredBandwidth", "number", "Required Bandwidth (Gbps)"),
93
+ ]
94
+
95
+ data = []
96
+ for slack in dcn_slack_analysis.dcn_slack_summary:
97
+ row = [
98
+ slack.rendezvous,
99
+ slack.recv_op_name,
100
+ slack.send_op_name,
101
+ slack.slack_us / 1000,
102
+ slack.observed_duration_us / 1000,
103
+ slack.stall_duration_us / 1000,
104
+ slack.occurrences,
105
+ (slack.stall_duration_us * slack.occurrences) / 1000,
106
+ convert_bytes_to_human_readable_format(
107
+ slack.bytes_transmitted_over_network
108
+ ),
109
+ ]
110
+ if slack.slack_us == 0:
111
+ row.append(float(sys.maxsize))
112
+ else:
113
+ row.append(
114
+ (slack.bytes_transmitted_over_network / slack.slack_us)
115
+ * _BANDWIDTH_CONVERSION_FACTOR
116
+ )
117
+ data.append(row)
118
+
119
+ return (table_description, data, [])
120
+
121
+
122
+ def generate_dcn_collective_stats_table(dcn_slack_analysis):
123
+ (table_description, data, custom_properties) = (
124
+ get_dcn_collective_stats_table_args(dcn_slack_analysis)
125
+ )
126
+ return gviz_api.DataTable(table_description, data, custom_properties)
127
+
128
+
129
+ def generate_all_chart_tables(dcn_slack_analysis):
130
+ """Converts a DcnSlackAnalysis proto to gviz DataTables."""
131
+ return [
132
+ generate_dcn_collective_stats_table(dcn_slack_analysis),
133
+ ]
134
+
135
+
136
+ def to_json(raw_data):
137
+ """Converts a serialized DcnCollectiveAnalysis string to json."""
138
+ dcn_slack_analysis = dcn_slack_analysis_pb2.DcnSlackAnalysis()
139
+ dcn_slack_analysis.ParseFromString(raw_data)
140
+ all_chart_tables = generate_all_chart_tables(dcn_slack_analysis)
141
+ json_join = ",".join(x.ToJSon() if x else "{}" for x in all_chart_tables)
142
+ return "[" + json_join + "]"
@@ -0,0 +1,47 @@
1
+ # Copyright 2020 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
+ """For conversion of diagnostics protos to GViz DataTables.
16
+
17
+ Usage:
18
+ gviz_data_tables = generate_diagnostics_tables(diag)
19
+ """
20
+
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+
25
+ import gviz_api
26
+
27
+
28
+ def generate_diagnostics_table(diag):
29
+ """Creates a diagnostics table from Diagnostics proto.
30
+
31
+ Args:
32
+ diag: An diagnostics_pb2.Diagnostics.
33
+
34
+ Returns:
35
+ Returns a gviz_api.DataTable
36
+ """
37
+ table_description = [("severity", "string", "severity"),
38
+ ("message", "string", "message")]
39
+ data = []
40
+ for info in diag.info:
41
+ data.append(["INFO", info])
42
+ for warning in diag.warnings:
43
+ data.append(["WARNING", warning])
44
+ for error in diag.errors:
45
+ data.append(["ERROR", error])
46
+
47
+ return gviz_api.DataTable(table_description, data)
@@ -0,0 +1,162 @@
1
+ # Copyright 2024 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
+ """For conversion of HloStats protos to GViz DataTables.
16
+
17
+ Usage:
18
+ gviz_data_tables = generate_hlo_stats_table(hlo_stats_db)
19
+ """
20
+
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+
25
+ from typing import Any
26
+
27
+ import gviz_api
28
+
29
+ from tensorboard_plugin_profile.protobuf import hlo_stats_pb2
30
+
31
+
32
+ def get_hlo_op_name_from_expression(hlo_op_expression: str) -> str:
33
+ """Returns the hlo op name from the hlo op expression.
34
+
35
+ Args:
36
+ hlo_op_expression: A string of hlo op expression.
37
+
38
+ Returns:
39
+ Returns the hlo op name extracted from the hlo op expression.
40
+ """
41
+ # The parse logic based on the assumption that the hlo op text is in format of
42
+ # '%op_name = <long name>'
43
+ parts = hlo_op_expression.split(" = ")
44
+ hlo_op_name = parts[0]
45
+ if hlo_op_name and hlo_op_name[0] == "%":
46
+ hlo_op_name = hlo_op_name[1:]
47
+ return hlo_op_name
48
+
49
+
50
+ TableColumnDescription = tuple[str, str, str]
51
+ TableRow = list[Any]
52
+ TableProperties = dict[str, Any]
53
+
54
+
55
+ def get_hlo_stats_table_args(
56
+ hlo_stats_db: hlo_stats_pb2.HloStatsDatabase,
57
+ ) -> tuple[list[TableColumnDescription], list[TableRow], TableProperties]:
58
+ """Creates hlo op stats table from a hlo stats proto.
59
+
60
+ Args:
61
+ hlo_stats_db: A HloStatsDatabase proto.
62
+
63
+ Returns:
64
+ Returns table description(column defubutuibs), data(rows data) and custom
65
+ properties for preparing the HloStats gviz table.
66
+ """
67
+
68
+ table_description = [
69
+ ("rank", "number", "Rank"),
70
+ ("program_id", "string", "Program id"),
71
+ ("category", "string", "HLO op category"),
72
+ ("hlo_op_name", "string", "HLO op name"),
73
+ ("hlo_op_expression", "string", "HLO op text"),
74
+ ("tf_op_name", "string", "Framework op name"),
75
+ ("occurrences", "number", "#Occurrences"),
76
+ ("total_time", "number", "Total time (us)"),
77
+ ("avg_time", "number", "Avg. time (us)"),
78
+ ("total_self_time", "number", "Total self time (us)"),
79
+ ("avg_self_time", "number", "Avg. self time (us)"),
80
+ ("total_self_time_percent", "number", "Total self time (%)"),
81
+ (
82
+ "cumulative_total_self_time_percent",
83
+ "number",
84
+ "Cumulative total self time (%)",
85
+ ),
86
+ ("dma_stall_percent", "number", "%time stalled by DMA"),
87
+ ("model_flop_rate", "number", "Model GFLOP/s"),
88
+ ("normalized_flop_rate", "number", "Normalized GFLOP/s"),
89
+ ("measured_memory_bw", "number", "Measured memory BW (GiB/s)"),
90
+ ("hbm_bw", "number", "HBM BW (GiB/s)"),
91
+ ("cmem_read_bw", "number", "CMEM Read BW (GiB/s)"),
92
+ ("cmem_write_bw", "number", "CMEM Write BW (GiB/s)"),
93
+ ("operational_intensity", "number", "Operational intensity (FLOPS/Byte)"),
94
+ ("bound_by", "string", "Bound by"),
95
+ ("hlo_rematerialization", "string", "Rematerialization"),
96
+ ("outside_compilation", "string", "Outside Compilation"),
97
+ ("autotuned", "string", "Autotuned"),
98
+ ]
99
+
100
+ data = []
101
+ for record in hlo_stats_db.hlo_stats_record:
102
+ row = [
103
+ record.rank,
104
+ str(record.program_id),
105
+ record.hlo_category,
106
+ get_hlo_op_name_from_expression(record.hlo_expression),
107
+ record.hlo_expression,
108
+ record.tf_op_name,
109
+ record.occurrences,
110
+ record.total_time_in_us,
111
+ record.avg_time_in_us,
112
+ record.total_self_time_in_us,
113
+ record.avg_self_time_in_us,
114
+ record.total_self_time_as_fraction,
115
+ record.cumulative_total_self_time_as_fraction,
116
+ record.dma_stall_fraction,
117
+ record.model_flop_rate,
118
+ record.measured_flop_rate,
119
+ record.measured_memory_bw,
120
+ record.hbm_bw,
121
+ record.cmem_read_bw,
122
+ record.cmem_write_bw,
123
+ record.operational_intensity,
124
+ record.bound_by,
125
+ "Yes" if record.rematerialization else "No",
126
+ "Yes" if record.outside_compilation else "No",
127
+ "Yes" if record.autotuned else "No",
128
+ ]
129
+ data.append(row)
130
+
131
+ return (table_description, data, {})
132
+
133
+
134
+ def generate_hlo_stats_table(
135
+ hlo_stats_db: hlo_stats_pb2.HloStatsDatabase,
136
+ ) -> gviz_api.DataTable:
137
+ """Converts a HloStatsDb proto to a GViz DataTable.
138
+
139
+ Args:
140
+ hlo_stats_db: A HloStatsDatabase proto.
141
+
142
+ Returns:
143
+ Returns a GViz DataTable for HloStats.
144
+ """
145
+ (table_description, data, custom_properties) = get_hlo_stats_table_args(
146
+ hlo_stats_db
147
+ )
148
+ return gviz_api.DataTable(table_description, data, custom_properties)
149
+
150
+
151
+ def to_json(raw_data: bytes) -> str:
152
+ """Converts a serialized HloStatsDb bytes to json.
153
+
154
+ Args:
155
+ raw_data: Bytes of serialized HloStatsDb.
156
+
157
+ Returns:
158
+ Returns a json string of HloStats Table.
159
+ """
160
+ hlo_stats_db = hlo_stats_pb2.HloStatsDatabase()
161
+ hlo_stats_db.ParseFromString(raw_data)
162
+ return generate_hlo_stats_table(hlo_stats_db).ToJSon()