Skip to content

Bug fix for apply_chunking_to_forward chunking dimension check #8391

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

Merged
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
4 changes: 2 additions & 2 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,9 +1667,9 @@ def forward(self, hidden_states):
"""

assert len(input_tensors) > 0, "{} has to be a tuple/list of tensors".format(input_tensors)
tensor_shape = input_tensors[0].shape
tensor_shape = input_tensors[0].shape[chunk_dim]
assert all(
input_tensor.shape == tensor_shape for input_tensor in input_tensors
input_tensor.shape[chunk_dim] == tensor_shape for input_tensor in input_tensors
), "All input tenors have to be of the same shape"

# inspect.signature exist since python 3.5 and is a python method -> no problem with backward compability
Expand Down