dlpack
dlpack copied to clipboard
[feature request] Example wrapper for C#
A related issue in onnxruntime: https://github.com/microsoft/onnxruntime/issues/4162. Not sure where this feature request should belong
There is DenseTensor type in Microsoft ML/onnxruntime. It would be good to have standard example wrapper for converting to and from DLPack. Then users could use the provided structs in their own C# wrappers for their own C function wrappers that accept or return DLPack tensors
A good example of this could be onnxruntime wrapper for C#: https://github.com/microsoft/onnxruntime/blob/3530ce541cbb66f05e523f92b62cebaa4793bd3f/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.cs and https://github.com/microsoft/onnxruntime/tree/3530ce541cbb66f05e523f92b62cebaa4793bd3f/csharp/src/Microsoft.ML.OnnxRuntime
(I may upload a sample wrapper later on, but I don't have it yet)
Given that DLPack interface is quite simple, it may be as easy as running automated clang-based C# binding generator https://github.com/microsoft/ClangSharp/tree/master/sources/ClangSharpPInvokeGenerator
here is a limited example of such bindings: https://github.com/vadimkantorov/dotnetdlpack