Open
Conversation
Member
|
i don't get it. you can dispatch on einsum Op directly (and you did). direct dispatches on subclasses (Einsum) take precedence over dispatches on parent class (OFG) |
ricardoV94
reviewed
Mar 30, 2026
| subscripts = op.subscripts | ||
|
|
||
| def einsum(*operands): | ||
| return mx.einsum(subscripts, *operands) |
Member
There was a problem hiding this comment.
they are both going to mx einsum?
Did you mean one goes through funcify ofg and the other mx einsum? Do you need a rewrite/ separate op for that? can you anslyze the subscripts and decide here?
Member
Author
Oh nice, I didn't think of that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MLX can't handle some of the behaviors of our einsum OpFromGraph, so I added a rewrite to a dummy
AbstractEinsumOp and dispatch on that. It's mostly a corner case (it can't do the trace pattern,"ii->", because it uses a symbolicArange). If my solution is too cute I can remove it and we can just error on the unsupported case. I benchmarked native mx.einsum against the OpFromGraph approach and they're pretty similar (OFG is a bit faster, but like 5%).