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, 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.
dataset/ETHPy150Open NervanaSystems/neon/neon/backends/float_ew.py/_compute_hist