-
Notifications
You must be signed in to change notification settings - Fork 5k
Minor tensor fixes #115125
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
Minor tensor fixes #115125
Conversation
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
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 addresses minor tensor fixes by updating exception naming, improving generic parameter handling in tensor operations, and refining validation logic in tensor transformation methods.
- Renamed exception methods and updated messages from "InvalidAxis" to "InvalidDimension".
- Modified generic parameters and overloads in TensorOperation for improved type consistency.
- Adjusted validation and update logic in Tensor methods (concatenation, reshape, filtered updates, permutation, and stacking).
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/libraries/System.Numerics.Tensors/src/System/ThrowHelper.cs | Renamed throw helper methods and updated error messages. |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorOperation.cs | Updated generic parameters and added a new overload for binary operations as well as refining filtered update mechanics. |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs | Revised concatenation, reshape, update, permutation, and stacking methods with updated validation and delegation improvements. |
Files not reviewed (1)
- src/libraries/System.Numerics.Tensors/src/Resources/Strings.resx: Language not supported
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorOperation.cs
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorOperation.cs
Show resolved
Hide resolved
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.
Left minor comments/suggestion. LGTM otherwise.
Please ensure fixing the issue raised by the copilot.
…ors/netcore/Tensor.cs Co-authored-by: Copilot <[email protected]>
…ors/netcore/Tensor.cs Co-authored-by: Copilot <[email protected]>
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs
Show resolved
Hide resolved
{ | ||
totalLength += (int)tensors[i].FlattenedLength; | ||
} | ||
} | ||
|
||
tensor = Tensor.Create<T>([totalLength]); |
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.
Don't think this is correct and it's now calling the Tensor.Create<T>(T[] array)
overload, rather than the Tensor.Create<T>(scoped ReadOnlySpan<nint> lengths, bool pinned = false)
overload
I think this should stay nint
and we can rely on Tensor.Create<T>(scoped ReadOnlySpan<nint> lengths, bool pinned = false)
validating that it can be allocated by the underlying tensor storage.
We just need to ensure that adding the combined tensors flattened lengths together doesn't overflow the nint
.
I also think that this represents a UX issue with the Create
APIs.
I think we may want to disambiguate as CreateFromShape
or similar so that a user passing in an nint[]
isn't confused on whether its going to create a Tensor<nint>
or a Tensor<T>
where nint
is the lengths.
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.
Fixed back to nint.
But it still was calling the right overload, not the Tensor.Create<T>(T[] array)
one since T != int.
/azp build-analysis |
Command 'build-analysis' is not supported by Azure Pipelines. Supported commands
See additional documentation. |
/azp run build-analysis |
No pipelines are associated with this pull request. |
/ba-g unrelated test failure and build-analysis isn't finishing for some reason. |
There were some minor nit suggestions from #114927, this pr fixes all those suggestions.