def calc_padding(img_width, stride, dilation, filter_width):
    """ calculate pixels to padding in order to keep input/output size same. """

    filter_width = dilation * (filter_width - 1) + 1
    if img_width % stride == 0:
        pad_along_width = max(filter_width - stride, 0)
    else:
        pad_along_width = max(filter_width - (img_width % stride), 0)
    return pad_along_width // 2, pad_along_width - pad_along_width // 2