-
Notifications
You must be signed in to change notification settings - Fork 10
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
implemented .inputs and .outputs properties for NIRGraphs #30
Conversation
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 nice work @matjobst. I particularly like how we're not adding any data to the existing declarations, but just using the existing data to provide convenient functionality.
There are a few linter errors, but that may just be a matter of rebasing to main?
But, before we merge, I suggest we resolve the conversation here: #28
nir/ir.py
Outdated
|
||
@property | ||
def inputs(self): | ||
return {name:node for name,node in self.nodes.items() if isinstance(node, Input)} |
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.
I get a warning from ruff that the line is too long. May I suggest either adding pre-commit as mentioned in the docs or maybe bumping the minimum line length to something more than 88?
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.
Or maybe it's just a matter of rebasing onto main?
083fc4b
to
3e8e36d
Compare
I pushed this failing version now to showcase one issue that came up: The reason for that is that dataclasses generate a default comparison def __eq__(self, other):
return self.shape == other.shape Since the .shape is typically an array, it would rather need to do something like: def __eq__(self, other):
return (self.shape == other.shape).all() However I am still not sure whether we want that behavior. Because that means that: a = nir.Input(shape=np.array([1]))
b = nir.Input(shape=np.array([1]))
a == b # True This could be avoided by having a name in each node. |
3e8e36d
to
de2382e
Compare
de2382e
to
a30c73b
Compare
cf2685d
to
c008851
Compare
This is also a proposed fix to #36 |
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.
I think this is a solid implementation and fulfills the specs. Nice work!
Please go ahead and squash + merge when ready :)
* implemented .inputs and .outputs properties for NIRGraphs * using identity for equality * Fixed tests after rebase * Added missing @DataClass(eq=False)
* implemented .inputs and .outputs properties for NIRGraphs * using identity for equality * Fixed tests after rebase * Added missing @DataClass(eq=False)
Implementation of Issue #29 "Add .inputs and .outputs properties to NIRGraph"