8000 [pytree] support collections.defaultdict type for Python pytree by XuehaiPan · Pull Request #113255 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 13 commits into from

Conversation

Copy link
pytorch-bot bot commented Nov 8, 2023

🔗 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 Failures

As of commit 4a334a6 with merge base f93ea14 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@XuehaiPan XuehaiPan added the topic: not user facing topic category label Nov 8, 2023
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Nov 28, 2023
return defaultdict(default_factory, zip(keys, values))


def _defaultdict_serialize(context: Context) -> DumpableContext:
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Contributor
@zou3519 zou3519 left a 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

8000
@XuehaiPan XuehaiPan requested a review from zou3519 November 30, 2023 16:36
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Nov 30, 2023
@@ -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]
Copy link
Collaborator Author

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.

XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Nov 30, 2023
@XuehaiPan
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 30, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Dec 1, 2023
@facebook-github-bot facebook-github-bot deleted the gh/XuehaiPan/11/head branch December 4, 2023 15:29
dmenig pushed a commit to dmenig/pytorch that referenced this pull request Dec 21, 2023
dmenig pushed a commit to dmenig/pytorch that referenced this pull request Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: pytree open source topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0