Skip to content

Commit

Permalink
[pytree] Extract reusable generic tests for pytree (pytorch#110395)
Browse files Browse the repository at this point in the history
Part of pytorch#109684

- pytorch#109684

Changes:

- Add new functions `tree_structure`, `tree_leaves`, `tree_map_` and `tree_map_only_` to Python pytree.
- Extract reusable tests for pytree to `TestGenericPytree`.
- Change `treespec_dumps` and `treespec_loads` in C++ pytree to call Python pytree and use JSON string as serialization type.
- Rename `torch.utils.pytree` -> `torch.utils._cxx_pytree`.

Pull Request resolved: pytorch#110395
Approved by: https://github.com/zou3519
  • Loading branch information
XuehaiPan authored and pytorchmergebot committed Oct 4, 2023
1 parent 37afa0c commit 449271f
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 416 deletions.
2 changes: 1 addition & 1 deletion .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ include_patterns = [
'tools/**/*.py',
'torchgen/**/*.py',
'torch/utils/_pytree.py',
'torch/utils/pytree.py',
'torch/utils/_cxx_pytree.py',
'torch/utils/benchmark/utils/common.py',
'torch/utils/benchmark/utils/timer.py',
'torch/utils/benchmark/utils/valgrind_wrapper/**/*.py',
Expand Down
2 changes: 1 addition & 1 deletion mypy-strict.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ files =
tools,
torch/profiler/_memory_profiler.py,
torch/utils/_pytree.py,
torch/utils/pytree.py,
torch/utils/_cxx_pytree.py,
torch/utils/benchmark/utils/common.py,
torch/utils/benchmark/utils/timer.py,
torch/utils/benchmark/utils/valgrind_wrapper
Expand Down
Loading

0 comments on commit 449271f

Please sign in to comment.