def image_slice(x, X, B, D, pad=0):
    start = x*B - pad
    stop  = start + D
    pad = [0,0]
    if start < 0:
        pad[0] = -start
        start = 0
    if stop - 1 >= X:
        pad[1] = stop - X
    return start, stop, pad
dataset/ETHPy150Open NervanaSystems/neon/neon/backends/winograd4.py/image_slice/original