-
Notifications
You must be signed in to change notification settings - Fork 29
Index #80
base: main
Are you sure you want to change the base?
Index #80
Conversation
Signed-off-by: benny-nottonson <[email protected]>
I was looking at this again,
The only different way of doing it i can really think of is having something like, which to me looks like it is becoming too much.
Or create a the whole mask/indeces to be selected beforehand and pass that as attribute. But my worry is that the current attributes are not big enough to support this. |
Maybe the way I showed for the attributes is too much, but in the end in the first place when we are able to have a frontend the user in reality wouldn't call the code that way, they would do it like in pytorch, mlx or other (not like onnx the 99% of the time), and I feel it is better to have the attributes declared this way.
It let's us declare more info easily I would say (extra: a slice and indices can't work on the same dimension, but I think you already no). But that's how I see it I don't know. And for the scatter part, if you say mlx is doing the slice and index combined instead of how pytorch does calling the two functions separately (slice and then index), then yeah maybe for now we can leave the code as it is and later implement the scatter function (and i also don't how to do it, because in the first place not all processors have a scatter simd functionality baked in from what I understand, so I think thats why mojo uses the scatter llvm instrinsic). |
INDEX: An extension on SLICE that adds the ability to select values form a tensor based on specified indeces (or slices).
Note that it also adds the ability to duplicate values from a dimension. (This feature is used in upsampling)
Short demo of the expected behaviour:
Notes: Using the attributes like it is right now feels hacky and not the right way to do it. One way of doing it could be to convert all slices to indeces in the API, but it would make the required size of the attribute a lot bigger then it is now. Even now you are basically restricted to specify up to MAX_RANK indeces in the list. I feel like this just needs an attribute of type List[Int] which can potentially be very big. But that has some implication on the size of the other attributes as well.