-
Notifications
You must be signed in to change notification settings - Fork 26.3k
fix: nn.Module allowing for expected Mixin MRO #74096
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
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit b68673a (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
albanD
left a comment
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.
Thanks for sending a fix!
|
@pytorchbot merge this please |
|
Hey @MattiaSarti. |
Summary: ## Description This pull request solves #74036 ## How Functionality Changes Were Tested Running: ``` from torch import nn class A: def __init__(self): super().__init__() self.a = True class B(A, nn.Module): def __init__(self): super().__init__() self.b = True class C(nn.Module, A): def __init__(self): super().__init__() self.c = True b = B() c = C() print(b.b) print(b.a) print(c.c) print(c.a) ``` - ### Results - Before: ``` >>> from torch import nn >>> >>> >>> class A: ... def __init__(self): ... super().__init__() ... self.a = True ... >>> >>> class B(A, nn.Module): ... def __init__(self): ... super().__init__() ... self.b = True ... >>> >>> class C(nn.Module, A): ... def __init__(self): ... super().__init__() ... self.c = True ... >>> >>> b = B() >>> c = C() >>> >>> print(b.b) True >>> print(b.a) True >>> >>> print(c.c) True >>> print(c.a) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/pytorch/torch/nn/modules/module.py", line 1188, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'C' object has no attribute 'a' ``` - ### Results - After: ``` >>> from torch import nn >>> >>> >>> class A: ... def __init__(self): ... super().__init__() ... self.a = True ... >>> >>> class B(A, nn.Module): ... def __init__(self): ... super().__init__() ... self.b = True ... >>> >>> class C(nn.Module, A): ... def __init__(self): ... super().__init__() ... self.c = True ... >>> >>> b = B() >>> c = C() >>> >>> print(b.b) True >>> print(b.a) True >>> >>> print(c.c) True >>> print(c.a) True ``` Pull Request resolved: #74096 Approved by: https://github.com/albanD Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/1ac519e6b5f53c02f78d9bae26411affd49328af Reviewed By: seemethere Differential Revision: D34822179 fbshipit-source-id: 54741d983477f8655348b1b7991e8ddcdbc879f4
|
This pull request has been reverted by 97ade8c. To re-land this change, please open another pull request, assignthe same reviewers, fix the CI failures that caused the revert and make sure that the failing CI runs on the PR by applying the proper ciflow label (e.g., ciflow/trunk). |
Description
This pull request solves #74036
How Functionality Changes Were Tested
Running:
Results - Before:
Results - After: