Skip to content
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

updated pad_sequence type hint #108765

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torch/nn/utils/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def pad_packed_sequence(
return padded_output.index_select(batch_dim, unsorted_indices), lengths[unsorted_indices.cpu()]
return padded_output, lengths


# NOTE: .pyi stub allows Iterable[Tensor], but for JIT-compatibility we need to be more restrictive here.
def pad_sequence(
sequences: Union[Tensor, List[Tensor]],
batch_first: bool = False,
Expand Down
4 changes: 2 additions & 2 deletions torch/nn/utils/rnn.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import (
Any,
List,
Iterable,
NamedTuple,
Optional,
overload,
Expand Down Expand Up @@ -82,7 +82,7 @@ def pad_packed_sequence(
total_length: Optional[int] = ...,
) -> Tuple[Tensor, ...]: ...
def pad_sequence(
sequences: List[Tensor],
sequences: Union[Tensor, Iterable[Tensor]],
batch_first: bool = False,
padding_value: float = ...,
) -> Tensor: ...
Expand Down
Loading