-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Description
Description
Tensor.StdDev does not handle non-contiguous input.
The method uses
Reproduction Steps
using System.Numerics.Tensors;
// Create 4x4 matrix with upper-left 2x2 matrix
var t = Tensor.Create<double>([4, 4]);
t[[0, 0]] = 1;
t[[0, 1]] = 1;
t[[1, 0]] = 1;
t[[1, 1]] = 1;
// Take slice of upper left 2x2 matrix
var t1 = t.Slice([0..2, 0..2]); // This makes a copy so it is contiguous
var t2 = t.AsReadOnlyTensorSpan().Slice([0..2, 0..2]); // Refers to original span, i.e. non-cotiguous.
// Should print 0 (StdDev of all ones)
Console.WriteLine(Tensor.StdDev<double>(t1));
Console.WriteLine(Tensor.StdDev<double>(t2));Expected behavior
Both print statements should print 0.
Actual behavior
First print statement prints 0.
Second print throws: System.ArgumentException: 'Destination is too short. Arg_ParamName_Name'
Regression?
No response
Known Workarounds
No response
Configuration
.NET 9
Other information
No response
Metadata
Metadata
Assignees
Labels
area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged