Hi,
The problem is that you assign the exact same entry with different values.
This is undefined behavior: in a single line you say a=1 and a=2. What would you expect the value of a to be after this line?
It’s hard to define a default behavior for that (without large performance cost because conflicting indices would need to be detected).
On cpu it appears that it gets assigned the value which is last in the indexing, on gpu you sometimes get another value.