-
Notifications
You must be signed in to change notification settings - Fork 7k
__deepcopy__ for DualGraphModule #8708
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8708
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4e10111 with merge base 22e86bd ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Thank you for the PR @andreasfloros . To be completely transparent here, I was hoping we could find a much more obvious fix for this problem. The current fix in this PR involves importing and relying on various private structures from Basically, if that code were to break (because e.g. of an upstream change in some internal of Do you think we can address the original problem from #8634 in a more obvious way? |
@NicolasHug the issue is with the hooks. Other than that, def __deepcopy__(self, memo):
res = type(self).__new__(type(self))
memo[id(self)] = res
res.__dict__ = copy.deepcopy(self.__dict__, memo)
return res However, this is not done in What do you think? |
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.
Oh, I didn't realize the fix was actually mostly taken from the implementation in the base class (you did write that as a comment, I missed it!)
I guess that's fine. Let's hope this file doesn't get updated too often. If it does, we might have to revert the fix, but for now this is hopefully OK.
Thanks a lot for the fix @andreasfloros . I pushed a small non-regression test and I'll merge the PR soon
Reviewed By: vmoens Differential Revision: D68021959 fbshipit-source-id: 8ab640cedd3b85d135af0164375da36848602b84 Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
DualGraphModule
inherits deepcopy behavior fromGraphModule
, which ignores thetrain_graph
andeval_graph
.This PR implements
__deepcopy__
forDualGraphModule
.Fixes #8634