#NEWLINE# def test_adv_sub1_fast( self ) : #NEWLINE# #INDENT# 'We check that the special cases of advanced indexing that\n        use CudaNdarrayTakeFrom are handled correctly\n\n        ' #NEWLINE# rand = numpy . random . rand #NEWLINE# for ( shape , idx , fast ) in [ ( ( 70000 , ) , range ( 70000 ) , True ) , ( ( 70000 , 5 ) , range ( 70000 ) , True ) , ( ( 70000 , 5 ) , numpy . zeros ( ( 0 , ) , 'int64' ) , True ) , ( ( 70000 , 2 , 3 ) , range ( 70000 ) , True ) , ( ( 1025 , 1025 ) , [ 5 , 10 ] , True ) , ( ( 3 , 1025 , 1026 ) , [ 1 , 2 ] , True ) , ( ( 1025 , 67000 ) , [ 5 , 10 ] , True ) , ( ( 3 , 10 , 68000 ) , [ 1 , 2 ] , True ) , ( ( 3 , 69000 , 11 ) , [ 1 , 2 ] , True ) , ( ( ( 2 * 100000000.0 ) , ) , [ ( - 1 ) , 199999999 ] , True ) , ( ( 4 , 5 ) , [ 2 , 3 ] , True ) , ( ( 4 , 2 , 3 ) , [ 0 , 3 ] , True ) , ( ( 4 , 2 , 3 ) , [ 3 , 3 , 1 , 1 , 2 , 2 , 0 , 0 ] , True ) , ( ( 4 , 2 , 3 ) , [ 3 , 3 , 1 , 1 , 2 , 2 , 0 , 0 , ( - 1 ) , ( - 2 ) , ( - 3 ) , ( - 4 ) ] , True ) , ( ( 4 , 4 , 2 , 3 ) , [ 3 , 3 , 1 , 1 , 2 , 2 , 0 , 0 , ( - 1 ) , ( - 2 ) , ( - 3 ) , ( - 4 ) ] , False ) , ( ( 1 , 10 ) , [ 0 , 0 ] , True ) ] : #NEWLINE# #INDENT# size_needed = ( numpy . prod ( shape ) * ( 4 + 1 ) ) #NEWLINE# if isinstance ( theano . compile . get_default_mode ( ) , theano . compile . DebugMode ) : #NEWLINE# #INDENT# size_needed = ( ( numpy . prod ( shape ) * 4 ) * 4 ) #NEWLINE# #UNINDENT# if ( size_needed >= theano . sandbox . cuda . mem_info ( ) [ 0 ] ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# data = rand ( * shape ) #NEWLINE# data = numpy . asarray ( data , dtype = self . dtype ) #NEWLINE# n = self . shared ( data , borrow = True ) #NEWLINE# t = self . adv_sub1 ( ) ( n , idx ) #NEWLINE# t . owner . op . perform_using_take = True #NEWLINE# val = self . eval_output_and_check ( t , list = True ) #NEWLINE# val = numpy . asarray ( val ) #NEWLINE# good = data [ idx ] #NEWLINE# self . assertTrue ( ( val . ndim == data . ndim ) ) #NEWLINE# utt . assert_allclose ( val , good ) #NEWLINE# t = self . adv_sub1 ( ) ( n [ : : ( - 1 ) ] , idx ) #NEWLINE# if ( not isinstance ( theano . compile . get_default_mode ( ) , theano . compile . DebugMode ) ) : #NEWLINE# #INDENT# t . owner . op . perform_using_take = fast #NEWLINE# #UNINDENT# val = theano . function ( [ ] , t , mode = self . mode ) ( ) #NEWLINE# val = numpy . asarray ( val ) #NEWLINE# good = data [ : : ( - 1 ) ] [ idx ] #NEWLINE# self . assertTrue ( ( val . ndim == data . ndim ) ) #NEWLINE# utt . assert_allclose ( val , good )