提交 e699c27d authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3108 from nouiz/tests

[TEST, CRASH] Fix tests in float32 and a new opt crash.
......@@ -499,8 +499,13 @@ class FromFunctionOp(gof.Op):
return 'FromFunctionOp{%s}' % self.__fn.__name__
def make_node(self, *inputs):
assert len(inputs) == len(self.itypes)
assert all(inp.type == it for inp, it in zip(inputs, self.itypes))
if len(inputs) != len(self.itypes):
raise ValueError("We expected %d inputs but got %d." %
(len(self.itypes), len(inputs)))
if not all(inp.type == it for inp, it in zip(inputs, self.itypes)):
raise TypeError(
"We expected inputs of types '%s' but got types '%s' " %
(str([inp.type for inp in inputs]), str(self.itypes)))
return theano.Apply(self, inputs, [o() for o in self.otypes])
def perform(self, node, inputs, outputs):
......
......@@ -4257,7 +4257,7 @@ class T_Scan(unittest.TestCase):
f = theano.function(inputs=[A, k],
outputs=final_result,
updates=updates)
f([2, 3, .1, 0, 1], 4)
f(numpy.asarray([2, 3, .1, 0, 1], dtype=theano.config.floatX), 4)
# There should be 3 outputs greater than 10: prior_result[0] at step 3,
# and prior_result[1] at steps 2 and 3.
......
......@@ -4393,7 +4393,7 @@ def local_intdiv_by_one(node):
if node.op in [T.int_div]:
if isinstance(node.inputs[1], T.TensorConstant) and \
numpy.all(node.inputs[1].value == 1):
return [node.inputs[0]]
return [node.inputs[0].astype(node.outputs[0].dtype)]
@gof.local_optimizer([T.pow])
......
......@@ -254,7 +254,7 @@ def test_debugprint():
def test_scan_debugprint1():
k = tensor.iscalar("k")
A = tensor.vector("A")
A = tensor.dvector("A")
# Symbolic description of the result
result, updates = theano.scan(fn=lambda prior_result, A: prior_result * A,
......@@ -375,11 +375,11 @@ def test_scan_debugprint2():
def test_scan_debugprint3():
coefficients = theano.tensor.vector("coefficients")
coefficients = theano.tensor.dvector("coefficients")
max_coefficients_supported = 10
k = tensor.iscalar("k")
A = tensor.vector("A")
A = tensor.dvector("A")
# compute A**k
def compute_A_k(A, k):
......@@ -569,7 +569,7 @@ def test_scan_debugprint4():
def test_scan_debugprint5():
k = tensor.iscalar("k")
A = tensor.vector("A")
A = tensor.dvector("A")
# Symbolic description of the result
result, updates = theano.scan(fn=lambda prior_result, A: prior_result * A,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论