pytorch
6cabc105 - Merge type stubs for torch.nn.parallel (#101528)

Commit
1 year ago
Merge type stubs for torch.nn.parallel (#101528) Fixes #91648 As explained in the tracking issue, the incomplete type stubs in `torch/nn/parallel` mask `DataParallel` methods relevant for subclassing and also mask type issues present in the code as well. One notable change here is the addition of [`allow_redefinition = True`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-allow_redefinition) in `mypy.ini`, which allows for a common pattern: > Allows variables to be redefined with an arbitrary type, as long as the redefinition is in the same block and nesting level as the original definition. This is added specifically to allow for the type narrowing of `device_ids` in `torch.nn.parallel.data_parallel.data_parallel` from `Sequence[Union[int, torch.device]]` to `Sequence[int]`. Other than this, there are various renamings and `type: ignore` comments added to bypass errors that arose from the merging. @ezyang Pull Request resolved: https://github.com/pytorch/pytorch/pull/101528 Approved by: https://github.com/ezyang
Author
Committer
Parents
Loading