-
Notifications
You must be signed in to change notification settings - Fork 5k
Mark the new tensor APIs as experimental for .NET 9 #105268
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
Mark the new tensor APIs as experimental for .NET 9 #105268
Conversation
Note regarding the
|
Note regarding the
|
@@ -6,6 +6,7 @@ | |||
|
|||
namespace System.Buffers | |||
{ | |||
[System.Diagnostics.CodeAnalysis.Experimental("SNTEXP0001")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC. @terrajobst, I don't think we have an existing format for these. So I've somewhat just followed what some other users (ASP.NET/Azure) are doing here.
Namely, SNT
for System.Numerics.Tensors
, then EXP
for Experimental
, then 0001
since this is the first ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording we get from this resembles:
SNTEXP0001: 'System.Numerics.Tensors.IReadOnlyTensor<System.Numerics.Tensors.Tensor<T>, T>' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@terrajobst Should we instead use SYSLIB5###
to follow suit of Obsoletions (SYSLIB0###
) and Analyzers (SYSLIB1###
) and leave plenty of room for analyzers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should stick to SYSLIB
for all diagnostics (obsoletions, experimental, and analyzers).
My concern with having separate prefixes is that it will be very inconsistent across all the parties. It's hard enough to come up with a prefix that is short enough and identifies a single party that can keep track of the numbers to avoid duplicates. Asking folks to have separate prefixes for obsoletions, experimental, and general purposes analyzers and have that scheme make sense across all parties, is a bit too much IMHO. And frankly it doesn't seem to add much more value to the consumer as the way a given diagnostic needs to be addressed often differs between different cases within the same category anyway. So the expectation is: read the message and follow the link if you need more information.
I don't have strong opinions on whether we should use numeric ranges for the different categories; if having separate ranges makes our lives easier (or is more consistent with what we have done before), then let's do that. If not, I don't think it's worth introducing though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Though it does seem to be failing some builds having that annotation there for some reason. |
// "aka.ms/dotnet-warnings/{0}" URL points to documentation for the API. | ||
// The diagnostic IDs reserved for experimental APIs are SYSLIB5### (SYSLIB5001 - SYSLIB5999). | ||
|
||
// When an API is no longer marked as experimental, the diagnostic ID should be removed from this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're using the markdown file as the source of truth for claiming new diagnostic IDs, what's the need for also consolidating them in source? IIRC we don't do this for other diagnostics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this with Obsoletions as well. I assert that it has helped keep the process discoverable and consistent.
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace System.Numerics.Tensors | ||
{ | ||
[Experimental(Experimentals.TensorTDiagId, UrlFormat = Experimentals.SharedUrlFormat)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to mark internal types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just the way the analyzer currently works. Presumably to ensure that consumers of those internal types are also aware that its using experimental features
/backport to release/9.0-preview7 |
Started backporting to release/9.0-preview7: https://github.com/dotnet/runtime/actions/runs/10069224280 |
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
Marking
Tensor<T>
as[Experimental]
Expanding .NET to provide built-in types for exchanging tensor data across libraries and allowing accelerated handling for core operations is an important but large undertaking. The work done in .NET 9 currently encompasses 8 types and nearly 600 new public APIs, many of which are generic and can support arbitrary T or T constrained to one of the generic math interfaces (see https://learn.microsoft.com/en-us/dotnet/standard/generics/math).
Due to the size of this work and the recognized importance of it to the long term growth of the .NET ecosystem, it has been decided to mark these new APIs as
[Experimental]
(see https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute) for .NET 9 and to plan on supporting them officially in .NET 10 instead. This is not being done due to a lack of confidence in the direction we're going, but rather is explictly being done to allow time for additional feedback from the community and important libraries in the .NET ecosystem that plan on taking advantage of the provided functionality. It also gives us additional time to coordinate with improvements to the C# language to ensure a great end-to-end experience.Call to Action
Please try out the new APIs and provide feedback on the overall experience. This includes (but is not limited to) the naming or shape of APIs, any core functionality that appears to be missing or that behaves unexpectedly, and how the general user experience was.
Some additional callouts include:
[Experimental]
much of the surface is relatively stable and isn't expectied to change, there isn't much you can get wrong for an API likeAdd(x, y)
after all. This isn't a guarantee that we won't change such APIs, but the expected churn for these ones is minimal.Tensor<T>
to work over allT
butoperator +
can only be defined for types that implement the generic mathIAdditionOperators
interface. This requires language support forextension operators
to achieve.TensorSpan<T>
types can wrap native allocations, but we don't have a non-ref struct type equivalent. Such a type would need to be disposable and needs additional design consideration around how ownership/lifetime tracking works. If this is an important scenario to you, we'd like to hear about it.TensorPrimitives
is stable and improvedAs a final note, the
TensorPrimitives
class which we shipped in .NET 8 is stable and has been expanded in .NET 9 with additional API surface that is also considered stable. It is the class that contains most of the accelerated algorithms that underpin theTensor<T>
type and so they can still be used to accelerate your code where applicable. There are many potential applications for these algorithms including in machine learning/AI, image processing, games, and beyond.