(self)
| 172 | ''' |
| 173 | |
| 174 | def testManyCPUs(self): |
| 175 | run_options = config_pb2.RunOptions( |
| 176 | trace_level=config_pb2.RunOptions.FULL_TRACE) |
| 177 | run_metadata = config_pb2.RunMetadata() |
| 178 | config = config_pb2.ConfigProto(device_count={'CPU': 3}) |
| 179 | with session.Session(config=config) as sess: |
| 180 | with ops.device('/cpu:0'): |
| 181 | num1 = variables.Variable(1.0, name='num1') |
| 182 | with ops.device('/cpu:1'): |
| 183 | num2 = variables.Variable(2.0, name='num2') |
| 184 | with ops.device('/cpu:2'): |
| 185 | result = num1 + num2 + num1 * num2 |
| 186 | self.evaluate(variables.global_variables_initializer()) |
| 187 | sess.run(result, options=run_options, run_metadata=run_metadata) |
| 188 | self.assertTrue(run_metadata.HasField('step_stats')) |
| 189 | step_stats = run_metadata.step_stats |
| 190 | devices = [d.device for d in step_stats.dev_stats] |
| 191 | self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:0' in devices) |
| 192 | self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:1' in devices) |
| 193 | self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:2' in devices) |
| 194 | tl = timeline.Timeline(step_stats) |
| 195 | ctf = tl.generate_chrome_trace_format() |
| 196 | self._validateTrace(ctf) |
| 197 | tl = timeline.Timeline(step_stats) |
| 198 | ctf = tl.generate_chrome_trace_format(show_dataflow=False) |
| 199 | self._validateTrace(ctf) |
| 200 | tl = timeline.Timeline(step_stats) |
| 201 | ctf = tl.generate_chrome_trace_format(show_memory=False) |
| 202 | self._validateTrace(ctf) |
| 203 | tl = timeline.Timeline(step_stats) |
| 204 | ctf = tl.generate_chrome_trace_format( |
| 205 | show_memory=False, show_dataflow=False) |
| 206 | self._validateTrace(ctf) |
| 207 | |
| 208 | |
| 209 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected