Mojo function
idx2crd2
idx2crd2(idx: IntTuple[origin], shape: IntTuple[origin], _stride: IntTuple[origin]) -> IntTuple
Convert a linear index to coordinates.
This function handles the actual conversion logic for different input combinations.
Notes:
- Handles four cases: tuple-tuple-tuple, tuple-int-int, int-tuple-tuple, and int-int-int.
- When input shapes don't match, `abort()` will be called.
- Handles four cases: tuple-tuple-tuple, tuple-int-int, int-tuple-tuple, and int-int-int.
- When input shapes don't match, `abort()` will be called.
Args:
- idx (
IntTuple[origin]
): The linear index to convert. - shape (
IntTuple[origin]
): The shape of the tensor/array. - _stride (
IntTuple[origin]
): Custom strides to use for the conversion. If empty, strides are computed from the shape using prefix_product.
Returns:
A new IntTuple containing the coordinates corresponding to the linear index.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!