pytorch/torch/ao/quantization
Xuehai Pan e8fadba28c [pytree] add treespec_{leaf,tuple,dict} functions for args_spec modification (#160843)
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
2025-11-01 04:12:11 +00:00
..
backend_config Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
experimental Clean up unused Pyrefly suppressions (#166178) 2025-10-25 05:32:21 +00:00
fx [2/N] Use 'is' in callable comparisons (#166685) 2025-10-31 08:08:07 +00:00
pt2e [pytree] add treespec_{leaf,tuple,dict} functions for args_spec modification (#160843) 2025-11-01 04:12:11 +00:00
quantizer Use 'is' in callable comparisons (#166624) 2025-10-30 19:00:09 +00:00
__init__.py Fix pyrelfy ignore syntax in distributions and ao (#166248) 2025-10-26 22:13:48 +00:00
_correct_bias.py [1/N] Remove unused loop variables (#166258) 2025-10-30 12:22:25 +00:00
_equalize.py Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
_learnable_fake_quantize.py Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
fake_quantize.py Fix pyrelfy ignore syntax in distributions and ao (#166248) 2025-10-26 22:13:48 +00:00
fuse_modules.py
fuser_method_mappings.py Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
observer.py [3/N] fix typo in other folders (#166606) 2025-10-30 10:30:40 +00:00
pattern.md
qconfig_mapping.py [4/N] Apply ruff UP035 rule to python code (#164206) 2025-10-01 19:05:53 +00:00
qconfig.py Fix pyrelfy ignore syntax in distributions and ao (#166248) 2025-10-26 22:13:48 +00:00
quant_type.py
quantization_mappings.py Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
quantize_fx.py [BE][13/16] fix typos in torch/ (torch/ao/) (#156603) 2025-06-29 04:34:04 +00:00
quantize_jit.py Revert "[Code Clean] Clean asserts in torch/ao/quantization (root, quantizer, backend_config) (#165433)" 2025-10-21 22:10:19 +00:00
quantize_pt2e.py [BE][13/16] fix typos in torch/ (torch/ao/) (#156603) 2025-06-29 04:34:04 +00:00
quantize.py Fix flake8 B028 warnings (#166224) 2025-10-26 06:18:55 +00:00
stubs.py [BE][PYFMT] migrate PYFMT for torch/ao/ to ruff format (#148185) 2025-06-14 16:47:04 +00:00
utils.py Fix flake8 B028 warnings (#166224) 2025-10-26 06:18:55 +00:00