-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/10.0] Fix Tensor.StdDev vs TensorPrimitives.StdDev differences for Complex input #119798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…nces for Complex input Co-authored-by: jeffhandley <[email protected]>
…input Co-authored-by: jeffhandley <[email protected]>
…tion - Fix typo: "TensorPrimitivers" -> "TensorPrimitives" in test comment - Replace custom SumOfSquaredMagnitudeDifferences operation with direct use of TensorPrimitives.StdDev - Leverage TensorPrimitives vectorization optimizations where T.Abs is only called when necessary - Remove unnecessary custom operation that always called T.Abs for all types - Use TryGetSpan for contiguous tensors and fallback to FlattenTo for non-contiguous tensors Co-authored-by: jeffhandley <[email protected]>
…lines Co-authored-by: jeffhandley <[email protected]>
…or non-essential methods and convert StdDev tests to Theory tests Co-authored-by: jeffhandley <[email protected]>
Added comment to clarify absolute value usage for complex numbers.
Co-authored-by: Copilot <[email protected]>
jeffhandley
approved these changes
Sep 17, 2025
|
@artl93 Seeking your approval of this backport to 10.0 RC2, with it meeting the bug bar as a broken scenario in a new API. |
artl93
approved these changes
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RC2 - we should do math correctly.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #119229 to release/10.0
/cc @jeffhandley @copilot
Customer Impact
As reported by a customer in Tensor.StdDev vs TensorPrimitives.StdDev differences for Complex input (dotnet/runtime#116133), the
Tensor.StdDevAPI being stablized in .NET 10 reports incorrect results for complex numbers, whileTensorPrimitives.StdDevproduces the correct results.Regression
This is a broken scenario on new APIs being marked as stable in .NET 10. The customer reported the issue against a preview, providing a repro that exhibited the incorrect results.
Testing
The customer's repro was used as the foundation for additional unit testing, with the tests verifying that
TensorandTensorPrimitivesproduce the same, expected results.Risk
Low. Only the new
Tensor.StdDevAPI is affected, and it now hasAbs(x - mean)logic matchingTensorPrimitivesbehavior. This algorithm also matches the behavior of other platforms' math libraries, including NumPy. The introduction of theAbscall will have a very minor perf hit, and approaches for avoiding that hit when unnecessary were discussed and ruled out as they would incur more substantial perf hits to conduct the check.