Skip to content

Reject zero-length sequences in LSTM/GRU with a clear message - #78

Merged
CanReader merged 1 commit into
CanReader:masterfrom
sharmis-tp:fix/zero-length-seq-27
Nov 12, 2026
Merged

CanReader merged 1 commit into
CanReader:masterfrom
sharmis-tp:fix/zero-length-seq-27

Conversation

@sharmis-tp

Copy link
Copy Markdown
Contributor

Summary

  • Assert steps > 0 in check_sequence so a zero-length sequence panics with a message naming the layer and shape, instead of propagating to cat: needs at least one tensor
  • Add stack: needs at least one tensor assert in Tensor::stack so an empty stack also has its own message
  • Add #[should_panic] tests for LSTM, GRU with [1, 0, 2] input, and for Tensor::stack(&[], 0)

All 41 existing tests pass.

Closes #27

@CanReader
CanReader force-pushed the fix/zero-length-seq-27 branch from 92f427e to cedef5a Compare November 12, 2026 08:47
@CanReader
CanReader merged commit 208aaae into CanReader:master Nov 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero length sequences panic with a message about cat

2 participants