(self)
| 88 | |
| 89 | @test_util.deprecated_graph_mode_only |
| 90 | def testTimelineGpu(self): |
| 91 | if not test.is_gpu_available(cuda_only=True): |
| 92 | return |
| 93 | |
| 94 | run_options = config_pb2.RunOptions( |
| 95 | trace_level=config_pb2.RunOptions.FULL_TRACE) |
| 96 | run_metadata = config_pb2.RunMetadata() |
| 97 | |
| 98 | with self.session(force_gpu=True) as sess: |
| 99 | const1 = constant_op.constant(1.0, name='const1') |
| 100 | const2 = constant_op.constant(2.0, name='const2') |
| 101 | result = math_ops.add(const1, const2) + const1 * const2 |
| 102 | sess.run(result, options=run_options, run_metadata=run_metadata) |
| 103 | self.assertTrue(run_metadata.HasField('step_stats')) |
| 104 | step_stats = run_metadata.step_stats |
| 105 | devices = [d.device for d in step_stats.dev_stats] |
| 106 | self.assertTrue('/job:localhost/replica:0/task:0/device:GPU:0' in devices) |
| 107 | if not test.is_built_with_rocm(): |
| 108 | # skip this check for the ROCm platform |
| 109 | # stream level tracing is not yet supported on the ROCm platform |
| 110 | self.assertTrue('/device:GPU:0/stream:all' in devices) |
| 111 | tl = timeline.Timeline(step_stats) |
| 112 | ctf = tl.generate_chrome_trace_format() |
| 113 | self._validateTrace(ctf) |
| 114 | tl = timeline.Timeline(step_stats) |
| 115 | ctf = tl.generate_chrome_trace_format(show_dataflow=False) |
| 116 | self._validateTrace(ctf) |
| 117 | tl = timeline.Timeline(step_stats) |
| 118 | ctf = tl.generate_chrome_trace_format(show_memory=False) |
| 119 | self._validateTrace(ctf) |
| 120 | tl = timeline.Timeline(step_stats) |
| 121 | ctf = tl.generate_chrome_trace_format( |
| 122 | show_memory=False, show_dataflow=False) |
| 123 | self._validateTrace(ctf) |
| 124 | |
| 125 | def testTimelineWithRPCs(self): |
| 126 | """Tests that Timeline can handle RPC tracing.""" |
nothing calls this directly
no test coverage detected