Mojo function
normalize_neg_index
normalize_neg_index(idx: Int, dim_size: Int) -> Int
Indices passed to gather and scatter ops may be negative. This performs a normalization so that they can be used to index into a buffer.
Returns val + dim if val < 0 else val
Returns:
Int
Raises:
If the index is out of range [-dim_size, dim_size).
normalize_neg_index[dtype: DType, width: Int, out_type: DType = DType.int](idx: SIMD[dtype, width], dim_size: Int) -> SIMD[out_type, width]
Indices passed to gather and scatter ops may be negative. This performs a normalization so that they can be used to index into a buffer.
Returns val + dim if val < 0 else val
Returns:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!