<s> """<STR_LIT>""" <EOL> def nvcc_kernel ( name , params , body ) : <EOL> """<STR_LIT>""" <EOL> paramstr = '<STR_LIT:U+002CU+0020>' . join ( params ) <EOL> def flatbody ( ) : <EOL> for b in body : <EOL> if isinstance ( b , ( list , tuple ) ) : <EOL> for bb in b : <EOL> yield bb <EOL> else : <EOL> yield b <EOL> bodystr = '<STR_LIT>' . join ( flatbody ( ) ) <EOL> return """<STR_LIT>""" % locals ( ) <EOL> def code_version ( version ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( version , tuple ) : <EOL> raise TypeError ( '<STR_LIT>' , version ) <EOL> def deco ( f ) : <EOL> f . code_version = version <EOL> return f <EOL> return deco <EOL> UNVERSIONED = ( ) <EOL> @ code_version ( ( <NUM_LIT:1> , ) ) <EOL> def inline_reduce ( N , buf , pos , count , manner_fn ) : <EOL> """<STR_LIT>""" <EOL> loop_line = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf ) ) <EOL> r_16 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_8 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_4 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_2 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_1 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> return """<STR_LIT>""" % locals ( ) <EOL> @ code_version ( inline_reduce . code_version ) <EOL> def inline_reduce_max ( N , buf , pos , count ) : <EOL> return inline_reduce ( N , buf , pos , count , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) ) <EOL> @ code_version ( inline_reduce . code_version ) <EOL> def inline_reduce_sum ( N , buf , pos , count ) : <EOL> return inline_reduce ( N , buf , pos , count , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) ) <EOL> @ code_version ( inline_reduce . code_version ) <EOL> def inline_reduce_min ( N , buf , pos , count ) : <EOL> return inline_reduce ( N , buf , pos , count , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) ) <EOL> @ code_version ( inline_reduce . code_version ) <EOL> def inline_reduce_prod ( N , buf , pos , count ) : <EOL> return inline_reduce ( N , buf , pos , count , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) ) <EOL> @ code_version ( ( <NUM_LIT:2> , ) + inline_reduce_max . code_version + <EOL> inline_reduce_sum . code_version ) <EOL> def inline_softmax ( N , buf , buf2 , threadPos , threadCount ) : <EOL> """<STR_LIT>""" <EOL> return [ <EOL> inline_reduce_max ( N , buf , threadPos , threadCount ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + buf + '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + threadPos + '<STR_LIT>' + N + <EOL> '<STR_LIT>' + threadCount + '<STR_LIT>' , <EOL> buf + '<STR_LIT>' + buf2 + '<STR_LIT>' , <EOL> buf2 + '<STR_LIT>' + buf + '<STR_LIT>' , <EOL> '<STR_LIT:}>' , <EOL> '<STR_LIT>' , <EOL> inline_reduce_sum ( N , buf , threadPos , threadCount ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + buf + '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + threadPos + '<STR_LIT>' + N + <EOL> '<STR_LIT>' + threadCount + '<STR_LIT>' , <EOL> buf + '<STR_LIT>' + buf2 + '<STR_LIT>' , <EOL> '<STR_LIT:}>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> @ code_version ( ( <NUM_LIT:1> , ) ) <EOL> def inline_reduce_fixed_shared ( N , buf , x , stride_x , pos , count , <EOL> manner_fn , manner_init , <EOL> b = '<STR_LIT>' , stride_b = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if b : <EOL> init = manner_init ( "<STR_LIT>" <EOL> "<STR_LIT>" % locals ( ) ) <EOL> loop_line = manner_fn ( "<STR_LIT>" , <EOL> manner_init ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> locals ( ) ) ) <EOL> else : <EOL> init = manner_init ( "<STR_LIT>" % locals ( ) ) <EOL> loop_line = manner_fn ( "<STR_LIT>" , manner_init ( "<STR_LIT>" % <EOL> locals ( ) ) ) <EOL> loop_line2 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , <EOL> "<STR_LIT>" % buf ) <EOL> r_16 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_8 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_4 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_2 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> r_1 = manner_fn ( "<STR_LIT>" % ( buf , pos ) , "<STR_LIT>" % ( buf , pos ) ) <EOL> return """<STR_LIT>""" % locals ( ) <EOL> @ code_version ( inline_reduce_fixed_shared . code_version ) <EOL> def inline_reduce_fixed_shared_max ( N , buf , x , stride_x , pos , count , <EOL> b = '<STR_LIT>' , stride_b = '<STR_LIT>' ) : <EOL> return inline_reduce_fixed_shared ( N , buf , x , stride_x , pos , count , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) , <EOL> lambda a : a , <EOL> b , stride_b ) <EOL> @ code_version ( ( <NUM_LIT:1> , ) + inline_reduce_max . code_version + <EOL> inline_reduce_sum . code_version ) <EOL> def inline_softmax_fixed_shared ( N , buf , x , stride_x , <EOL> sm , sm_stride , <EOL> threadPos , threadCount , <EOL> b = '<STR_LIT>' , stride_b = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> ret = [ <EOL> inline_reduce_fixed_shared_max ( N , buf , x , stride_x , <EOL> threadPos , threadCount , b , stride_b ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + buf + '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> inline_reduce_fixed_shared ( N , buf , x , stride_x , threadPos , threadCount , <EOL> lambda a , b : "<STR_LIT>" % ( a , b ) , <EOL> lambda a : "<STR_LIT>" % a , <EOL> b , stride_b ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + buf + '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> "<STR_LIT>" , <EOL> ] <EOL> if b : <EOL> ret += [ <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % locals ( ) ] <EOL> else : <EOL> ret += [ <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % locals ( ) ] <EOL> ret += [ <EOL> "<STR_LIT:}>" , <EOL> '<STR_LIT>' , <EOL> ] <EOL> return ret </s>
