Skip to content

Mark some Tensor extension methods as scoped #115575

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
merged 2 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ public static void BroadcastTo<T>(this System.Numerics.Tensors.Tensor<T> source,
public static ref readonly System.Numerics.Tensors.TensorSpan<T> RadiansToDegrees<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.ITrigonometricFunctions<T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> Reciprocal<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IFloatingPoint<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Reciprocal<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IFloatingPoint<T> { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Reshape<T>(this in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, scoped System.ReadOnlySpan<nint> lengths) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Reshape<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor, scoped System.ReadOnlySpan<nint> lengths) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Reshape<T>(this scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, scoped System.ReadOnlySpan<nint> lengths) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Reshape<T>(this scoped in System.Numerics.Tensors.TensorSpan<T> tensor, scoped System.ReadOnlySpan<nint> lengths) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Reshape<T>(this System.Numerics.Tensors.Tensor<T> tensor, scoped System.ReadOnlySpan<nint> lengths) { throw null; }
public static void ResizeTo<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, in System.Numerics.Tensors.TensorSpan<T> destination) { }
public static void ResizeTo<T>(scoped in System.Numerics.Tensors.TensorSpan<T> tensor, in System.Numerics.Tensors.TensorSpan<T> destination) { }
Expand Down Expand Up @@ -511,11 +511,11 @@ public static void ResizeTo<T>(scoped in System.Numerics.Tensors.Tensor<T> tenso
public static System.Numerics.Tensors.Tensor<T>[] Split<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, int splitCount, nint dimension) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Sqrt<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IRootFunctions<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Sqrt<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IRootFunctions<T> { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> SqueezeDimension<T>(this in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> SqueezeDimension<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> SqueezeDimension<T>(this scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> SqueezeDimension<T>(this scoped in System.Numerics.Tensors.TensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.Tensor<T> SqueezeDimension<T>(this System.Numerics.Tensors.Tensor<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Squeeze<T>(this in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Squeeze<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Squeeze<T>(this scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Squeeze<T>(this scoped in System.Numerics.Tensors.TensorSpan<T> tensor) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Squeeze<T>(this System.Numerics.Tensors.Tensor<T> tensor) { throw null; }
public static System.Numerics.Tensors.Tensor<T> StackAlongDimension<T>(int dimension, params scoped System.ReadOnlySpan<System.Numerics.Tensors.Tensor<T>> tensors) { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> StackAlongDimension<T>(scoped System.ReadOnlySpan<System.Numerics.Tensors.Tensor<T>> tensors, in System.Numerics.Tensors.TensorSpan<T> destination, int dimension) { throw null; }
Expand Down Expand Up @@ -546,8 +546,8 @@ public static void ResizeTo<T>(scoped in System.Numerics.Tensors.Tensor<T> tenso
public static bool TryBroadcastTo<T>(this in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, in System.Numerics.Tensors.TensorSpan<T> destination) { throw null; }
public static bool TryBroadcastTo<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor, in System.Numerics.Tensors.TensorSpan<T> destination) { throw null; }
public static bool TryBroadcastTo<T>(this System.Numerics.Tensors.Tensor<T> tensor, in System.Numerics.Tensors.TensorSpan<T> destination) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Unsqueeze<T>(this in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Unsqueeze<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.ReadOnlyTensorSpan<T> Unsqueeze<T>(this scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.TensorSpan<T> Unsqueeze<T>(this scoped in System.Numerics.Tensors.TensorSpan<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Unsqueeze<T>(this System.Numerics.Tensors.Tensor<T> tensor, int dimension) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Xor<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y) where T : System.Numerics.IBitwiseOperators<T, T, T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Xor<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IBitwiseOperators<T, T, T> { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ public static Tensor<T> Reshape<T>(this Tensor<T> tensor, ReadOnlySpan<nint> len
/// </summary>
/// <param name="tensor"><see cref="TensorSpan{T}"/> you want to reshape.</param>
/// <param name="lengths"><see cref="ReadOnlySpan{T}"/> with the new dimensions.</param>
public static TensorSpan<T> Reshape<T>(in this TensorSpan<T> tensor, scoped ReadOnlySpan<nint> lengths)
public static TensorSpan<T> Reshape<T>(this scoped in TensorSpan<T> tensor, scoped ReadOnlySpan<nint> lengths)
{
if (tensor.Lengths.SequenceEqual(lengths))
return tensor;
Expand Down Expand Up @@ -1584,7 +1584,7 @@ public static TensorSpan<T> Reshape<T>(in this TensorSpan<T> tensor, scoped Read
/// </summary>
/// <param name="tensor"><see cref="TensorSpan{T}"/> you want to reshape.</param>
/// <param name="lengths"><see cref="ReadOnlySpan{T}"/> with the new dimensions.</param>
public static ReadOnlyTensorSpan<T> Reshape<T>(in this ReadOnlyTensorSpan<T> tensor, scoped ReadOnlySpan<nint> lengths)
public static ReadOnlyTensorSpan<T> Reshape<T>(this scoped in ReadOnlyTensorSpan<T> tensor, scoped ReadOnlySpan<nint> lengths)
{
if (tensor.Lengths.SequenceEqual(lengths))
return tensor;
Expand Down Expand Up @@ -1983,7 +1983,7 @@ public static Tensor<T> SqueezeDimension<T>(this Tensor<T> tensor, int dimension
/// Removes all dimensions of length one from the <paramref name="tensor"/>.
/// </summary>
/// <param name="tensor">The <see cref="TensorSpan{T}"/> to remove all dimensions of length 1.</param>
public static TensorSpan<T> Squeeze<T>(in this TensorSpan<T> tensor)
public static TensorSpan<T> Squeeze<T>(this scoped in TensorSpan<T> tensor)
{
return SqueezeDimension(tensor, -1);
}
Expand All @@ -1994,7 +1994,7 @@ public static TensorSpan<T> Squeeze<T>(in this TensorSpan<T> tensor)
/// </summary>
/// <param name="tensor">The <see cref="TensorSpan{T}"/> to remove dimension of length 1.</param>
/// <param name="dimension">The dimension to remove.</param>
public static TensorSpan<T> SqueezeDimension<T>(in this TensorSpan<T> tensor, int dimension)
public static TensorSpan<T> SqueezeDimension<T>(this scoped in TensorSpan<T> tensor, int dimension)
{
if (dimension >= tensor.Rank || dimension < -1)
ThrowHelper.ThrowArgument_AxisLargerThanRank();
Expand Down Expand Up @@ -2065,7 +2065,7 @@ public static TensorSpan<T> SqueezeDimension<T>(in this TensorSpan<T> tensor, in
/// Removes all dimensions of length one from the <paramref name="tensor"/>.
/// </summary>
/// <param name="tensor">The <see cref="ReadOnlyTensorSpan{T}"/> to remove all dimensions of length 1.</param>
public static ReadOnlyTensorSpan<T> Squeeze<T>(in this ReadOnlyTensorSpan<T> tensor)
public static ReadOnlyTensorSpan<T> Squeeze<T>(this scoped in ReadOnlyTensorSpan<T> tensor)
{
return SqueezeDimension(tensor, -1);
}
Expand All @@ -2076,7 +2076,7 @@ public static ReadOnlyTensorSpan<T> Squeeze<T>(in this ReadOnlyTensorSpan<T> ten
/// </summary>
/// <param name="tensor">The <see cref="ReadOnlyTensorSpan{T}"/> to remove dimension of length 1.</param>
/// <param name="dimension">The dimension to remove.</param>
public static ReadOnlyTensorSpan<T> SqueezeDimension<T>(in this ReadOnlyTensorSpan<T> tensor, int dimension)
public static ReadOnlyTensorSpan<T> SqueezeDimension<T>(this scoped in ReadOnlyTensorSpan<T> tensor, int dimension)
{
if (dimension >= tensor.Rank || dimension < -1)
ThrowHelper.ThrowArgument_AxisLargerThanRank();
Expand Down Expand Up @@ -2467,7 +2467,7 @@ public static Tensor<T> Unsqueeze<T>(this Tensor<T> tensor, int dimension)
/// </summary>
/// <param name="tensor">The <see cref="TensorSpan{T}"/> to add a dimension of length 1.</param>
/// <param name="dimension">The index of the dimension to add.</param>
public static TensorSpan<T> Unsqueeze<T>(in this TensorSpan<T> tensor, int dimension)
public static TensorSpan<T> Unsqueeze<T>(this scoped in TensorSpan<T> tensor, int dimension)
{
if (dimension > tensor.Lengths.Length)
ThrowHelper.ThrowArgument_AxisLargerThanRank();
Expand Down Expand Up @@ -2504,7 +2504,7 @@ public static TensorSpan<T> Unsqueeze<T>(in this TensorSpan<T> tensor, int dimen
/// </summary>
/// <param name="tensor">The <see cref="ReadOnlyTensorSpan{T}"/> to add a dimension of length 1.</param>
/// <param name="dimension">The index of the dimension to add.</param>
public static ReadOnlyTensorSpan<T> Unsqueeze<T>(in this ReadOnlyTensorSpan<T> tensor, int dimension)
public static ReadOnlyTensorSpan<T> Unsqueeze<T>(this scoped in ReadOnlyTensorSpan<T> tensor, int dimension)
{
if (dimension > tensor.Lengths.Length)
ThrowHelper.ThrowArgument_AxisLargerThanRank();
Expand Down
Loading