(tensor, hist, nbins=64, offset=-48)
Helper function to compute the histogram of a tensor.

    Arguments:
        tensor (GPUTensor): the tensor to compute the histogram over
        hist (gpu pointer): the gpu memory region to store the 64 bin hist in.
        nbins (int, optional): number of histogram bins, each representing a power of 2
                               (default 64)
        offset (int, optional): offset the value of a bin from its idx as a power of two
                                (default offset=-48 means bin 0 represents 2**-48)
Helper function to compute the histogram of a tensor.
Helper function to compute the histogram of a tensor .
def _compute_hist(tensor, hist, nbins=64, offset=-48):
    """
    Helper function to compute the histogram of a tensor.

    Arguments:
        tensor (GPUTensor): the tensor to compute the histogram over
        hist (gpu pointer): the gpu memory region to store the 64 bin hist in.
        nbins (int, optional): number of histogram bins, each representing a power of 2
                               (default 64)
        offset (int, optional): offset the value of a bin from its idx as a power of two
                                (default offset=-48 means bin 0 represents 2**-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 )