-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[pytree] support collections.defaultdict type for Python pytree #113255
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
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113255
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4a334a6 with merge base f93ea14 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ytree" cc zou3519 [ghstack-poisoned]
…ytree" cc zou3519 [ghstack-poisoned]
…ytree" cc zou3519 [ghstack-poisoned]
…ytree" cc zou3519 [ghstack-poisoned]
…ytree" cc zou3519 [ghstack-poisoned]
ghstack-source-id: fdad50f Pull Request resolved: pytorch#113255
…ytree" cc zou3519 [ghstack-poisoned]
ghstack-source-id: 28d7680 Pull Request resolved: pytorch#113255
…ytree" cc zou3519 [ghstack-poisoned]
ghstack-source-id: 8f40be9 Pull Request resolved: pytorch#113255
…ytree" cc zou3519 [ghstack-poisoned]
…ytree" cc zou3519 [ghstack-poisoned]
return defaultdict(default_factory, zip(keys, values)) | ||
|
||
|
||
def _defaultdict_serialize(context: Context) -> DumpableContext: |
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.
Can you add a test for _defaultdict_serialize/_defaultdict_deserialize?
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 add a serialization test case for defaultdict
.
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.
Needs a test for serializing/deserializing defaultdict, otherwise, LGTM
…ytree" cc zou3519 [ghstack-poisoned]
ghstack-source-id: 4762fc7 Pull Request resolved: pytorch#113255
…ytree" cc zou3519 [ghstack-poisoned]
@@ -345,7 +345,7 @@ def _ordereddict_unflatten( | |||
|
|||
def _defaultdict_flatten(d: DefaultDict[Any, Any]) -> Tuple[List[Any], Context]: | |||
values, dict_context = _dict_flatten(d) | |||
return values, (d.default_factory, dict_context) | |||
return values, [d.default_factory, dict_context] |
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.
Changed the context type from tuple
to list
. Because json.dumps
serializes a tuple
to a array, while a array is deserialized to list
.
…ytree" cc zou3519 [ghstack-poisoned]
ghstack-source-id: 3a58a5c Pull Request resolved: pytorch#113255
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Pull Request resolved: #113256 Approved by: https://github.com/zou3519 ghstack dependencies: #112485, #113255
…rch#113255) Pull Request resolved: pytorch#113255 Approved by: https://github.com/zou3519 ghstack dependencies: pytorch#112485
…3256) Pull Request resolved: pytorch#113256 Approved by: https://github.com/zou3519 ghstack dependencies: pytorch#112485, pytorch#113255
Stack from ghstack (oldest at bottom):
none_is_leaf
andnamespace
in C++ pytree #114858cc @zou3519