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

Method _assign_lanes

tensorflow/python/client/timeline.py:435–464  ·  view source on GitHub ↗

Assigns non-overlapping lanes for the activities on each device.

(self, device_only)

Source from the content-addressed store, hash-verified

433 return nn, op, inputs
434
435 def _assign_lanes(self, device_only):
436 """Assigns non-overlapping lanes for the activities on each device."""
437 cpu_tid_assign = 0
438 cpu_tid_map = {}
439 for device_stats in self._step_stats.dev_stats:
440 device_name = device_stats.device
441 is_gputrace = self._is_gputrace_device(device_name)
442 is_launchtrace = self._is_launchtrace_device(device_name)
443 if (not device_only) or (device_only and is_gputrace and not is_launchtrace):
444 # TODO(pbar): Genuine thread IDs in NodeExecStats might be helpful.
445 lanes = [0]
446 for ns in device_stats.node_stats:
447 l = -1
448 for (i, lts) in enumerate(lanes):
449 if ns.all_start_micros > lts:
450 l = i
451 lanes[l] = ns.all_start_micros + ns.all_end_rel_micros
452 break
453 if l < 0:
454 l = len(lanes)
455 lanes.append(ns.all_start_micros + ns.all_end_rel_micros)
456 ns.thread_id = l
457 else:
458 for ns in device_stats.node_stats:
459 if ns.thread_id not in cpu_tid_map.keys():
460 cpu_tid_map[ns.thread_id] = cpu_tid_assign
461 ns.thread_id = cpu_tid_assign
462 cpu_tid_assign = cpu_tid_assign + 1
463 else:
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.

Callers 1

analyze_step_statsMethod · 0.95

Calls 4

_is_gputrace_deviceMethod · 0.95
appendMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected