Skip to content
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

System.Numerics.Tensors Non-monotonic constructor errors #106538

Closed
soerenwolfers opened this issue Aug 16, 2024 · 3 comments · Fixed by #107427
Closed

System.Numerics.Tensors Non-monotonic constructor errors #106538

soerenwolfers opened this issue Aug 16, 2024 · 3 comments · Fixed by #107427
Assignees
Labels
area-System.Numerics.Tensors in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@soerenwolfers
Copy link

Description

new TensorSpan<double>(new double[j], lengths: new IntPtr[] {2}, strides: new IntPtr[] {1}); 

throws a ArgumentException if j == 1 but not if j == 0 or j > 1.

Reproduction Steps

using System.Diagnostics.CodeAnalysis;
using System.Numerics.Tensors;

namespace ConsoleApp1;

public abstract class Program
{
	[Experimental("SYSLIB5001")]
	public static void Main()
	{
		new TensorSpan<double>(new double[0], lengths: new IntPtr[] {2}, strides: new IntPtr[] {1});
		new TensorSpan<double>(new double[2], lengths: new IntPtr[] {2}, strides: new IntPtr[] {1});
		new TensorSpan<double>(new double[1], lengths: new IntPtr[] {2}, strides: new IntPtr[] {1}); 
	}
}

Expected behavior

Error when j <= 1

Actual behavior

Error if and only if j == 1

Regression?

No response

Known Workarounds

No response

Configuration

.NET8, Ubuntu22, x64

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 16, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

@stephentoub stephentoub added this to the 9.0.0 milestone Aug 16, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Aug 16, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics-tensors
See info in area-owners.md if you want to be subscribed.

@michaelgsharp
Copy link
Member

Ok, this should throw when j = 0 || j = 1, but not when j > 1. I'll fix the 0 case. As long as there is enough backing memory its ok if there is more backing memory than the lengths/span can actually access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Numerics.Tensors in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants