def test_elemwise0():
a = tcn.shared_constructor(theano._asarray(numpy.random.rand(4, 4),
dtype='float32'), 'a')
b = tensor.fmatrix()
f = pfunc([b], [], updates=[(a, a + b)], mode=mode_with_gpu)
# check that we work inplace.
assert (list(
f.maker.fgraph.toposort()[1].op.destroy_map.items()) == [
(0, [0])])
a0 = a.get_value() * 1.0
f(numpy.ones((4, 4), dtype='float32'))
assert numpy.all(a0 + 1.0 == a.get_value())
评论列表
文章目录