@triton.autotune(configs=_get_autotune_configs(), key=['M', 'N'])
@triton.jit
def _triton_dynamic_quantize_kernel(output_ptr, input_ptr, scale_ptr,
    stride_outputm, stride_outputn, stride_inputm, stride_inputn,
    n_elements, M: tl.constexpr, N: tl.constexpr):
    pid = tl.program_id(axis=0)
    offsets = tl.arange(0, N)
    mask = offsets < n_elements
    input_ptrs = input_ptr + pid * stride_inputm + offsets
    input_vals = tl.load(input_ptrs, mask=mask, other=1e-06)
    abs_max_f = tl.reduce(input_vals, 0, _abs_max)
    dynamic_per_token_scale = 127.0 / abs_max_f
    precison_mask = tl.where(input_vals > 0, 0.5, -0.5)
    output_vals = (input_vals * dynamic_per_token_scale + precison_mask).to(tl
        .int8)
    output_ptrs = output_ptr + pid * stride_outputm + offsets
    tl.store(output_ptrs, output_vals, mask=mask)
    tl.store(scale_ptr + pid, abs_max_f / 127.0)
