Skip to content

Commit eb3bd73

Browse files
pedrocolon93pedro
and
pedro
authored
Bug fix for modeling utilities function: apply_chunking_to_forward, chunking should be in the chunking dimension, an exception was raised if the complete shape of the inputs was not the same rather than only the chunking dimension (#8391)
Co-authored-by: pedro <pe25171@mit.edu>
1 parent 70708cc commit eb3bd73

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/transformers/modeling_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,9 +1668,9 @@ def forward(self, hidden_states):
16681668
"""
16691669

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

16761676
# inspect.signature exist since python 3.5 and is a python method -> no problem with backward compatibility

0 commit comments

Comments
 (0)