提交 5ac06c76 authored 作者: Frederic's avatar Frederic

skip make test pass when no c++ compiler under theano/{tensor,sparse}

上级 1ac53176
...@@ -1012,7 +1012,7 @@ class test_structureddot(unittest.TestCase): ...@@ -1012,7 +1012,7 @@ class test_structureddot(unittest.TestCase):
overhead_tol = 0.002 # seconds overhead_tol = 0.002 # seconds
overhead_rtol = 1.1 # times as long overhead_rtol = 1.1 # times as long
self.assertTrue(numpy.allclose(theano_result, scipy_result)) self.assertTrue(numpy.allclose(theano_result, scipy_result))
if not theano.config.mode in ["DebugMode", "DEBUG_MODE"]: if not theano.config.mode in ["DebugMode", "DEBUG_MODE"] and theano.config.cxx:
self.assertFalse(theano_time > overhead_rtol * scipy_time + self.assertFalse(theano_time > overhead_rtol * scipy_time +
overhead_tol) overhead_tol)
...@@ -1198,7 +1198,8 @@ class UsmmTests(unittest.TestCase): ...@@ -1198,7 +1198,8 @@ class UsmmTests(unittest.TestCase):
fast_compile = theano.config.mode == "FAST_COMPILE" fast_compile = theano.config.mode == "FAST_COMPILE"
if (y.type.dtype == up and format1 == 'csc' and format2 == 'dense' if (y.type.dtype == up and format1 == 'csc' and format2 == 'dense'
and not fast_compile) and up in ('float32', 'float64'): and not fast_compile and theano.config.cxx and
up in ('float32', 'float64')):
# The op UsmmCscDense should be inserted # The op UsmmCscDense should be inserted
assert (sum([isinstance(node.op, tensor.Elemwise) and assert (sum([isinstance(node.op, tensor.Elemwise) and
isinstance(node.op.scalar_op, isinstance(node.op.scalar_op,
......
...@@ -37,6 +37,8 @@ def test_local_csm_properties_csm(): ...@@ -37,6 +37,8 @@ def test_local_csm_properties_csm():
def test_local_csm_grad_c(): def test_local_csm_grad_c():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
data = tensor.vector() data = tensor.vector()
indices, indptr, shape = (tensor.ivector(), tensor.ivector(), indices, indptr, shape = (tensor.ivector(), tensor.ivector(),
tensor.ivector()) tensor.ivector())
...@@ -60,6 +62,8 @@ def test_local_csm_grad_c(): ...@@ -60,6 +62,8 @@ def test_local_csm_grad_c():
def test_local_mul_s_d(): def test_local_mul_s_d():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
mode = theano.compile.mode.get_default_mode() mode = theano.compile.mode.get_default_mode()
mode = mode.including("specialize", "local_mul_s_d") mode = mode.including("specialize", "local_mul_s_d")
...@@ -76,6 +80,8 @@ def test_local_mul_s_d(): ...@@ -76,6 +80,8 @@ def test_local_mul_s_d():
def test_local_mul_s_v(): def test_local_mul_s_v():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
mode = theano.compile.mode.get_default_mode() mode = theano.compile.mode.get_default_mode()
mode = mode.including("specialize", "local_mul_s_v") mode = mode.including("specialize", "local_mul_s_v")
...@@ -92,6 +98,8 @@ def test_local_mul_s_v(): ...@@ -92,6 +98,8 @@ def test_local_mul_s_v():
def test_local_structured_add_s_v(): def test_local_structured_add_s_v():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
mode = theano.compile.mode.get_default_mode() mode = theano.compile.mode.get_default_mode()
mode = mode.including("specialize", "local_structured_add_s_v") mode = mode.including("specialize", "local_structured_add_s_v")
...@@ -108,6 +116,8 @@ def test_local_structured_add_s_v(): ...@@ -108,6 +116,8 @@ def test_local_structured_add_s_v():
def test_local_sampling_dot_csr(): def test_local_sampling_dot_csr():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
mode = theano.compile.mode.get_default_mode() mode = theano.compile.mode.get_default_mode()
mode = mode.including("specialize", "local_sampling_dot_csr") mode = mode.including("specialize", "local_sampling_dot_csr")
......
...@@ -4203,9 +4203,13 @@ class t_dot(unittest.TestCase): ...@@ -4203,9 +4203,13 @@ class t_dot(unittest.TestCase):
e[0].split()[1:4] == ['are', 'not', 'aligned'] or e[0].split()[1:4] == ['are', 'not', 'aligned'] or
# Reported by blas or Theano. # Reported by blas or Theano.
e[0].split()[0:2] == ['Shape', 'mismatch:'] or e[0].split()[0:2] == ['Shape', 'mismatch:'] or
# Reported by Theano perform
e[0].split()[0:4] == ['Incompatible', 'shapes', 'for', 'gemv'] or
# Reported by Theano when 'exception_verbosity' is set # Reported by Theano when 'exception_verbosity' is set
# to 'high'. # to 'high'.
e[0].split()[0:3] == ['dot', 'product', 'failed.'], e[0].split()[0:3] == ['dot', 'product', 'failed.']
,
e) e)
finally: finally:
_logger.setLevel(oldlevel) _logger.setLevel(oldlevel)
...@@ -5912,8 +5916,9 @@ def test_unalign(): ...@@ -5912,8 +5916,9 @@ def test_unalign():
f.maker.fgraph.toposort() f.maker.fgraph.toposort()
# FAST_COMPILE use the python code that support unaligned data # FAST_COMPILE use the python code that support unaligned data
# The DebugMode make a copy of the inputs, so they will be aligned. # The DebugMode make a copy of the inputs, so they will be aligned.
should_raise = theano.config.mode not in ["FAST_COMPILE", "DebugMode", should_raise = (theano.config.mode not in ["FAST_COMPILE", "DebugMode",
"DEBUG_MODE"] "DEBUG_MODE"] and
theano.config.linker != 'py')
try: try:
out_theano = f(a, b) out_theano = f(a, b)
assert not a.flags.aligned assert not a.flags.aligned
......
...@@ -101,7 +101,8 @@ class t_gemm(TestCase): ...@@ -101,7 +101,8 @@ class t_gemm(TestCase):
cmp_linker(copy(z), a, x, y, b, 'c|py') cmp_linker(copy(z), a, x, y, b, 'c|py')
cmp_linker(copy(z), a, x, y, b, 'py') cmp_linker(copy(z), a, x, y, b, 'py')
if config.blas.ldflags and not dtype.startswith("complex"): if (config.blas.ldflags and not dtype.startswith("complex")
and theano.config.cxx):
# If blas.ldflags is equal to '', the C code will not # If blas.ldflags is equal to '', the C code will not
# be generated # be generated
cmp_linker(copy(z), a, x, y, b, 'c') cmp_linker(copy(z), a, x, y, b, 'c')
......
...@@ -5,6 +5,7 @@ import time ...@@ -5,6 +5,7 @@ import time
import unittest import unittest
import numpy import numpy
from nose.plugins.skip import SkipTest
from numpy.testing import dec from numpy.testing import dec
import theano import theano
...@@ -166,15 +167,21 @@ class test_Broadcast(unittest.TestCase): ...@@ -166,15 +167,21 @@ class test_Broadcast(unittest.TestCase):
self.with_linker(gof.PerformLinker()) self.with_linker(gof.PerformLinker())
def test_c(self): def test_c(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
self.with_linker(gof.CLinker()) self.with_linker(gof.CLinker())
def test_perform_inplace(self): def test_perform_inplace(self):
self.with_linker_inplace(gof.PerformLinker()) self.with_linker_inplace(gof.PerformLinker())
def test_c_inplace(self): def test_c_inplace(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
self.with_linker_inplace(gof.CLinker()) self.with_linker_inplace(gof.CLinker())
def test_fill(self): def test_fill(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x = TensorType('float64', [0, 0])('x') x = TensorType('float64', [0, 0])('x')
y = TensorType('float64', [1, 1])('y') y = TensorType('float64', [1, 1])('y')
e = Elemwise(scalar.Second(scalar.transfer_type(0)), {0: 0})(x, y) e = Elemwise(scalar.Second(scalar.transfer_type(0)), {0: 0})(x, y)
...@@ -185,6 +192,8 @@ class test_Broadcast(unittest.TestCase): ...@@ -185,6 +192,8 @@ class test_Broadcast(unittest.TestCase):
assert (xv == yv).all() assert (xv == yv).all()
def test_weird_strides(self): def test_weird_strides(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x = TensorType('float64', [0, 0, 0, 0, 0])('x') x = TensorType('float64', [0, 0, 0, 0, 0])('x')
y = TensorType('float64', [0, 0, 0, 0, 0])('y') y = TensorType('float64', [0, 0, 0, 0, 0])('y')
e = Elemwise(scalar.add)(x, y) e = Elemwise(scalar.add)(x, y)
...@@ -195,6 +204,8 @@ class test_Broadcast(unittest.TestCase): ...@@ -195,6 +204,8 @@ class test_Broadcast(unittest.TestCase):
assert (f(xv, yv) == zv).all() assert (f(xv, yv) == zv).all()
def test_same_inputs(self): def test_same_inputs(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x = TensorType('float64', [0, 0])('x') x = TensorType('float64', [0, 0])('x')
e = Elemwise(scalar.add)(x, x) e = Elemwise(scalar.add)(x, x)
f = gof.CLinker().accept(FunctionGraph([x], [e])).make_function() f = gof.CLinker().accept(FunctionGraph([x], [e])).make_function()
...@@ -374,6 +385,9 @@ class test_CAReduce(unittest_tools.InferShapeTester): ...@@ -374,6 +385,9 @@ class test_CAReduce(unittest_tools.InferShapeTester):
test_nan=True, tensor_op=tensor.all) test_nan=True, tensor_op=tensor.all)
def test_c(self): def test_c(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
for dtype in ["floatX", "complex64", "complex128", "int8", "uint8"]: for dtype in ["floatX", "complex64", "complex128", "int8", "uint8"]:
self.with_linker(gof.CLinker(), scalar.add, dtype=dtype) self.with_linker(gof.CLinker(), scalar.add, dtype=dtype)
self.with_linker(gof.CLinker(), scalar.mul, dtype=dtype) self.with_linker(gof.CLinker(), scalar.mul, dtype=dtype)
...@@ -390,6 +404,8 @@ class test_CAReduce(unittest_tools.InferShapeTester): ...@@ -390,6 +404,8 @@ class test_CAReduce(unittest_tools.InferShapeTester):
self.with_linker(gof.CLinker(), scalar.xor, dtype=dtype) self.with_linker(gof.CLinker(), scalar.xor, dtype=dtype)
def test_c_nan(self): def test_c_nan(self):
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
for dtype in ["floatX", "complex64", "complex128"]: for dtype in ["floatX", "complex64", "complex128"]:
self.with_linker(gof.CLinker(), scalar.add, dtype=dtype, self.with_linker(gof.CLinker(), scalar.add, dtype=dtype,
test_nan=True) test_nan=True)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论