Repository navigation
Fix TimeDistributed for non-contiguous sequence batches - #1220
Merged
bruAristimunha merged 6 commits intoOct 5, 2026
Merged
bruAristimunha merged 6 commits into
bruAristimunha merged 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1220 +/- ##
=======================================
Coverage 87.79% 87.79%
=======================================
Files 149 149
Lines 17462 17462
=======================================
Hits 15330 15330
Misses 2132 2132 🚀 New features to boost your workflow:
|
Resolved docs/whats_new.rst by keeping both changelog entries.
bruAristimunha
approved these changes
Oct 4, 2026
bruAristimunha
left a comment
Collaborator
There was a problem hiding this comment.
Thanks. Reproduced the non-contiguous batch failure on master, verified the fix keeps contiguous inputs bit-identical for all TimeDistributed callers. CI green.
Resolved docs/whats_new.rst by keeping both changelog entries.
bruAristimunha
approved these changes
Oct 5, 2026
bruAristimunha
left a comment
Collaborator
There was a problem hiding this comment.
Thanks. Reproduced the non-contiguous batch failure on master, verified the fix keeps contiguous inputs bit-identical for all TimeDistributed callers. Tests green; the only red check is the Codecov upload (codecov.io SSL error, infra).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
TimeDistributedaccept non-contiguous input tensors by usingreshapeinstead of requiringview-compatible strides.Root cause
TimeDistributed.forward()currently flattens and restores the batch/sequence axes with.view(...). A tensor can have the documented shape(batch, seq, channels, time)while being non-contiguous—for example after a transpose or other layout-preserving upstream operation. In that case.viewraises even though the tensor shape is otherwise valid for the layer.Fix
Use
.reshapefor both the flatten and restore operations. Contiguous inputs keep the same behavior; non-contiguous inputs are copied only when required by the underlying strides.Regression
The test constructs a non-contiguous tensor whose shape remains
(4, 4, 3, 10), verifies the current view path is not required, and checks thatTimeDistributed(nn.Identity())returns(4, 4, 30)with the expected values.Independent CPU reproduction:
RuntimeError: view size is not compatible with input tensor's size and stride;AI assistance was used to audit the tensor-layout boundary and prepare the patch; the change is limited to layout handling plus regression coverage.