(self)
| 778 | """Test running TPU computation on more than one core.""" |
| 779 | |
| 780 | def testBasic(self): |
| 781 | if not multiple_tpus(): |
| 782 | self.skipTest('MultiDeviceTest requires multiple TPU devices.') |
| 783 | |
| 784 | # Compute 10 on TPU core 0 |
| 785 | with ops.device('device:TPU:0'): |
| 786 | two = constant_op.constant(2) |
| 787 | five = constant_op.constant(5) |
| 788 | ten = two * five |
| 789 | self.assertAllEqual(10, ten) |
| 790 | |
| 791 | # Compute 6 on TPU core 1 |
| 792 | with ops.device('device:TPU:1'): |
| 793 | two = constant_op.constant(2) |
| 794 | three = constant_op.constant(3) |
| 795 | six = two * three |
| 796 | self.assertAllEqual(6, six) |
| 797 | |
| 798 | # Copy 10 and 6 to CPU and sum them |
| 799 | self.assertAllEqual(16, ten + six) |
| 800 | |
| 801 | |
| 802 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected