-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Tensor<T> select. Iteration along dimensions #113697
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
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
My comments on the new API: |
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs
Outdated
Show resolved
Hide resolved
@michaelgsharp what's the state of this PR? Are you returning to it, or is it no longer necessary? |
195e6a7
to
9abdc41
Compare
5c8970d
to
03a0e08
Compare
03a0e08
to
7a0bafe
Compare
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 introduces new slicing and selection operations for Tensor by adding methods such as SliceAlongDimension and Select, as well as new types for iterating along tensor dimensions. Key changes include new unit tests for dimension slicing, additions to the Tensor and TensorSpan implementations to support GetDimensionSpan, and corresponding project file and suppression updates.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/TensorDimensionSpanTests.cs | Added thorough tests for dimension slicing on tensors in various shapes |
src/System/Numerics/Tensors/netcore/Tensor_1.cs | New GetDimensionSpan method and tweak in IDisposable.Dispose implementation |
src/System/Numerics/Tensors/netcore/TensorSpan_1.cs | Added GetDimensionSpan method for TensorSpan |
src/System/Numerics/Tensors/netcore/TensorShape.cs | Added AdjustToNextIndex and updated GetLinearOffset methods using DivRem |
src/System/Numerics/Tensors/netcore/TensorDimensionSpan_1.cs | New implementation of TensorDimensionSpan for slicing a tensor along a given dimension |
csproj and CompatibilitySuppressions.xml | Updated to include the new files and suppress expected compatibility diagnostics |
Comments suppressed due to low confidence (1)
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorDimensionSpan_1.cs:25
- Consider adding a clarifying comment here to explain why the 'dimension' parameter is incremented, which would help improve readability and understanding of the slicing logic.
dimension += 1;
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.
Looks good for the most part - shared a suggestion to cleanup suppressions and bring ref up to date.
/// <summary>Enumerates the spans of a tensor dimension span.</summary> | ||
public ref struct Enumerator | ||
#if NET9_0_OR_GREATER | ||
: IEnumerator<ReadOnlyTensorSpan<T>> |
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.
Should this implement other interfaces in older TFMs?
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.
What other interfaces would it implement?
src/libraries/System.Numerics.Tensors/src/CompatibilitySuppressions.xml
Outdated
Show resolved
Hide resolved
/ba-g unrelated failures |
Fixes #113068 and fixes #113863
Adds a new method,
SliceAlongDimension
, that lets you slice any given subdimension out of a tensor.Adds a new method,
Select
, that lets you runTensor
operations on segments of theTensor
instead of the wholeTensor
.Adds a
DimensionCollection
, which is similar to a Dictionary's KeyCollection, in that it has anEnumerator
that lets you iterate over theTensor
along a given dimension (compared to the KeyCollection that lets you iterate by the keys).