dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

System.Numerics.Tensors Inconsistent TryFlattenTo & TryBroadcastTo vs TryCopyTo #106537

Open soerenwolfers opened 4 weeks ago

soerenwolfers commented 4 weeks ago

Description

TryFlattenTo and TryBroadcastTo throw when destination is too short, TryCopyTo returns false.

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[1]).TryCopyTo(Array.Empty<double>());
        new TensorSpan<double>(new double[1]).TryFlattenTo(Array.Empty<double>());
    }
}

Expected behavior

Return false; never throw.

Actual behavior

ArgumentException

Regression?

No response

Known Workarounds

No response

Configuration

.Net8, Ubuntu22, x64

Other information

No response

dotnet-policy-service[bot] commented 4 weeks ago

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

dotnet-policy-service[bot] commented 4 weeks ago

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