Commit 587ec72
Open Source Contributor
Fix IndexError in sdpa_mask and flex_attention_mask for 0D tensors during ONNX export
Fix for Issue #45735
When torch.onnx.export is called with ModernBERT, cache_position can be
passed as a 0-dimensional tensor (scalar), causing IndexError when
accessing cache_position.shape[0] or cache_position[0].
This fix handles the 0D tensor case by unsqueezing to 1D before
extracting shape and offset information.1 parent 5c1c72b commit 587ec72
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| 480 | + | |
| 481 | + | |
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
| |||
660 | 662 | | |
661 | 663 | | |
662 | 664 | | |
| 665 | + | |
| 666 | + | |
663 | 667 | | |
664 | 668 | | |
665 | 669 | | |
| |||
0 commit comments