MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testCopies

Method testCopies

tensorflow/compiler/tests/xla_device_test.py:34–50  ·  view source on GitHub ↗

Tests that copies onto and off XLA devices work.

(self)

Source from the content-addressed store, hash-verified

32class 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."""

Callers

nothing calls this directly

Calls 7

sessionMethod · 0.45
deviceMethod · 0.45
placeholderMethod · 0.45
test_scopeMethod · 0.45
identityMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected