class triton.language.range(self, arg1, arg2=None, step=None, num_stages=None)

Iterator that counts upward forever.

def kernel(...):
    for i in tl.range(10, num_stages=3):

This is a special iterator used to implement similar semantics to Python’s range in the context of triton.jit functions. In addition, it allows user to pass extra attributes to the compiler.

  • arg1 – the start value.

  • arg2 – the end value.

  • step – the step value.

  • num_stages

    pipeline the loop into this many stages (so there are num_stages iterations of the loop in flight at once).

    Note this is subtly different than passing num_stages as a kernel argument. The kernel argument only pipelines loads that feed into dot operations, while this attribute tries to pipeline most (though not all) loads in this loop.

__init__(self, arg1, arg2=None, step=None, num_stages=None)


__init__(self, arg1[, arg2, step, num_stages])