Tests that copies onto and off XLA devices work.
(self)
| 32 | class XlaDeviceTest(xla_test.XLATestCase): |
| 33 | |
| 34 | def testCopies(self): |
| 35 | """Tests that copies onto and off XLA devices work.""" |
| 36 | shapes = [[0], [1], [1, 0], [1024, 0], [1024, 1], [3, 777], [777, 3], |
| 37 | [16384, 1], [1, 16384], [1, 20000, 1, 1]] |
| 38 | for dtype in self.numeric_types: |
| 39 | for shape in shapes: |
| 40 | with self.session() as sess: |
| 41 | with ops.device("CPU"): |
| 42 | x = array_ops.placeholder(dtype, shape) |
| 43 | with self.test_scope(): |
| 44 | y = x + x |
| 45 | with ops.device("CPU"): |
| 46 | z = array_ops.identity(y) |
| 47 | |
| 48 | inputs = np.random.randint(-100, 100, shape).astype(dtype) |
| 49 | result = sess.run(z, {x: inputs}) |
| 50 | self.assertAllCloseAccordingToType(result, inputs + inputs) |
| 51 | |
| 52 | def testCopiesOfUnsupportedTypesFailGracefully(self): |
| 53 | """Tests that copies of unsupported types don't crash.""" |
nothing calls this directly
no test coverage detected