Skip cudnn test when cudnn v3 is not installed
@@ -4,18 +4,27 @@ import mock
import numpy
import cupy
+try:
import cupy.cuda.cudnn as libcudnn
+ cudnn_enabled = True
+ modes = [
+ libcudnn.CUDNN_ACTIVATION_SIGMOID,
+ libcudnn.CUDNN_ACTIVATION_RELU,
+ libcudnn.CUDNN_ACTIVATION_TANH,
+ ]
+except ImportError:
+ cudnn_enabled = False
+ modes = []
import cupy.cudnn
from cupy import testing
+@unittest.skipUnless(
+ cudnn_enabled and libcudnn.getVersion() >= 3000,
+ 'cuDNN >= 3.0 is supported')
@testing.parameterize(*testing.product({
- 'dtype': [numpy.float16, numpy.float32, numpy.float64],
- 'mode': [
- libcudnn.CUDNN_ACTIVATION_SIGMOID,
- libcudnn.CUDNN_ACTIVATION_RELU,
- libcudnn.CUDNN_ACTIVATION_TANH,
- ],
+ 'dtype': [numpy.float32, numpy.float64],
+ 'mode': modes,
}))
class TestCudnnActivation(unittest.TestCase):
@@ -25,23 +34,19 @@ class TestCudnnActivation(unittest.TestCase):
self.g = testing.shaped_arange((3, 4), cupy, self.dtype)
def test_activation_forward_version(self):
- expect = libcudnn.getVersion() >= 3000 or self.dtype != numpy.float16
-
if libcudnn.getVersion() >= 4000:
patch = 'cupy.cuda.cudnn.activationForward_v4'
else:
patch = 'cupy.cuda.cudnn.activationForward_v3'
with mock.patch(patch) as func:
cupy.cudnn.activation_forward(self.x, self.mode)
- self.assertEqual(func.called, expect)
+ self.assertEqual(func.called, True)
def test_activation_backward_version(self):
- expect = libcudnn.getVersion() >= 3000 or self.dtype != numpy.float16
-
if libcudnn.getVersion() >= 4000:
patch = 'cupy.cuda.cudnn.activationBackward_v4'
else:
patch = 'cupy.cuda.cudnn.activationBakward_v3'
with mock.patch(patch) as func:
cupy.cudnn.activation_backward(self.x, self.y, self.g, self.mode)
- self.assertEqual(func.called, expect)
+ self.assertEqual(func.called, True)
