-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix the formatting of the tensor ToString functions #118750
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
Conversation
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.
Pull Request Overview
This PR fixes the formatting of the ToString methods for tensor types to improve readability and provide better structured output. The previous implementation produced incorrectly formatted strings that were difficult to read, mixing type information with content formatting in an inconsistent way.
Key changes include:
- Refactored ToString implementation to centralize formatting logic across all tensor types
- Fixed shape representation to use comma-separated dimensions instead of TensorShape object representation
- Added proper indentation and structure for multi-dimensional tensor content display
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor_1.cs |
Simplified ToString methods to delegate to centralized formatting logic |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan_1.cs |
Updated ToString methods to use centralized formatting with proper type name |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan_1.cs |
Added comprehensive ToString overload with documentation and delegated to centralized logic |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs |
Complete rewrite of ToString formatting logic with proper indentation and structure |
src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs |
Updated API surface to reflect new ToString method signatures |
src/libraries/System.Numerics.Tensors/tests/TensorTests.cs |
Added comprehensive tests for ToString functionality across different scenarios |
src/libraries/System.Numerics.Tensors/tests/TensorSpanTests.cs |
Added comprehensive tests for TensorSpan ToString functionality |
src/libraries/System.Numerics.Tensors/tests/ReadOnlyTensorSpanTests.cs |
Added comprehensive tests for ReadOnlyTensorSpan ToString functionality |
|
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
|
@artl93 FYI - I'm merging this for RC1 as it meets the bug bar. |
The formatting was previously incorrect, resulting in output similar to:
The correct formatting is meant to be:
Explicit tests validating various scenarios were added.