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

Fix UserWarning: Defining your __torch_function__ as a plain method is deprecated and will be an error in future, please define it as a classmethod. #565

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

V0XNIHILI
Copy link

@V0XNIHILI V0XNIHILI commented Mar 28, 2023

See: https://github.com/pytorch/pytorch/blob/08766b23de8ed50a8f52973df78114426500cb65/torch/overrides.py#L1547.

I get this error with the latest version of Brevitas (installed via pip one week ago) with PyTorch 1.13

@V0XNIHILI V0XNIHILI changed the title Fix issue "UserWarning: Positional args are being deprecated, use kwargs instead. Refer to https://pytorch.org/docs/master/generated/torch.nn.Module.html#torch.nn.Module.state_dict for details." UserWarning: Defining your __torch_function__ as a plain method is deprecated and will be an error in future, please define it as a classmethod. Mar 28, 2023
…s deprecated and will be an error in future, please define it as a classmethod.
@V0XNIHILI V0XNIHILI changed the title UserWarning: Defining your __torch_function__ as a plain method is deprecated and will be an error in future, please define it as a classmethod. Fix UserWarning: Defining your __torch_function__ as a plain method is deprecated and will be an error in future, please define it as a classmethod. Mar 28, 2023
@Giuseppe5 Giuseppe5 changed the base branch from master to dev March 30, 2023 08:40
@Giuseppe5 Giuseppe5 self-requested a review March 30, 2023 21:01
@V0XNIHILI
Copy link
Author

@Giuseppe5 is this okay?

@@ -79,6 +79,7 @@ def training(self):
else:
return None

@classmethod
def __torch_function__(self, func, types, args=(), kwargs=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename self to cls?

@Giuseppe5
Copy link
Collaborator

Apart from the change of self to cls, I don't think there are any other issues with this change.

I would wait for your commit and @volcacius comments, and eventually merge it

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

Successfully merging this pull request may close these issues.

None yet

2 participants