提交 e6022580 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Added test for borrowed output bug

上级 9be3ec1a
...@@ -13,3 +13,21 @@ def test_bug_2009_06_02_trac_387(): ...@@ -13,3 +13,21 @@ def test_bug_2009_06_02_trac_387():
#z = tensor.lscalar('z') #z = tensor.lscalar('z')
#f = theano.function([z], tensor.DimShuffle([], ['x'])(z) / 2) #f = theano.function([z], tensor.DimShuffle([], ['x'])(z) / 2)
def test_bug_2009_07_17_borrowed_output():
"""Regression test for a bug where output was borrowed by mistake."""
a = theano.tensor.dmatrix()
b = theano.tensor.dmatrix()
# The output should *NOT* be borrowed.
g = theano.function([a, b],
theano.Out(theano.tensor.dot(a, b), borrow=False))
x = numpy.zeros((1, 2))
y = numpy.ones((2, 5))
z = g(x, y)
print z # Should be zero.
x.fill(1)
print g(x, y) # Should be non-zero.
print z # Should still be zero.
assert numpy.linalg.norm(z) == 0
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论