From 23df084b32dd0cb43407924913f098aa1c9be785 Mon Sep 17 00:00:00 2001 From: guomingz Date: Mon, 22 Apr 2019 09:55:06 +0800 Subject: [PATCH] resolve #16987 (#16994) Rename the testcuda function to has_cuda, it will elimate the unnecessary testing. test=develop --- .../paddle/fluid/tests/unittests/test_conv2d_op.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_conv2d_op.py b/python/paddle/fluid/tests/unittests/test_conv2d_op.py index 2927a9828fd..1783fa65d5c 100644 --- a/python/paddle/fluid/tests/unittests/test_conv2d_op.py +++ b/python/paddle/fluid/tests/unittests/test_conv2d_op.py @@ -85,7 +85,7 @@ class TestConv2dOp(OpTest): } input = np.random.random(self.input_size).astype(self.dtype) - if not self.testcuda(): + if not self.has_cuda(): self.fuse_relu_before_depthwise_conv = False if self.fuse_relu_before_depthwise_conv: input = input - 0.5 @@ -117,25 +117,25 @@ class TestConv2dOp(OpTest): } self.outputs = {'Output': output} - def testcuda(self): + def has_cuda(self): return core.is_compiled_with_cuda() and (self.use_cudnn or self.use_cuda) def test_check_output(self): - place = core.CUDAPlace(0) if self.testcuda() else core.CPUPlace() + place = core.CUDAPlace(0) if self.has_cuda() else core.CPUPlace() self.check_output_with_place(place, atol=1e-5) def test_check_grad(self): if self.dtype == np.float16: return - place = core.CUDAPlace(0) if self.testcuda() else core.CPUPlace() + place = core.CUDAPlace(0) if self.has_cuda() else core.CPUPlace() self.check_grad_with_place( place, {'Input', 'Filter'}, 'Output', max_relative_error=0.02) def test_check_grad_no_filter(self): if self.dtype == np.float16: return - place = core.CUDAPlace(0) if self.testcuda() else core.CPUPlace() + place = core.CUDAPlace(0) if self.has_cuda() else core.CPUPlace() self.check_grad_with_place( place, ['Input'], 'Output', @@ -145,7 +145,7 @@ class TestConv2dOp(OpTest): def test_check_grad_no_input(self): if self.dtype == np.float16: return - place = core.CUDAPlace(0) if self.testcuda() else core.CPUPlace() + place = core.CUDAPlace(0) if self.has_cuda() else core.CPUPlace() self.check_grad_with_place( place, ['Filter'], 'Output', -- GitLab