#NEWLINE# def test_GpuCumsum3D( self ) : #NEWLINE# #INDENT# block_max_size = ( self . max_threads_dim0 * 2 ) #NEWLINE# x = T . ftensor3 ( 'x' ) #NEWLINE# for ( shape_axis , axis ) in zip ( [ 0 , 1 , 2 , 0 , 2 , 1 , 0 ] , [ 0 , 1 , 2 , None , ( - 1 ) , ( - 2 ) , ( - 3 ) ] ) : #NEWLINE# #INDENT# f = theano . function ( [ x ] , cumsum ( x , axis = axis ) , mode = self . mode ) #NEWLINE# assert [ n for n in f . maker . fgraph . toposort ( ) if isinstance ( n . op , GpuCumsum ) ] #NEWLINE# a_shape = [ 5 , 5 , 5 ] #NEWLINE# a_shape [ shape_axis ] = 1025 #NEWLINE# a = np . random . rand ( * a_shape ) . astype ( 'float32' ) #NEWLINE# slices = [ slice ( None ) , slice ( None ) , slice ( None ) ] #NEWLINE# for i in xrange ( a . shape [ shape_axis ] ) : #NEWLINE# #INDENT# slices [ shape_axis ] = slice ( i ) #NEWLINE# fa = f ( a [ slices ] ) #NEWLINE# npa = np . cumsum ( a [ slices ] , axis = axis ) #NEWLINE# utt . assert_allclose ( npa , fa ) #NEWLINE# #UNINDENT# a_shape = [ 2 , 2 , 2 ] #NEWLINE# a_shape [ shape_axis ] = ( block_max_size + 2 ) #NEWLINE# a = np . random . random ( a_shape ) . astype ( 'float32' ) #NEWLINE# utt . assert_allclose ( np . cumsum ( a , axis = axis ) , f ( a ) ) #NEWLINE# a_shape = [ 5 , 5 , 5 ] #NEWLINE# a_shape [ ( ( shape_axis + 1 ) % 3 ) ] = ( self . max_grid_size1 + 1 ) #NEWLINE# a = np . random . random ( a_shape ) . astype ( 'float32' ) #NEWLINE# if ( axis is None ) : #NEWLINE# #INDENT# a = np . sign ( ( a - 0.5 ) ) . astype ( 'float32' ) #NEWLINE# #UNINDENT# utt . assert_allclose ( np . cumsum ( a , axis = axis ) , f ( a ) ) #NEWLINE# a_shape = [ 5 , 5 , 5 ] #NEWLINE# a_shape [ ( ( shape_axis + 2 ) % 3 ) ] = ( self . max_grid_size1 + 1 ) #NEWLINE# a = np . random . random ( a_shape ) . astype ( 'float32' ) #NEWLINE# if ( axis is None ) : #NEWLINE# #INDENT# a = np . sign ( ( a - 0.5 ) ) . astype ( 'float32' ) #NEWLINE# #UNINDENT# utt . assert_allclose ( np . cumsum ( a , axis = axis ) , f ( a ) ) #NEWLINE# a_shape = [ 3 , 3 , 3 ] #NEWLINE# a_shape [ shape_axis ] = ( ( block_max_size * ( block_max_size + 1 ) ) + 2 ) #NEWLINE# a = np . random . random ( a_shape ) . astype ( 'float32' ) #NEWLINE# a = np . sign ( ( a - 0.5 ) ) . astype ( 'float32' ) #NEWLINE# utt . assert_allclose ( np . cumsum ( npa , axis = axis ) , f ( a ) )