diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-10-18 16:25:56 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-10-18 16:30:30 -0700 |
commit | bba3957467ad8ba9351b829036120412d5d006cb (patch) | |
tree | 73796fd844d5d4da1a2b673caa574094e9075cd3 /tensorflow/python/eager/backprop_test.py | |
parent | 2b91b812ef50384cd0526ea513f1cf585adb6ef7 (diff) |
Replace as_gpu_tensor and as_cpu_tensor to gpu and cpu
PiperOrigin-RevId: 172673720
Diffstat (limited to 'tensorflow/python/eager/backprop_test.py')
-rw-r--r-- | tensorflow/python/eager/backprop_test.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tensorflow/python/eager/backprop_test.py b/tensorflow/python/eager/backprop_test.py index 002be95d0f..5161095683 100644 --- a/tensorflow/python/eager/backprop_test.py +++ b/tensorflow/python/eager/backprop_test.py @@ -209,10 +209,10 @@ class BackpropTest(test.TestCase): def fn(x): with context.device('/gpu:0'): b = constant_op.constant(2.0) - c = math_ops.add(x.as_gpu_tensor(), b) - # TODO(apassos): remove as_cpu_tensor below by making TensorVSPace aware + c = math_ops.add(x.gpu(), b) + # TODO(apassos): remove cpu below by making TensorVSPace aware # of devices. - return math_ops.add(c, constant_op.constant(3.0)).as_cpu_tensor() + return math_ops.add(c, constant_op.constant(3.0)).cpu() grad = backprop.gradients_function(fn, [0])(constant_op.constant(1.0))[0] self.assertAllEqual(grad, 1.0) @@ -230,7 +230,7 @@ class BackpropTest(test.TestCase): return v.read_value() self.assertEqual( - backprop.implicit_grad(f)()[0][0].as_cpu_tensor().numpy(), 1.0) + backprop.implicit_grad(f)()[0][0].cpu().numpy(), 1.0) def testCPU(self): @@ -247,7 +247,7 @@ class BackpropTest(test.TestCase): self.skipTest('No GPUs found') def f(a, b): - return a.as_cpu_tensor() + b.as_cpu_tensor() + return a.cpu() + b.cpu() with context.device('/gpu:0'): a = constant_op.constant(1.0) @@ -309,8 +309,8 @@ class BackpropTest(test.TestCase): # back: e (cpu) -> add (cpu) -> c (cpu->gpu) -> add (gpu) -> grad (gpu->cpu) def f(a, b): with context.device('/gpu:0'): - c = math_ops.add(a.as_gpu_tensor(0), b.as_gpu_tensor(0)) - return math_ops.add(c.as_cpu_tensor(), constant_op.constant(3.0)) + c = math_ops.add(a.gpu(0), b.gpu(0)) + return math_ops.add(c.cpu(), constant_op.constant(3.0)) with context.device('/cpu:0'): a = constant_op.constant(1.0) |