提交 88648d8d authored 作者: Pascal Lamblin's avatar Pascal Lamblin 提交者: GitHub

Merge pull request #5300 from nouiz/cxx

Fix tests when no compiler.
from __future__ import absolute_import, print_function, division
from nose.plugins.skip import SkipTest
import theano
from theano.compile.mode import Mode, AddFeatureOptimizer
from theano.gof.toolbox import NoOutputFromInplace
......@@ -18,6 +21,8 @@ def test_no_output_from_implace():
op = fct_no_opt.maker.fgraph.outputs[0].owner.op
assert (hasattr(op, 'destroy_map') and 0 in op.destroy_map)
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
# Ensure that the elemwise op that produces the output is not inplace when
# using a mode that includes the optimization
opt = AddFeatureOptimizer(NoOutputFromInplace())
......
......@@ -390,6 +390,9 @@ def test_shared_input_output():
# Test bug reported on the mailing list by Alberto Orlandi
# https://groups.google.com/d/topic/theano-users/6dLaEqc2R6g/discussion
# The shared variable is both an input and an output of the function.
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
inc = theano.tensor.iscalar('inc')
state = theano.shared(0)
state.name = 'state'
......
......@@ -331,7 +331,7 @@ class TestComputeTestValue(unittest.TestCase):
assert (str(e).startswith("shape mismatch") or
str(e).startswith("operands could not be broadcast "
"together with shapes") or
str(e).startswith("could not broadcast input"))
str(e).startswith("could not broadcast input")), str(e)
finally:
theano.config.compute_test_value = orig_compute_test_value
......
......@@ -3,6 +3,8 @@ import os
import pickle
import unittest
from nose.plugins.skip import SkipTest
import theano
from theano.compat import PY3
from theano.gof import CachedConstantError, FunctionGraph
......@@ -32,6 +34,8 @@ class TFunctionGraph(unittest.TestCase):
# In the past, we where removing some not used variable from
# fgraph.variables event if the apply had other output used in
# the graph. This caused a crash.
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
# This test run the pickle that reproduce this case.
with open(os.path.join(os.path.dirname(__file__),
......
......@@ -209,6 +209,8 @@ def test_partial_function():
utt.assert_allclose(f(5), np.array([32., 16., 1.7857142857142858]))
check_partial_function(vm.VM_Linker(allow_partial_eval=True, use_cloop=False))
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
check_partial_function('cvm')
......@@ -223,6 +225,8 @@ def test_partial_function_with_output_keys():
assert f(5, output_subset=['a'])['a'] == f(5)['a']
check_partial_function_output_keys(vm.VM_Linker(allow_partial_eval=True, use_cloop=False))
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
check_partial_function_output_keys('cvm')
......@@ -243,6 +247,8 @@ def test_partial_function_with_updates():
assert y.get_value() == 10
check_updates(vm.VM_Linker(allow_partial_eval=True, use_cloop=False))
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
check_updates('cvm')
......
from __future__ import absolute_import, print_function, division
import theano
from theano.scalar.basic_sympy import SymPyCCode
from theano.scalar.basic import floats
import theano
from nose.plugins.skip import SkipTest
try:
import sympy
xs = sympy.Symbol('x')
ys = sympy.Symbol('y')
except ImportError:
from nose.plugins.skip import SkipTest
raise SkipTest('optional package sympy disabled')
xt, yt = floats('xy')
def test_SymPyCCode():
if not theano.config.cxx:
raise SkipTest("Need cxx for this test")
op = SymPyCCode([xs, ys], xs + ys)
e = op(xt, yt)
g = theano.gof.FunctionGraph([xt, yt], [e])
......
......@@ -1436,6 +1436,11 @@ class Scan(PureOp):
outs[j][0][pos[j]] = \
output_storage[offset_out + j].storage[0]
except ValueError as e:
if i == 0:
# First iteration, so don't change the
# error message as it can't be the
# case we write about.
raise
ne = ValueError(
"An output of the scan has changed shape. "
"This may be caused by a pushout optimization."
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论