Analyze tensor references to track dataflow.
(self, show_memory)
| 653 | self._chrome_trace.emit_pid(dev_stats.device + ' Tensors', tensors_pid) |
| 654 | |
| 655 | def _analyze_tensors(self, show_memory): |
| 656 | """Analyze tensor references to track dataflow.""" |
| 657 | for dev_stats in self._step_stats.dev_stats: |
| 658 | device_pid = self._device_pids[dev_stats.device] |
| 659 | tensors_pid = self._tensor_pids[dev_stats.device] |
| 660 | for node_stats in dev_stats.node_stats: |
| 661 | tid = node_stats.thread_id |
| 662 | node_name = node_stats.node_name |
| 663 | start_time = node_stats.all_start_micros |
| 664 | end_time = node_stats.all_start_micros + node_stats.all_end_rel_micros |
| 665 | for index, output in enumerate(node_stats.output): |
| 666 | if index: |
| 667 | output_name = '%s:%d' % (node_name, index) |
| 668 | else: |
| 669 | output_name = node_name |
| 670 | |
| 671 | allocation = output.tensor_description.allocation_description |
| 672 | num_bytes = allocation.requested_bytes |
| 673 | allocator_name = allocation.allocator_name |
| 674 | tensor = self._produce_tensor(output_name, start_time, tensors_pid, |
| 675 | allocator_name, num_bytes) |
| 676 | tensor.add_ref(start_time) |
| 677 | tensor.add_unref(end_time) |
| 678 | self._flow_starts[output_name] = (end_time, device_pid, tid) |
| 679 | |
| 680 | if show_memory: |
| 681 | self._chrome_trace.emit_obj_create('Tensor', output_name, |
| 682 | start_time, tensors_pid, tid, |
| 683 | tensor.object_id) |
| 684 | self._emit_tensor_snapshot(tensor, end_time - 1, tensors_pid, tid, |
| 685 | output) |
| 686 | |
| 687 | def _show_compute(self, show_dataflow): |
| 688 | """Visualize the computation activity.""" |
no test coverage detected