-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[API Proposal]: GetPinnedHandle #111966
Comments
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
We may want to consider if this should instead be |
I'd prefer if this were to use |
@jkoritzinsky, just to clarify you mean the We do have need for |
Yep! I didn't realize that the proposal was extending an existing interface instead of declaring a new one (I usually make my API proposals diffs to avoid this confusion, so I missed that). |
Background and motivation
Tensors were designed to be able to be used in a
fixed
statement. This is great for performance, but there are times when we need the data to be fixed but using it in afixed
statement will not work. Currently, when you create a tensor you can have the GC actually pin the underlying memory, but once the tensor has been created we have no way of pinning it after the fact. We need to expose a way to allow the underlying memory be GC pinned for the cases that afixed
statement wont work.API Proposal
API Usage
Alternative Designs
One other thought would be to put this in
System.Runtime.InteropServices;
like we haveCollectionMarshal
we could add aTensorMarshal
so that its only used whenfixed
really will not work.Risks
This would be a new api in a preview object, so the risks are very minimal.
The text was updated successfully, but these errors were encountered: