def test_constant_folding():
 x = tensor.dvector()
 mode = theano.compile.get_mode('FAST_COMPILE').excluding('fusion')
 f = theano.function([x], [(x * 2), (x + x)], mode=mode)
 topo = f.maker.fgraph.toposort()
 assert (len(topo) == 2)
 x = tensor.constant(3)
 assert (x.ndim == 0)
 mode = theano.compile.get_mode('FAST_COMPILE').excluding('fusion')
 f = theano.function([], [(x * 2), (x + x)], mode=mode)
 topo = f.maker.fgraph.toposort()
 assert (len(topo) == 2)
 assert all([isinstance(n.op, DeepCopyOp) for n in topo])

def test_constant_folding ( ) : x = tensor . dvector ( ) mode = theano . compile . get_mode ( 'FAST_COMPILE' ) . excluding ( 'fusion' ) f = theano . function ( [ x ] , [ ( x * 2 ) , ( x + x ) ] , mode = mode ) topo = f . maker . fgraph . toposort ( ) assert ( len ( topo ) == 2 ) x = tensor . constant ( 3 ) assert ( x . ndim == 0 ) mode = theano . compile . get_mode ( 'FAST_COMPILE' ) . excluding ( 'fusion' ) f = theano . function ( [ ] , [ ( x * 2 ) , ( x + x ) ] , mode = mode ) topo = f . maker . fgraph . toposort ( ) assert ( len ( topo ) == 2 ) assert all ( [ isinstance ( n . op , DeepCopyOp ) for n in topo ] )
test that constant folding get registered at fast_compile an error removed that registration during the registration .