Skip to content

AssetRipper/AssetRipper.Bindings.LibTorchSharp

Repository files navigation

AssetRipper.Bindings.LibTorchSharp

This is an alternate binding library for LibTorchSharp, the native library portion of TorchSharp.

Current Status

The library is fully functional right now, but there are a few issues that need resolved before an inital release.

Differences from TorchSharp

This opinionated library requires unwavering vigilance to memory management, in exchange for maximum performance. Here be dragons.

.NET 10

This library is built targeting .NET 10, while TorchSharp multi-targets older versions, including .NET Standard 2.0.

Allocations

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]);

Level of abstraction

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.

Maintenance

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.

Documentation

Procedurally generated code is not documented in this library. Users should refer to the TorchSharp source code or the official PyTorch documentation.

About

Alternate bindings for LibTorchSharp

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published