8000 [MEGA] nit size test (#23028) · githubhjs/transformers@1933231 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 1933231

Browse files
ArthurZuckerArthurZuckerauthored
[MEGA] nit size test (huggingface#23028)
* add fast not use warning * properly check sequence_length vs chunk_size * fixup
1 parent a4908da commit 1933231

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/transformers/models/mega/modeling_mega.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,12 +1541,6 @@ def forward(
15411541
)
1542154 8000 2
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
15431543

1544-
if self.config.use_chunking and (input_ids.size(1) > self.config.chunk_size):
1545-
if input_ids.size(1) % self.config.chunk_size != 0:
1546-
raise ValueError(
1547-
f"config.use_chunking is activated; input sequence length must be shorter than or a multiple of config.chunk_size\nreceived sequence length of {input_ids.size(1)} with chunk size {self.config.chunk_size}"
1548-
)
1549-
15501544
if input_ids is not None and inputs_embeds is not None:
15511545
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
15521546
elif input_ids is not None:
@@ -1560,6 +1554,12 @@ def forward(
15601554

15611555
batch_size, sequence_length = input_shape
15621556

1557+
if self.config.use_chunking and (sequence_length > self.config.chunk_size):
1558+
if sequence_length % self.config.chunk_size != 0:
1559+
raise ValueError(
1560+
f"config.use_chunking is activated; input sequence length must be shorter than or a multiple of config.chunk_size\nreceived sequence length of {sequence_length} with chunk size {self.config.chunk_size}"
1561+
)
1562+
15631563
if self.config.is_decoder:
15641564
use_cache = use_cache if use_cache is not None else self.config.use_cache
15651565

0 commit comments

Comments
 (0)
0