@triton.jit
def _QuantUint8Window_impl(input_ptr, output_ptr, numel, window, BLOCK_SIZE:
    tl.constexpr):
    tid = tl.program_id(0)
    input_ptr += tid * BLOCK_SIZE
    output_ptr += tid * BLOCK_SIZE
    offset = tl.arange(0, BLOCK_SIZE)
    mask = offset < numel - tid * BLOCK_SIZE
    input = tl.load(input_ptr + offset, mask=mask).to(tl.float32)
    input = tl.minimum(tl.maximum(input, -window), window)
    input = (input + window) / (2 * window)
    input *= 255
    input = input.to(tl.uint8)
    tl.store(output_ptr + offset, input, mask=mask)
