This is an alternate binding library for LibTorchSharp, the native library portion of TorchSharp.
The library is fully functional right now, but there are a few issues that need resolved before an inital release.
This opinionated library requires unwavering vigilance to memory management, in exchange for maximum performance. Here be dragons.
This library is built targeting .NET 10, while TorchSharp multi-targets older versions, including .NET Standard 2.0.
TorchSharp relies on the garbage collector to protect against native memory leaks. This library eliminates managed allocations by relying on users to dispose any native objects they create.
using Tensor tensor = new Tensor([1, 2, 3]);This library exposes the native API directly and also offers a more user-friendly layer over top of that. TorchSharp is high-level and tries to mirror the PyTorch API almost exactly.
Most of this library is procedurally generated.
- ClangSharp is used to generate the low-level interop code.
- A custom Roslyn source generator is used to create a mid-level layer on top of the interop code.
Procedurally generated code is not documented in this library. Users should refer to the TorchSharp source code or the official PyTorch documentation.