import math


def _full_length(length: int, kernel_size: int, stride: int):
    """
    Given a convolution-like operation with the given kernel size and stride,
    return the length the input should have so that the last frame is full.
    """

    length = max(length, kernel_size)
    return stride * math.ceil((length - kernel_size) / stride) + kernel_size