-
Notifications
You must be signed in to change notification settings - Fork 130
Replace str "output" by a dummy Op in the clients of the FunctionGraph #790
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
Conversation
ba93370
to
a9204fb
Compare
4b9ed3a
to
3ab8992
Compare
707ce87
to
f7da400
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #790 +/- ##
==========================================
+ Coverage 80.76% 80.78% +0.01%
==========================================
Files 163 163
Lines 46938 46921 -17
Branches 11497 11490 -7
==========================================
- Hits 37911 37903 -8
+ Misses 6785 6774 -11
- Partials 2242 2244 +2
|
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.
Really like this one, the code looks a lot cleaner without having to check for strings.
ApplyOrOutput = Apply | Literal["output"] | ||
ClientType = tuple[ApplyOrOutput, int] | ||
|
||
class Output(Op): |
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.
It's quite surprising we don't have another class named Output
anywhere else in the codebase
Marking as a draft because I want to do a release before these changes |
f7da400
to
5b8f38a
Compare
Description
This is often a source of bug, because everything in the clients graph is a node with an Op, except these sneaky string labels "output". It also messes up mypy in multiple places.
The whole point of having "output" in the clients dictionary is so we know if a variable is used in multiple places (i.e., may still need to be computed even if we do a rewrite that gets rid of it as an intermediate operation). For that purpose it doesn't really matter if it's an output or used by another node. This approach allows handling these cases more easily because it looks like just another client.
We could also get rid of this dummy client, and force rewrites to check if a node is in fgraph.outputs separately but that feels more cumbersome. I understand why they added "output" as a client. I just think it hurts a bit more than needed to have it be so different.
Having said and done this PR I'm happy to just close it if people don't agree with it.
Related Issue
Checklist
Type of change