Skip to content

[BUG] Typo in comments of idx2crd #2883

@Gin-Sin

Description

@Gin-Sin

Hi, recently I found a typo in CuTe DSL, specifically in the comments of cute.idx2crd, which is as the following:

@dsl_user_op
def idx2crd(idx, shape, *, loc=None, ip=None):
    """
    Convert a linear index back into a multi-dimensional coordinate using the specified layout.

    Mapping from a linear index to the corresponding multi-dimensional coordinate in the layout's coordinate space.
    It essentially "unfolds" a linear index into its constituent coordinate components.

    :param idx: The linear index to convert back to coordinates.
    :type idx: : int/Integer/Tuple
    :param shape: Shape of the layout defining the size of each mode
    :type shape: Shape
    :param loc: Optional location information for IR diagnostics.
    :type loc: optional
    :param ip: Optional instruction pointer or context for underlying IR functions.
    :type ip: optional
    :return: The result of applying the layout transformation to the provided coordinate.
    :rtype: Coord

    **Examples:**

    .. code-block:: python

        import cutlass.cute as cute
        @cute.jit
        def foo():
            coord = cute.idx2crd(11, (5,4))
            # Computed as: 11 = 2 * 4 + 3, so coordinate is (2, 3)
            print(coord)
        foo()  # Expected output: (2, 3)

    **Note:**
        Python DSL is aligned with C++ DSL.
    """
    if is_integer(idx) and is_integer(shape):
        return idx
    idx_val = _pack_int_tuple(idx, loc=loc, ip=ip)
    shape_val = _pack_shape(shape, loc=loc, ip=ip)
    res = _cute_ir.idx2crd(idx_val, shape_val, loc=loc, ip=ip)
    return _unpack_x_tuple(res, loc=loc, ip=ip)

In the above comments, it gives an example of cute.idx2crd(11, (5,4)) and shows the result is (2, 3), but the correct result should be (1, 2) because the index is MN Index. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions