#NEWLINE# def __init__( self , lib , dtype , N , C , K , D , H , W , T , R , S , M , P , Q , pad_d , pad_h , pad_w , str_d , str_h , str_w , relu , bsum ) : #NEWLINE# #INDENT# super ( BpropDirect , self ) . __init__ ( lib , dtype ) #NEWLINE# assert ( ( N % 32 ) == 0 ) , 'N dim must be multiple of 32' #NEWLINE# assert ( ( C % self . vec_size ) == 0 ) , ( 'C dim must be multiple of %d' % self . vec_size ) #NEWLINE# tile_N = ( 128 if ( N > 64 ) else 64 ) #NEWLINE# grid_N = _ceil_div ( N , tile_N ) #NEWLINE# tile_C = ( ( 128 , 64 , 32 ) if ( tile_N == 128 ) else ( 128 , 64 ) ) #NEWLINE# magic_HW = _magic64 ( ( H * W ) ) #NEWLINE# magic_W = _magic64 ( W ) #NEWLINE# magic_RS = _magic32 ( ( ( ( R * S ) * T ) + 32 ) , ( R * S ) ) #NEWLINE# magic_S = _magic32 ( ( ( R * S ) + 32 ) , S ) #NEWLINE# magic_str_w = _magic32 ( ( W + S ) , str_w ) #NEWLINE# magic_str_h = _magic32 ( ( H + R ) , str_h ) #NEWLINE# magic_str_d = _magic32 ( ( D + T ) , str_d ) #NEWLINE# self . xprop_kernels ( 'bprop' , 'C' , tile_N , grid_N , C , tile_C , ( ( D * H ) * W ) , ( ( R * S ) * T ) , _flatten ( [ N , C , M , P , Q , ( Q * N ) , ( ( P * Q ) * N ) , ( ( ( M * P ) * Q ) * N ) , K , ( ( ( C * R ) * S ) * T ) , ( ( R * S ) * T ) , ( R * S ) , magic_RS , S , magic_S , pad_d , pad_h , pad_w , str_d , str_h , str_w , W , ( H * W ) , ( W * N ) , ( ( H * W ) * N ) , ( ( ( D * H ) * W ) * N ) , magic_W , magic_HW , R , T , magic_str_w , magic_str_h , magic_str_d ] ) ) #NEWLINE# self . shared = ( ( ( ( R * S ) * T ) * 4 ) * 2 ) #NEWLINE# self . flags = ( ( relu and 2 ) + ( bsum and 4 ) ) #NEWLINE# shuffle_grid = ( _ceil_div ( K , 32 ) , _ceil_div ( C , 32 ) , ( ( R * S ) * T ) ) #NEWLINE# self . shuffle_size = ( ( ( ( ( C * T ) * R ) * S ) * K ) * dtype . itemsize ) #NEWLINE# self . shuffle_args = [ shuffle_grid , ( 32 , 8 , 1 ) , None , None , None ] #NEWLINE# self . shuffle_args . extend ( _flatten ( [ ( ( ( R * S ) * T ) * K ) , ( ( R * S ) * K ) , ( S * K ) , K , ( ( ( R * S ) * T ) * C ) , ( ( R * S ) * C ) , ( S * C ) , C , ( R * S ) , T , R , S , magic_RS , magic_S ] ) ) #NEWLINE# lib . set_scratch_size ( self . shuffle_size )