candle icon indicating copy to clipboard operation
candle copied to clipboard

fix cpu backend: index_select fails with negative index

Open shua opened this issue 1 year ago • 0 comments

currently the cpu backend incorrectly converts negative i64 to usize by casting, but it should check if the index is negative, and in that case, count back from the end of the thing being indexed.

This change fixes the behaviour by adding a private trait and implementing it for all valid index types. If any more types are added as index types, the compiler should direct people to implement this same trait to calculate the index properly.

shua avatar Jul 07 '24 19:07 shua