Slice index type

18 views
Skip to first unread message

Joel Berkeley

unread,
May 20, 2026, 11:38:50 PMMay 20
to OpenXLA Discuss
Hi,

I want to find out about index types for tensor ops, in particular whether slice supports negative indexing, like numpy.

Why is the index type for slice is signed 64-bit int (I think that's what si64 and DenseI64ArrayAttr mean), despite the docs stating all args must be >0? Is it because

1. You don't support negative indices (like in numpy etc)
2. Other APIs do support negative indices (if so which ones?)
3. You want to use the same type everywhere for indices?



P.S. I think the docs for slice are subtly but confusingly wrong. They say "1-dimensional tensor constant of type si64", but I don't believe these are tensors, precisely because this isn't dynamic slicing. They're (MLIR?) arrays.

Best,
Joel

Joel Berkeley

unread,
May 20, 2026, 11:40:29 PMMay 20
to OpenXLA Discuss, Joel Berkeley
To prevent confusion, I'm not requesting negative indexing. In fact it may be easier for me if it's NOT supported.

Jacques Pienaar

unread,
May 27, 2026, 11:54:30 PMMay 27
to Joel Berkeley, OpenXLA Discuss
Hey Joel,

I believe it's (1) from reading the op constraints and looking at ~equivalent XLA op ( https://openxla.org/xla/operation_semantics#slice ). While the latter is int64_t (signed ) due to guide of not using unsigned ints in C++ to say non-negative which was just carried over to signed integer atrribute. Now, XLA doesn't dictate the semantics, but it is probably the most complete mapping of StableHLO to executional form and origin of StableHLO so reasonably good extra check 🙂

-- Jacques 

--
You received this message because you are subscribed to the Google Groups "OpenXLA Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openxla-discu...@openxla.org.
To view this discussion visit https://groups.google.com/a/openxla.org/d/msgid/openxla-discuss/7284b7a8-e1fa-403d-9c8f-8eee25946384n%40openxla.org.
For more options, visit https://groups.google.com/a/openxla.org/d/optout.
Reply all
Reply to author
Forward
0 new messages