New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POC] emit indexing code directly #4489
base: master
Are you sure you want to change the base?
Conversation
|
||
@dataclass(frozen=True) | ||
class IndexedView(View): | ||
# TODO: Any is LazyBuffer but circular import bleh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
speaking of leaky abstractions
how's shoving a LB into a View 😎
Changes
|
does this support backward for setitem? |
I haven't tried yet. |
There are a bunch of rough edges here I haven't ironed out, but here's a POC.
I wrote a bunch of hacks just to get it working.
I've tried doing symbolic index tensor with a new symbolic object, but I found myself needing a new
UOps
to deal with the loading for therender_ops
I saw how setitem was doing the store part with ShapeTracker, so I thought on a conceptual level the advanced indexing stuff should also be apart of the ShapeTracker.
The basic idea is just creating a non-mergable special
View
(IndexedVIew) that contains the Tensor indices which is then global_loaded and used to determine the offsets of the Buffer that holds the IndexedView when this Buffer is loaded/stored. The kernel code just indexes directly instead of arange masking.Currently things that work:
Things that don't work:
There are a lot of garbage hacks in this currently
The main thing that works is the
index()
function in linearizer that correctly determines the offset given buffers used for indexing (doesn't work in all cases yet... bunch of hacks in Tensor getitem to get tests passing)It's gonna take some more time for me to get this to a point where it's mergeable since I still don't fully get schedule and shapetracker. Or idk is this pursuable?