-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add check for second value in sum: Logsumexp #90
base: main
Are you sure you want to change the base?
Conversation
torchfix/visitors/misc/__init__.py
Outdated
@@ -183,7 +183,7 @@ def visit_Call(self, node): | |||
node.args[0].value.args[0].value | |||
) | |||
== "torch.exp" | |||
): | |||
) and len(node.args[0].value.args) > 1 and node.args[0].value.args[1].value is not None: |
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.
Use get_specific_arg
from https://github.com/pytorch-labs/torchfix/blob/main/torchfix/common.py#L64 because dim
can be passed as a positional or as a keyword argument.
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.
Updated and added condition to check for dim. But I used has_specific_arg since we just want to check its presence
message=self.ERRORS[0].message(), | ||
replacement=None, | ||
) | ||
if len(node.args[0].value.args) > 1 and ( |
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 don't think value.args[1]
is always correct, because the order may be different for keyword arguments.
For example, add test y = torch.log(torch.sum(torch.exp(x)), keepdim=True, dim=None)
.
I think you can delete most if this and just use get_specific_arg("dim", 1)
, which will return None if the argument is not present.
Added conditions to check if second value exists in "sum" for Logsumexp update. If not then no change.
Files updated: