[release/11.0-rc1] Fix duplicate _start offset in Tensor.Resize - #132472
Merged
tannergooding merged 1 commit intoAug 19, 2026
Conversation
Closes #128512 This PR fix the offset used when creating a `ReadOnlySpan<T>` that starts at `_start` in `Tensor.Resize`. `AsTensorSpan()._reference` already includes the `_start` offset, so applying it again via `Unsafe.Add` caused the span to start at the wrong position. Changes: - Remove `Unsafe.Add` when creating a `ReadOnlySpan<T>` - Change from `tensor.AsTensorSpan` to `Tensor.AsReadOnlyTensorSpan` to match `Tensor.ResizeTo` - Use `(int)tensor.FlattenedLength` instead of `tensor._values.Length - tensor._start`
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
artl93
approved these changes
Aug 18, 2026
artl93
left a comment
Member
There was a problem hiding this comment.
Regression. Basic functionality along the lines of "we should do math right". Approved.
4 tasks
Member
|
/ba-g System.Net.HttpListener.Tests timeouts |
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.
Backport of #128511 to
release/11.0-rc1.Closes #128512
/cc @tannergooding @prozolic
Customer Impact
Tensor.Resizereturns incorrect values when resizing a dense tensor whosestartis greater than zero. For example, resizing a tensor representing[3, 4, 5, 6]returns[5, 6, 0, 0]because the start offset is applied twice.Regression
Introduced by #114927, which added the affected
Tensor.Resizeimplementation.Testing
Added
TensorResizeWithStartTestscovering tensors with a nonzero start when resizing to the same size, growing, shrinking, and changing rank. The original fix in #128511 completed CI successfully.Risk
Low. The production change only removes the duplicate offset and uses the existing read-only tensor span and flattened length, matching the approach already used by
Tensor.ResizeTo. No public API surface changes.Note
This description was drafted with GitHub Copilot.