Skip to content

Commit 4314ca3

Browse files
authored
Tensor doc improvements (#116562)
1 parent 953ccfb commit 4314ca3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/IReadOnlyTensor.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ public interface IReadOnlyTensor
2626
/// <summary>Gets the total number of items in the tensor.</summary>
2727
nint FlattenedLength { get; }
2828

29-
/// <summary>Determines if the current tensor has any dimension where <c>GetDimensionSpan(int)</c> will iterate through tensors that would have <see cref="IsDense" /> be <c>true</c>.</summary>
29+
/// <summary>Gets a value that indicates whether the current tensor has any dimension span where <see cref="IsDense" /> is <see langword="true"/>.</summary>
30+
/// <value><see langword="true"/> if this tensor has any dense dimensions; otherwise, <see langword="false"/>.</value>
3031
/// <remarks>
31-
/// <para>This does not include the last dimension, <c>GetDimensionSpan(Rank - 1)</c>, as it always iterates 1 element at a time and would mean this property always returns true.</para>
32-
/// <para>An example of a tensor which is not dense but which would have a dense dimension is a 2x2 Tensor where <c>FlattenedLength: 4; Lengths: [2, 2]; Strides: [4, 1]</c>. In such a scenario, the overall tensor is not dense because the backing storage has a length of at least 6 and so has 2 used elements, 2 unused elements, followed by the last 2 used elements. However, the two slices representing <c>[0..1, ..]</c> and <c>[1..2, ..]</c> would themselves be dense; thus <c>GetDimension(0).GetSlice(n)</c> will iterate dense tensors: <c>FlattenedLength: 2, Length: [2], Strides: [1]</c>.</para>
32+
/// <para>This does not include the last dimension, <c>GetDimensionSpan(Rank - 1)</c>, as it always iterates one element at a time and would mean this property always returns <see langword="true"/>.</para>
33+
/// <para>An example of a tensor that's not dense but has a dense dimension is a 2x2 Tensor where <c>FlattenedLength: 4; Lengths: [2, 2]; Strides: [4, 1]</c>. In such a scenario, the overall tensor is not dense because the backing storage has a length of at least 6. It has two used elements, two unused elements, followed by the last two used elements. However, the two slices representing <c>[0..1, ..]</c> and <c>[1..2, ..]</c> are dense; thus <c>GetDimension(0).GetSlice(n)</c> will iterate dense tensors: <c>FlattenedLength: 2, Length: [2], Strides: [1]</c>.</para>
3334
/// </remarks>
3435
bool HasAnyDenseDimensions { get; }
3536

36-
/// <summary>Determines if the current tensor is dense.</summary>
37+
/// <summary>Gets a value that indicates whether the current tensor is dense.</summary>
38+
/// <value><see langword="true"/> if this tensor is dense; otherwise, <see langword="false"/>.</value>
3739
/// <remarks>
3840
/// <para>A dense tensor is one where the elements are ordered sequentially in memory and where no gaps exist between the elements.</para>
39-
/// <para>For a 2x2 Tensor, this would mean it has <c>FlattenedLength: 4; Lengths: [2, 2]; Strides: [2, 1]</c>. The elements would be sequentially accessed via indexes: <c>[0, 0]; [0, 1]; [1, 0]; [1, 1]</c></para>
41+
/// <para>For a 2x2 Tensor, this would mean it has <c>FlattenedLength: 4; Lengths: [2, 2]; Strides: [2, 1]</c>. The elements would be sequentially accessed via indexes: <c>[0, 0]; [0, 1]; [1, 0]; [1, 1]</c>.</para>
4042
/// </remarks>
4143
bool IsDense { get; }
4244

src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/IReadOnlyTensor_1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public interface IReadOnlyTensor<TSelf, T> : IReadOnlyTensor, IEnumerable<T>
9191
/// <returns>The current tensor if it is already dense; otherwise, a new tensor that contains the elements of this tensor.</returns>
9292
/// <remarks>
9393
/// <para>A dense tensor is one where the elements are ordered sequentially in memory and where no gaps exist between the elements.</para>
94-
/// <para>For a 2x2 Tensor, this would mean it has <c>FlattendLength: 4; Lengths: [2, 2]; Strides: [4, 1]</c>. The elements would be sequentially accessed via indexes: <c>[0, 0]; [0, 1]; [1, 0]; [1, 1]</c></para>
94+
/// <para>For a 2x2 Tensor, this would mean it has <c>FlattendLength: 4; Lengths: [2, 2]; Strides: [4, 1]</c>. The elements would be sequentially accessed via indexes: <c>[0, 0]; [0, 1]; [1, 0]; [1, 1]</c>.</para>
9595
/// </remarks>
9696
TSelf ToDenseTensor();
9797

0 commit comments

Comments
 (0)