in tb_plugin/torch_tb_profiler/profiler/run_generator.py [0:0]
def _generate_op_pie(self, group_by_input_shape=False):
op_device_total_time = []
op_device_self_time = []
op_host_total_time = []
op_host_self_time = []
if group_by_input_shape:
op_list = self.profile_data.op_list_groupby_name_input
else:
op_list = self.profile_data.op_list_groupby_name
for op_agg in op_list:
# Whether device_duration & self_device_duration are accurate or not depends on the input tracing data.
if op_agg.device_duration > 0:
op_device_total_time.append([op_agg.name, op_agg.device_duration])
if op_agg.self_device_duration > 0:
op_device_self_time.append([op_agg.name, op_agg.self_device_duration])
if op_agg.host_duration > 0:
op_host_total_time.append([op_agg.name, op_agg.host_duration])
if op_agg.self_host_duration > 0:
op_host_self_time.append([op_agg.name, op_agg.self_host_duration])
op_device_total_time.sort(key=lambda x: x[1], reverse=True)
op_device_self_time.sort(key=lambda x: x[1], reverse=True)
op_host_total_time.sort(key=lambda x: x[1], reverse=True)
op_host_self_time.sort(key=lambda x: x[1], reverse=True)
data = {}
device_total_time = {}
device_self_time = {}
host_total_time = {}
host_self_time = {}
if len(op_device_total_time) > 0:
device_total_time["title"] = "Device Total Time (us)"
device_total_time["columns"] = [{"type": "string", "name": "name"}, {"type": "number", "name": "value"}]
device_total_time["rows"] = op_device_total_time
else:
device_total_time = None
if len(op_device_self_time) > 0:
device_self_time["title"] = "Device Self Time (us)"
device_self_time["columns"] = [{"type": "string", "name": "name"}, {"type": "number", "name": "value"}]
device_self_time["rows"] = op_device_self_time
else:
device_self_time = None
if len(op_host_total_time) > 0:
host_total_time["title"] = "Host Total Time (us)"
host_total_time["columns"] = [{"type": "string", "name": "name"}, {"type": "number", "name": "value"}]
host_total_time["rows"] = op_host_total_time
else:
host_total_time = None
if len(op_host_self_time) > 0:
host_self_time["title"] = "Host Self Time (us)"
host_self_time["columns"] = [{"type": "string", "name": "name"}, {"type": "number", "name": "value"}]
host_self_time["rows"] = op_host_self_time
else:
host_self_time = None
data["device_total_time"] = device_total_time
data["device_self_time"] = device_self_time
data["host_total_time"] = host_total_time
data["host_self_time"] = host_self_time
return data