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

Method testGPU

tensorflow/contrib/eager/python/tfe_test.py:83–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

81
82 @test_util.run_gpu_only
83 def testGPU(self):
84 # tf.Tensor.as_gpu_device() moves a tensor to GPU.
85 x = constant_op.constant([[1., 2.], [3., 4.]]).gpu()
86 # Alternatively, tf.device() as a context manager places tensors and
87 # operations.
88 with ops.device('gpu:0'):
89 x += 1.
90 # Without a device context, heuristics are used to place ops.
91 # In this case, ops.reduce_mean runs on the GPU.
92 axis = range(x.shape.ndims)
93 m = math_ops.reduce_mean(x, axis)
94 # m is on GPU, bring it back to CPU and compare.
95 self.assertEqual(3.5, m.cpu().numpy())
96
97 def testListDevices(self):
98 # Expect at least one device.

Callers

nothing calls this directly

Calls 7

reduce_meanMethod · 0.80
cpuMethod · 0.80
rangeFunction · 0.50
gpuMethod · 0.45
constantMethod · 0.45
deviceMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected