提交 7d3c6d15 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: Reyhane Askari

Fix tests that was dependent of the exact toposort order.

上级 bb41c388
...@@ -25,9 +25,9 @@ Currently, information regarding shape is used in two ways in Theano: ...@@ -25,9 +25,9 @@ Currently, information regarding shape is used in two ways in Theano:
>>> f = theano.function([x], (x ** 2).shape) >>> f = theano.function([x], (x ** 2).shape)
>>> theano.printing.debugprint(f) # doctest: +NORMALIZE_WHITESPACE >>> theano.printing.debugprint(f) # doctest: +NORMALIZE_WHITESPACE
MakeVector{dtype='int64'} [id A] '' 2 MakeVector{dtype='int64'} [id A] '' 2
|Shape_i{0} [id B] '' 1 |Shape_i{0} [id B] '' 0
| |x [id C] | |x [id C]
|Shape_i{1} [id D] '' 0 |Shape_i{1} [id D] '' 1
|x [id C] |x [id C]
......
...@@ -153,7 +153,7 @@ class TestWrapLinker(unittest.TestCase): ...@@ -153,7 +153,7 @@ class TestWrapLinker(unittest.TestCase):
i[0].data = 1 i[0].data = 1
i[1].data = 2 i[1].data = 2
fn() fn()
assert nodes == [div, add, mul] assert nodes == [div, add, mul] or nodes == [add, div, mul]
assert o[0].data is None assert o[0].data is None
def test_1(self): def test_1(self):
...@@ -171,7 +171,7 @@ class TestWrapLinker(unittest.TestCase): ...@@ -171,7 +171,7 @@ class TestWrapLinker(unittest.TestCase):
i[0].data = 1 i[0].data = 1
i[1].data = 2 i[1].data = 2
fn() fn()
assert nodes == [div, add, mul] assert nodes == [div, add, mul] or nodes == [add, div, mul]
assert o[0].data == 1.5 assert o[0].data == 1.5
......
...@@ -1568,14 +1568,19 @@ def test_log1p(): ...@@ -1568,14 +1568,19 @@ def test_log1p():
y = fmatrix() y = fmatrix()
f = function([x, y], T.log(tensor.fill(y, 1) + (x)), mode=m) f = function([x, y], T.log(tensor.fill(y, 1) + (x)), mode=m)
# the first three ops are Shape_i, Shape_i, and Dimshuffle # the first three ops are Shape_i, Shape_i, and Dimshuffle
assert [node.op for node in f.maker.fgraph.toposort()][3:] == [ topo = f.maker.fgraph.toposort()
T.log1p, tensor.alloc] assert topo[-1].op == tensor.alloc
assert T.log1p in [node.op for node in topo]
f = function([x, y], T.log(0 + (x) + tensor.fill(y, 1.0)), mode=m) f = function([x, y], T.log(0 + (x) + tensor.fill(y, 1.0)), mode=m)
assert [node.op for node in f.maker.fgraph.toposort()][3:] == [ topo = f.maker.fgraph.toposort()
T.log1p, tensor.alloc] assert topo[-1].op == tensor.alloc
assert T.log1p in [node.op for node in topo]
f = function([x, y], T.log(2 + (x) - tensor.fill(y, 1.0)), mode=m) f = function([x, y], T.log(2 + (x) - tensor.fill(y, 1.0)), mode=m)
assert ([node.op for node in f.maker.fgraph.toposort()][3:] == topo = f.maker.fgraph.toposort()
[T.log1p, tensor.alloc]) assert topo[-1].op == tensor.alloc
assert T.log1p in [node.op for node in topo]
f([1e-7, 10], [[0, 0], [0, 0]]) # debugmode will verify values f([1e-7, 10], [[0, 0], [0, 0]]) # debugmode will verify values
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论