MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _emit_op

Method _emit_op

tensorflow/python/client/timeline.py:466–533  ·  view source on GitHub ↗

Generates a Chrome Trace event to show Op execution. Args: nodestats: The 'NodeExecStats' proto recording op execution. pid: The pid assigned for the device where this op ran. is_gputrace: If True then this op came from the GPUTracer.

(self, nodestats, pid, is_gputrace, is_hosttrace, activity_cache)

Source from the content-addressed store, hash-verified

464 ns.thread_id = cpu_tid_map[ns.thread_id]
465
466 def _emit_op(self, nodestats, pid, is_gputrace, is_hosttrace, activity_cache):
467 """Generates a Chrome Trace event to show Op execution.
468
469 Args:
470 nodestats: The 'NodeExecStats' proto recording op execution.
471 pid: The pid assigned for the device where this op ran.
472 is_gputrace: If True then this op came from the GPUTracer.
473 """
474 kernel_name = None
475 node_name = nodestats.node_name
476 start = nodestats.all_start_micros
477 duration = nodestats.all_end_rel_micros
478 tid = nodestats.thread_id
479 # extract calling contexts via backtracing the parents
480 cct = ""
481 parent_id = nodestats.parent_id
482 while parent_id != 0:
483 if parent_id not in activity_cache.keys():
484 cct += "<unknown>"
485 break
486 node, _ = activity_cache[parent_id]
487 cct += node.node_name + "\n"
488 parent_id = node.parent_id
489 if parent_id == 0:
490 cct += "<root>"
491 # extract info from node name
492 inputs = []
493 args = {}
494 if is_gputrace:
495 # Node names should always have the form 'name:op@@kernel_name'
496 fields = node_name.split('@@') + ["unknown"]
497 node_name, kernel_name = fields[:2]
498 # Node names should always have the form 'name:op'.
499 fields = node_name.split(':') + [kernel_name]
500 node_name, op = fields[:2]
501 elif is_hosttrace:
502 # Node names should have the form 'name:op' or 'op'
503 if '::' in node_name:
504 fields = node_name.split('::')
505 node_name = fields[0].split(':')
506 if len(node_name)==1:
507 op = '::'.join(fields)
508 node_name = 'unknown'
509 kernel = op
510 else:
511 kernel = "::".join([node_name[-1]]+fields[1:])
512 node_name, op = node_name[:2]
513 else:
514 fields = node_name.split(':') + ['unknown']
515 node_name, op = fields[:2]
516 elif node_name == 'RecvTensor':
517 # RPC tracing does not use the standard timeline_label format.
518 op = 'RecvTensor'
519 labels = nodestats.timeline_label.split(';')
520 args['size'] = labels[0]
521 args['rate'] = labels[1]
522 args['tensor name'] = labels[2]
523 args['direction'] = labels[3]

Callers 1

_show_computeMethod · 0.95

Calls 5

_parse_op_labelMethod · 0.95
keysMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45
emit_regionMethod · 0.45

Tested by

no test coverage detected