提交 07a689b6 authored 作者: Frederic Bastien's avatar Frederic Bastien

skip tests when scipy isn't there

上级 be494716
...@@ -14,7 +14,7 @@ from theano.gpuarray.linalg import (GpuCholesky, GpuMagmaCholesky, ...@@ -14,7 +14,7 @@ from theano.gpuarray.linalg import (GpuCholesky, GpuMagmaCholesky,
gpu_solve, gpu_svd, gpu_qr) gpu_solve, gpu_svd, gpu_qr)
from theano.tensor.nlinalg import (SVD, MatrixInverse, QRFull, from theano.tensor.nlinalg import (SVD, MatrixInverse, QRFull,
QRIncomplete, eigh, matrix_inverse, qr) QRIncomplete, eigh, matrix_inverse, qr)
from theano.tensor.slinalg import Cholesky, cholesky from theano.tensor.slinalg import Cholesky, cholesky, imported_scipy
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
from .. import gpuarray_shared_constructor from .. import gpuarray_shared_constructor
...@@ -149,6 +149,8 @@ class TestGpuCholesky(unittest.TestCase): ...@@ -149,6 +149,8 @@ class TestGpuCholesky(unittest.TestCase):
utt.assert_allclose(chol_A_res, chol_A_val) utt.assert_allclose(chol_A_res, chol_A_val)
def test_gpu_cholesky_opt(self): def test_gpu_cholesky_opt(self):
if not imported_scipy:
self.skipTest('SciPy is not enabled, skipping test')
A = theano.tensor.matrix("A", dtype="float32") A = theano.tensor.matrix("A", dtype="float32")
fn = theano.function([A], cholesky(A), mode=mode_with_gpu) fn = theano.function([A], cholesky(A), mode=mode_with_gpu)
assert any([isinstance(node.op, GpuCholesky) assert any([isinstance(node.op, GpuCholesky)
......
...@@ -645,8 +645,8 @@ def test_no_complex(): ...@@ -645,8 +645,8 @@ def test_no_complex():
@utt.assertFailure_fast @utt.assertFailure_fast
def test_local_lift_solve(): def test_local_lift_solve():
if not cusolver_available: if not cusolver_available or not slinalg.imported_scipy:
raise SkipTest('No cuSolver') raise SkipTest('No cuSolver or SciPy')
A = tensor.fmatrix() A = tensor.fmatrix()
b = tensor.fmatrix() b = tensor.fmatrix()
o = slinalg.solve(A, b) o = slinalg.solve(A, b)
...@@ -663,8 +663,8 @@ def test_local_lift_solve(): ...@@ -663,8 +663,8 @@ def test_local_lift_solve():
def test_gpu_solve_not_inplace(): def test_gpu_solve_not_inplace():
if not cusolver_available: if not cusolver_available or not slinalg.imported_scipy:
raise SkipTest('No cuSolver') raise SkipTest('No cuSolver or Scipy')
A = tensor.fmatrix() A = tensor.fmatrix()
b = tensor.fmatrix() b = tensor.fmatrix()
s = slinalg.solve(A, b) s = slinalg.solve(A, b)
...@@ -681,8 +681,8 @@ def test_gpu_solve_not_inplace(): ...@@ -681,8 +681,8 @@ def test_gpu_solve_not_inplace():
@utt.assertFailure_fast @utt.assertFailure_fast
def test_local_lift_cholesky(): def test_local_lift_cholesky():
if not cusolver_available: if not cusolver_available or not slinalg.imported_scipy:
raise SkipTest('No cuSolver') raise SkipTest('No cuSolver or Scipy')
A = tensor.fmatrix() A = tensor.fmatrix()
o = slinalg.cholesky(A) o = slinalg.cholesky(A)
f_cpu = theano.function([A], o, mode=mode_without_gpu) f_cpu = theano.function([A], o, mode=mode_without_gpu)
...@@ -699,8 +699,8 @@ def test_local_lift_cholesky(): ...@@ -699,8 +699,8 @@ def test_local_lift_cholesky():
def test_gpu_cholesky_not_inplace(): def test_gpu_cholesky_not_inplace():
if not cusolver_available: if not cusolver_available or not slinalg.imported_scipy:
raise SkipTest('No cuSolver') raise SkipTest('No cuSolver or SciPy')
A = tensor.fmatrix() A = tensor.fmatrix()
A_squared = A**2 A_squared = A**2
B = slinalg.cholesky(A_squared) B = slinalg.cholesky(A_squared)
......
...@@ -741,6 +741,8 @@ class TestAbstractConvNoOptim(BaseTestConv2d): ...@@ -741,6 +741,8 @@ class TestAbstractConvNoOptim(BaseTestConv2d):
cls.border_modes = ["valid", "half", "full"] cls.border_modes = ["valid", "half", "full"]
cls.filter_flip = [True] cls.filter_flip = [True]
cls.provide_shape = [False] cls.provide_shape = [False]
if not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("SciPy needed")
def tcase(self, i, f, s, b, flip, provide_shape, fd=(1, 1)): def tcase(self, i, f, s, b, flip, provide_shape, fd=(1, 1)):
o = self.get_output_shape(i, f, s, b, fd) o = self.get_output_shape(i, f, s, b, fd)
...@@ -1454,8 +1456,8 @@ class Grouped_conv_noOptim(unittest.TestCase): ...@@ -1454,8 +1456,8 @@ class Grouped_conv_noOptim(unittest.TestCase):
self.corr_fwd = conv2d_corr self.corr_fwd = conv2d_corr
self.corr_gradw = conv2d_corr_gw self.corr_gradw = conv2d_corr_gw
self.corr_gradi = conv2d_corr_gi self.corr_gradi = conv2d_corr_gi
if theano.config.cxx == "": if theano.config.cxx == "" or not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("CorrMM needs cxx") raise SkipTest("CorrMM needs cxx and SciPy")
def test_fwd(self): def test_fwd(self):
if self.convdim == 2: if self.convdim == 2:
...@@ -1621,7 +1623,7 @@ class Grouped_conv3d_noOptim(Grouped_conv_noOptim): ...@@ -1621,7 +1623,7 @@ class Grouped_conv3d_noOptim(Grouped_conv_noOptim):
self.corr_fwd = conv3d_corr self.corr_fwd = conv3d_corr
self.corr_gradw = conv3d_corr_gw self.corr_gradw = conv3d_corr_gw
self.corr_gradi = conv3d_corr_gi self.corr_gradi = conv3d_corr_gi
if theano.config.cxx == "": if theano.config.cxx == "" or not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("CorrMM needs cxx") raise SkipTest("CorrMM needs cxx")
...@@ -1770,8 +1772,8 @@ class TestUnsharedConv(unittest.TestCase): ...@@ -1770,8 +1772,8 @@ class TestUnsharedConv(unittest.TestCase):
self.verify_flags = [True] * 4 self.verify_flags = [True] * 4
self.ref_mode = 'FAST_RUN' self.ref_mode = 'FAST_RUN'
if theano.config.cxx == "": if theano.config.cxx == "" or not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("CorrMM needs cxx") raise SkipTest("CorrMM needs cxx or SciPy")
def test_fwd(self): def test_fwd(self):
tensor6 = theano.tensor.TensorType(theano.config.floatX, (False,) * 6) tensor6 = theano.tensor.TensorType(theano.config.floatX, (False,) * 6)
...@@ -1913,6 +1915,8 @@ class TestAsymmetricPadding(unittest.TestCase): ...@@ -1913,6 +1915,8 @@ class TestAsymmetricPadding(unittest.TestCase):
border_mode = [((1, 2), (2, 1)), ((1, 1), (0, 3)), ((2, 1), (0, 0))] border_mode = [((1, 2), (2, 1)), ((1, 1), (0, 3)), ((2, 1), (0, 0))]
def test_fwd(self): def test_fwd(self):
if not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("SciPy needed")
img_sym = theano.tensor.tensor4('img') img_sym = theano.tensor.tensor4('img')
kern_sym = theano.tensor.tensor4('kern') kern_sym = theano.tensor.tensor4('kern')
...@@ -1947,6 +1951,9 @@ class TestAsymmetricPadding(unittest.TestCase): ...@@ -1947,6 +1951,9 @@ class TestAsymmetricPadding(unittest.TestCase):
utt.verify_grad(asymmetric_conv_op, [img, kern], mode=self.mode, eps=1) utt.verify_grad(asymmetric_conv_op, [img, kern], mode=self.mode, eps=1)
def test_gradweight(self): def test_gradweight(self):
if not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("SciPy needed")
img_sym = theano.tensor.tensor4('img') img_sym = theano.tensor.tensor4('img')
top_sym = theano.tensor.tensor4('top') top_sym = theano.tensor.tensor4('top')
...@@ -2035,7 +2042,8 @@ class TestCausalConv(unittest.TestCase): ...@@ -2035,7 +2042,8 @@ class TestCausalConv(unittest.TestCase):
def test_interface(self): def test_interface(self):
img_sym = theano.tensor.tensor3('img') img_sym = theano.tensor.tensor3('img')
kern_sym = theano.tensor.tensor3('kern') kern_sym = theano.tensor.tensor3('kern')
if not theano.tensor.nnet.abstract_conv.imported_scipy_signal:
raise SkipTest("SciPy needed")
sym_out = causal_conv1d(img_sym, kern_sym, self.kern.shape, filter_dilation=self.dilation) sym_out = causal_conv1d(img_sym, kern_sym, self.kern.shape, filter_dilation=self.dilation)
causal_func = theano.function([img_sym, kern_sym], sym_out, mode=self.mode) causal_func = theano.function([img_sym, kern_sym], sym_out, mode=self.mode)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论