@@ -41,12 +41,13 @@ def process_raw_trace(raw_trace):
4141 return '' .join (trace_events_json .TraceEventsJsonStream (trace ))
4242
4343
44- def xspace_to_tools_data_from_byte_string (xspace_byte_list , filenames , tool ,
45- params ):
44+ def xspace_to_tools_data_from_byte_string (xspace_byte_list , all_hosts ,
45+ filenames , tool , params ):
4646 """Helper function for getting an XSpace tool from a bytes string.
4747
4848 Args:
4949 xspace_byte_list: A list of byte strings read from a XSpace proto file.
50+ all_hosts: A list of all hosts in the session.
5051 filenames: Names of the read files.
5152 tool: A string of tool name.
5253 params: user input parameters.
@@ -57,7 +58,7 @@ def xspace_to_tools_data_from_byte_string(xspace_byte_list, filenames, tool,
5758# pylint:disable=dangerous-default-value
5859 def xspace_wrapper_func (xspace_arg , tool_arg , params = {}):
5960 return _pywrap_profiler_plugin .xspace_to_tools_data_from_byte_string (
60- xspace_arg , filenames , tool_arg , params )
61+ xspace_arg , all_hosts , filenames , tool_arg , params )
6162# pylint:enable=dangerous-default-value
6263
6364 return xspace_to_tool_data (xspace_byte_list , tool , params ,
@@ -73,22 +74,26 @@ def xspace_to_tool_names(xspace_paths):
7374 Returns:
7475 Returns a list of tool names.
7576 """
77+ # xspace_to_tools_data expects all_hosts as the second argument, passing an
78+ # empty list.
7679 raw_data , success = _pywrap_profiler_plugin .xspace_to_tools_data (
77- xspace_paths , 'tool_names' )
80+ xspace_paths , [], 'tool_names' , {} )
7881 if success :
7982 return [tool for tool in raw_data .decode ().split (',' )]
8083 return []
8184
8285
8386def xspace_to_tool_data (
8487 xspace_paths ,
88+ all_hosts ,
8589 tool ,
8690 params ,
8791 xspace_wrapper_func = _pywrap_profiler_plugin .xspace_to_tools_data ):
8892 """Converts XSpace to tool data string.
8993
9094 Args:
9195 xspace_paths: A list of XSpace paths.
96+ all_hosts: A list of all hosts in the session.
9297 tool: A string of tool name.
9398 params: user input parameters.
9499 xspace_wrapper_func: A callable that takes a list of strings and a tool and
@@ -112,26 +117,31 @@ def xspace_to_tool_data(
112117 if tool == 'trace_viewer' :
113118 # Trace viewer handles one host at a time.
114119 assert len (xspace_paths ) == 1
115- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
120+ raw_data , success = xspace_wrapper_func (
121+ xspace_paths , all_hosts , tool , options )
116122 if success :
117123 data = process_raw_trace (raw_data )
118124 elif tool == 'trace_viewer@' :
119125 options = params .get ('trace_viewer_options' , {})
120126 options ['use_saved_result' ] = params .get ('use_saved_result' , True )
121- options ['hosts' ] = params .get ('hosts' , [])
122- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
127+ options ['hosts' ] = all_hosts
128+ raw_data , success = xspace_wrapper_func (
129+ xspace_paths , all_hosts , tool , options )
123130 if success :
124131 data = raw_data
125132 elif tool == 'overview_page' :
126- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
133+ json_data , success = xspace_wrapper_func (
134+ xspace_paths , all_hosts , tool , options )
127135 if success :
128136 data = json_data
129137 elif tool == 'input_pipeline_analyzer' :
130- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
138+ json_data , success = xspace_wrapper_func (
139+ xspace_paths , all_hosts , tool , options )
131140 if success :
132141 data = json_data
133142 elif tool == 'framework_op_stats' :
134- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
143+ json_data , success = xspace_wrapper_func (
144+ xspace_paths , all_hosts , tool , options )
135145 if success :
136146 if tqx == 'out:csv' :
137147 data = csv_writer .json_to_csv (json_data )
@@ -142,15 +152,16 @@ def xspace_to_tool_data(
142152 # TODO(b/419013992): Remove this tool completely as it has been deprecated
143153 legacy_tool = 'tensorflow_stats'
144154 json_data , success = xspace_wrapper_func (
145- xspace_paths , legacy_tool , options
155+ xspace_paths , all_hosts , legacy_tool , options
146156 )
147157 if success :
148158 if tqx == 'out:csv' :
149159 data = csv_writer .json_to_csv (json_data )
150160 else :
151161 data = json_data
152162 elif tool == 'kernel_stats' :
153- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
163+ json_data , success = xspace_wrapper_func (
164+ xspace_paths , all_hosts , tool , options )
154165 if success :
155166 if tqx == 'out:csv' :
156167 data = csv_writer .json_to_csv (json_data )
@@ -159,37 +170,44 @@ def xspace_to_tool_data(
159170 elif tool == 'memory_profile' :
160171 # Memory profile handles one host at a time.
161172 assert len (xspace_paths ) == 1
162- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
173+ raw_data , success = xspace_wrapper_func (
174+ xspace_paths , all_hosts , tool , options )
163175 if success :
164176 data = raw_data
165177 elif tool == 'pod_viewer' :
166- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
178+ raw_data , success = xspace_wrapper_func (
179+ xspace_paths , all_hosts , tool , options )
167180 if success :
168181 data = raw_data
169182 elif tool == 'op_profile' :
170183 options ['group_by' ] = params .get ('group_by' , 'program' )
171- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
184+ raw_data , success = xspace_wrapper_func (
185+ xspace_paths , all_hosts , tool , options )
172186 if success :
173187 data = raw_data
174188 elif tool == 'hlo_op_profile' :
175189 options ['group_by' ] = params .get ('group_by' , 'program' )
176- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
190+ raw_data , success = xspace_wrapper_func (
191+ xspace_paths , all_hosts , tool , options )
177192 if success :
178193 data = raw_data
179194 elif tool == 'hlo_stats' :
180- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
195+ json_data , success = xspace_wrapper_func (
196+ xspace_paths , all_hosts , tool , options )
181197 if success :
182198 data = json_data
183199 elif tool == 'roofline_model' :
184- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
200+ json_data , success = xspace_wrapper_func (
201+ xspace_paths , all_hosts , tool , options )
185202 if success :
186203 data = json_data
187204 elif tool == 'graph_viewer' :
188205 download_hlo_types = ['pb' , 'pbtxt' , 'json' , 'short_txt' , 'long_txt' ]
189206 graph_html_type = 'graph'
190207 options = params .get ('graph_viewer_options' , {})
191208 options ['use_saved_result' ] = params .get ('use_saved_result' , True )
192- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
209+ raw_data , success = xspace_wrapper_func (
210+ xspace_paths , all_hosts , tool , options )
193211 if success :
194212 data = raw_data
195213 content_type = 'text/plain'
@@ -213,18 +231,21 @@ def xspace_to_tool_data(
213231 'view_memory_allocation_timeline' : view_memory_allocation_timeline ,
214232 'memory_space' : params .get ('memory_space' , '' ),
215233 }
216- raw_data , success = xspace_wrapper_func (xspace_paths , tool , options )
234+ raw_data , success = xspace_wrapper_func (
235+ xspace_paths , all_hosts , tool , options )
217236 if success :
218237 data = raw_data
219238 if view_memory_allocation_timeline :
220239 content_type = 'text/html'
221240 elif tool == 'megascale_stats' :
222241 options = {'host_name' : params .get ('host' )}
223- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
242+ json_data , success = xspace_wrapper_func (
243+ xspace_paths , all_hosts , tool , options )
224244 if success :
225245 data = json_data
226246 elif tool == 'inference_profile' :
227- json_data , success = xspace_wrapper_func (xspace_paths , tool , options )
247+ json_data , success = xspace_wrapper_func (
248+ xspace_paths , all_hosts , tool , options )
228249 if success :
229250 data = json_data
230251 else :
0 commit comments