Skip to content
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

Misleading method name from_list #47

Closed
bauerfe opened this issue Aug 15, 2023 · 8 comments
Closed

Misleading method name from_list #47

bauerfe opened this issue Aug 15, 2023 · 8 comments

Comments

@bauerfe
Copy link
Collaborator

bauerfe commented Aug 15, 2023

The name of the method NIRGraph.from_list suggests that a list is expected as input:

graph = NIRGraph.from_list([node_a, node_b, node_c])

In reality however it expects the nodes to be passed as individual arguments:

graph = NIRGraph.from_list(node_a, node_b, node_c)

I suggest the method to be either renamed to something like "Compose" or "Sequential", or to change it such that it accepts a list.

@matjobst
Copy link
Collaborator

matjobst commented Aug 21, 2023

I agree that this is slightly misleading.
Our current implementation is similar to the torch.nn.Sequential of Pytorch. Tensorflow's tf.keras.Sequential is similar to your first suggestion with the lists.
I like the idea of renaming to Sequential and keeping the definition otherwise as is.

@Jegp
Copy link
Collaborator

Jegp commented Aug 22, 2023

Nicely spotted! That's my bad. I really like avoiding the two [ ] characters :P

How about adding a check so we can work with both lists and varargs? That's also what PyTorch is doing, I believe.

@bauerfe
Copy link
Collaborator Author

bauerfe commented Aug 24, 2023

I would also prefer renaming it to Sequential and passing the args without container.

Pytorch (at least my possibly outdated version) raises an error when passing a list:

TypeError: list is not a Module subclass

I also don't mind supporting both, though.

@Jegp
Copy link
Collaborator

Jegp commented Sep 4, 2023

This should be fixed with #50. Would you mind confirming and closing, @bauerfe ?

@bauerfe
Copy link
Collaborator Author

bauerfe commented Sep 20, 2023

I'm really sorry but I must be missing something. Could you please specify how #50 addresses this issue? Neither the name nor the call signature of the from_list method has changed.

@Jegp
Copy link
Collaborator

Jegp commented Sep 20, 2023

You're entirely correct that the PR doesn't change the name of the method. But it allows the from_list method to take a list and varargs (

NIR/nir/ir.py

Line 44 in 464de9f

if len(nodes) > 0 and (
). So it kinda addresses the issue that the method called from_list doesn't even take lists.

I'm sympathetic if you wish to rename the method if you think there's a better name. I believe you suggested sequence or compose?

@Jegp
Copy link
Collaborator

Jegp commented Oct 5, 2023

@bauerfe could you share your opinion on how to proceed? Is the current naming sufficient, given #50?

@bauerfe
Copy link
Collaborator Author

bauerfe commented Oct 9, 2023

Yeah, sorry for the late reply. I think this is fine.

@bauerfe bauerfe closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants