def get_padding(ks, s, hw):
    """ choose padding value to make sure:
    if s = 1, out_hw = in_hw;
    if s = 2, out_hw = in_hw // 2;
    if s = 4, out_hw = in_hw // 4;
    """
    if hw % s == 0:
        pad = max(ks - s, 0)
    else:
        pad = max(ks - (hw % s), 0)
    if pad % 2 == 0:
        return pad // 2
    else:
        return pad // 2 + 1