def test_eq(self):
x = T.dmatrix()
y = T.dmatrix()
f = theano.function([x, y], T.eq(x, y), mode=self.mode)
vx = numpy.random.rand(5, 4)
vy = numpy.random.rand(5, 4)
f(vx, vy)
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
assert isinstance(topo[0].op, T.Elemwise)
assert isinstance(topo[0].op.scalar_op, theano.scalar.EQ)
f2 = theano.function([x], T.eq(x, x), mode=self.mode)
assert numpy.all(f2(vx) == numpy.ones((5, 4)))
topo2 = f2.maker.fgraph.toposort()
# Shape_i{1}(<TensorType(float64, matrix)>), Shape_i{0}(<TensorType(float64, matrix)>), Alloc([[1]], Shape_i{0}.0, Shape_i{1}.0
assert len(topo2) == 3
assert isinstance(topo2[-1].op, T.Alloc)
评论列表
文章目录