def test_borrow_output(self):
a = T.dmatrix()
f = function([a], Out(a, borrow=False))
o = N.ones((3, 3))
assert o is not f(o) # function no longer permits aliasing outputs to inputs
f = function([a], Out(a * 4, borrow=False))
o = N.ones((3, 3))
four = f(o)
assert numpy.all(four == 4)
f(o + .1) # should not clobber the memory used to store four
assert numpy.all(four == 4)
f = function([a], Out(a * 4, borrow=True), mode=theano.Mode('c|py_nogc', 'fast_run'))
o = N.ones((3, 3))
four = f(o)
assert numpy.all(four == 4)
f(o + .1) # should clobber the memory used to store four
if theano.config.cxx:
assert not numpy.all(four == 4)
else:
# The Elemwise.perform method don't reuse memory
# as some numpy version don't support that correctly.
assert numpy.all(four == 4)
test_function_module.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录