dlpack icon indicating copy to clipboard operation
dlpack copied to clipboard

[feature request] Example wrapper for C#

Open vadimkantorov opened this issue 5 years ago • 2 comments
trafficstars

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)

vadimkantorov avatar Aug 17 '20 11:08 vadimkantorov

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

vadimkantorov avatar Aug 17 '20 12:08 vadimkantorov

here is a limited example of such bindings: https://github.com/vadimkantorov/dotnetdlpack

vadimkantorov avatar Aug 17 '20 17:08 vadimkantorov