mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
The goal of this PR is to provide a standard way to create simple treespec instances and hide the implementation details of the `PyTreeSpec` class. Changes: 1. Add function `treespec_leaf()` to replace `LeafSpec()`. 2. Add function `treespec_tuple(...)` and `treespec_dict(...)` to create treespec for `tuple` / `dict` which is used for `*args` / `**kwargs`. This avoids direct modification to `treespec` instances that rely on the implementation details of the `PyTreeSpec` class. 3. Change `len(spec.children_specs)` to `spec.num_children`. 4. Change `isinstance(spec, LeafSpec)` to `spec.is_leaf()`. ------ Pull Request resolved: https://github.com/pytorch/pytorch/pull/160843 Approved by: https://github.com/mlazos |
||
|---|---|---|
| .. | ||
| _activation_checkpointing | ||
| _aot_autograd | ||
| __init__.py | ||
| aot_autograd.py | ||
| apis.py | ||
| autograd_function.py | ||
| batch_norm_replacement.py | ||
| benchmark_utils.py | ||
| compile_utils.py | ||
| compilers.py | ||
| config.py | ||
| deprecated.py | ||
| eager_transforms.py | ||
| functional_call.py | ||
| fx_minifier.py | ||
| make_functional.py | ||
| partitioners.py | ||
| predispatch.py | ||
| pyfunctorch.py | ||
| python_key.py | ||
| pytree_hacks.py | ||
| top_operators_github_usage.py | ||
| utils.py | ||
| vmap.py | ||