Created
October 23, 2023 22:10
-
-
Save sklam/5e5737137d48d6e5b816d14a90076f1d to your computer and use it in GitHub Desktop.
LoopNest, Shape, ndim inference
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am coming back to this after finishing some refactoring work on egglog and wanted to check to see if I am understanding things properly before trying to implement the features needed for this.
Thank you again for posting this example! I am excited about getting this sort of thing to work and it's essential to have real use cases like this to drive the development...
Let's say we implement an API like you proposed on top of the existing array api bindings:
With that, a user could write a loopnest function with it:
By applying some rewrite rules (included below in a dropdown), we could translate away the custom APIs and end up with something like this expression:
Then, using the existing source generation, we could create this Python source from that function:
Does that seem about right?
Implementation
I haven't tried any of this code, and to implement it would require adding functions as values to egglog. I believe this could be done without any (or minimal) changes to the core, but before starting on it, I wanted to check in to see if this use case is accurate enough to give it a go.
Also implementing generic functions and types would go a long way in making the code a bit more fluid, but in the examples I put here, I assume we don't have that feature yet. It should all still be possible without it, just more repetition.
I believe I could add them as a Python pre-processor and this use case would also be a good model to show how they help with readability.
Rewrite rules: