__deepcopy__ for DualGraphModule#8708
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 resHowever, this is not done in What do you think? |
NicolasHug
left a comment
There was a problem hiding this comment.
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>
DualGraphModuleinherits deepcopy behavior fromGraphModule, which ignores thetrain_graphandeval_graph.This PR implements
__deepcopy__forDualGraphModule.Fixes #8634