<s> """<STR_LIT>""" <EOL> import unittest <EOL> import numpy <EOL> import theano <EOL> from six . moves import StringIO <EOL> import theano . tensor as T <EOL> from theano . ifelse import ifelse <EOL> class Test_profiling ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_profiling ( self ) : <EOL> config1 = theano . config . profile <EOL> config2 = theano . config . profile_memory <EOL> config3 = theano . config . profiling . min_peak_memory <EOL> try : <EOL> theano . config . profile = True <EOL> theano . config . profile_memory = True <EOL> theano . config . profiling . min_peak_memory = True <EOL> x = [ T . fvector ( "<STR_LIT>" % i ) for i in range ( <NUM_LIT:3> ) ] <EOL> z = [ ] <EOL> z += [ T . outer ( x [ i ] , x [ i + <NUM_LIT:1> ] ) . sum ( axis = <NUM_LIT:1> ) for i in range ( len ( x ) - <NUM_LIT:1> ) ] <EOL> z += [ x [ i ] + x [ i + <NUM_LIT:1> ] for i in range ( len ( x ) - <NUM_LIT:1> ) ] <EOL> p = theano . ProfileStats ( False ) <EOL> if theano . config . mode in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> m = "<STR_LIT>" <EOL> else : <EOL> m = None <EOL> f = theano . function ( x , z , profile = p , name = "<STR_LIT>" , <EOL> mode = m ) <EOL> inp = [ numpy . arange ( <NUM_LIT> , dtype = '<STR_LIT>' ) + <NUM_LIT:1> for i in range ( len ( x ) ) ] <EOL> output = f ( * inp ) <EOL> buf = StringIO ( ) <EOL> f . profile . summary ( buf ) <EOL> the_string = buf . getvalue ( ) <EOL> lines1 = [ l for l in the_string . split ( "<STR_LIT:\n>" ) if "<STR_LIT>" in l ] <EOL> lines2 = [ l for l in the_string . split ( "<STR_LIT:\n>" ) if "<STR_LIT>" in l ] <EOL> if theano . config . device == '<STR_LIT>' : <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( <EOL> lines1 , lines2 ) <EOL> else : <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( lines1 , lines2 ) <EOL> assert "<STR_LIT>" in the_string , ( <EOL> lines1 , lines2 ) <EOL> finally : <EOL> theano . config . profile = config1 <EOL> theano . config . profile_memory = config2 <EOL> theano . config . profiling . min_peak_memory = config3 <EOL> def test_ifelse ( self ) : <EOL> config1 = theano . config . profile <EOL> config2 = theano . config . profile_memory <EOL> try : <EOL> theano . config . profile = True <EOL> theano . config . profile_memory = True <EOL> a , b = T . scalars ( '<STR_LIT:a>' , '<STR_LIT:b>' ) <EOL> x , y = T . scalars ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> z = ifelse ( T . lt ( a , b ) , x * <NUM_LIT:2> , y * <NUM_LIT:2> ) <EOL> p = theano . ProfileStats ( False ) <EOL> if theano . config . mode in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> m = "<STR_LIT>" <EOL> else : <EOL> m = None <EOL> f_ifelse = theano . function ( [ a , b , x , y ] , z , profile = p , name = "<STR_LIT>" , <EOL> mode = m ) <EOL> val1 = <NUM_LIT:0.> <EOL> val2 = <NUM_LIT:1.> <EOL> big_mat1 = <NUM_LIT:10> <EOL> big_mat2 = <NUM_LIT:11> <EOL> out = f_ifelse ( val1 , val2 , big_mat1 , big_mat2 ) <EOL> finally : <EOL> theano . config . profile = config1 <EOL> theano . config . profile_memory = config2 <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
