def _compute_hist(tensor, hist, nbins=64, offset=(-48)):
 threads = 128
 assert ((nbins < threads) and (nbins > 0))
 size = tensor.size
 strides = (np.floor((np.sqrt(size) / threads)) * threads)
 if (strides < threads):
  strides = max(((size / threads) * threads), threads)
 blocks = max(1, (int(strides) // threads))
 kernel_args = [hist, tensor.gpudata, int(strides), size]
 hist_kern = _get_hist_kernel(tensor.dtype.str, nbins, offset)
 hist_kern.prepared_call((blocks, 1, 1), (threads, 1, 1), *kernel_args)

def _compute_hist ( tensor , hist , nbins = 64 , offset = ( - 48 ) ) : threads = 128 assert ( ( nbins < threads ) and ( nbins > 0 ) ) size = tensor . size strides = ( np . floor ( ( np . sqrt ( size ) / threads ) ) * threads ) if ( strides < threads ) : strides = max ( ( ( size / threads ) * threads ) , threads ) blocks = max ( 1 , ( int ( strides ) // threads ) ) kernel_args = [ hist , tensor . gpudata , int ( strides ) , size ] hist_kern = _get_hist_kernel ( tensor . dtype . str , nbins , offset ) hist_kern . prepared_call ( ( blocks , 1 , 1 ) , ( threads , 1 , 1 ) , * kernel_args )
helper function to compute the histogram of a tensor .