You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Other][C++][Compute] inverse_permutation and scatter should accept unsigned integers #54920
The compute functions inverse_permutation and scatter accept arrays of indices that are can only be be signed integers. This limits the range of indices that they can accept, and may force the user into doing an unnecessary cast.
For context, scatter is implemented as Take(values, InversePermutation(indices)).
The inverse_permutation kernel explicitly checks for negative indices:
changed the title [-][C++][Compute] `inverse_permutation` and `scatter` should accept unsigned integers[/-][+][Other][C++][Compute] `inverse_permutation` and `scatter` should accept unsigned integers[/+]on Oct 21, 2026
Activity
[-][C++][Compute] `inverse_permutation` and `scatter` should accept unsigned integers[/-][+][Other][C++][Compute] `inverse_permutation` and `scatter` should accept unsigned integers[/+]pitrou commentedon Oct 22, 2026
The code size concern is genuine, but perhaps we can base the signed implementations on the unsigned ones?
ypomortsev commentedon Oct 22, 2026
Right, the signed implementation can use the fact that valid signed values are the same bitwise as unsigned, e.g. pseudocode