Aleator.Torch
0.5.1
dotnet add package Aleator.Torch --version 0.5.1
NuGet\Install-Package Aleator.Torch -Version 0.5.1
<PackageReference Include="Aleator.Torch" Version="0.5.1" />
<PackageVersion Include="Aleator.Torch" Version="0.5.1" />
<PackageReference Include="Aleator.Torch" />
paket add Aleator.Torch --version 0.5.1
#r "nuget: Aleator.Torch, 0.5.1"
#:package Aleator.Torch@0.5.1
#addin nuget:?package=Aleator.Torch&version=0.5.1
#tool nuget:?package=Aleator.Torch&version=0.5.1
Aleator.Torch
Optional TorchSharp bridge for Aleator, the C# port of the Figaro probabilistic programming library.
TorchDifferentiableTarget(dimension, tensorProgram)wraps any TorchSharp tensor program as anIDifferentiableTarget, so Aleator's gradient engines (HMC / NUTS / ADVI / SVGD from Aleator.AutoDiff) consume libtorch log-densities — including neural-network likelihoods and VAE-style amortised encoders.TorchModuleTarget(module, logDensity, includeBuffers)wraps atorch.nn.Module's parameters (and optional buffers) as anIDifferentiableTarget, withLoadPoint(theta)to write parameter vectors back into the module.TorchTensors(ToTensor,ToPosteriorSamples) converts betweenPosteriorSamplesand 2-Dfloat64tensors.TorchProbe.Describe()— native-backend smoke check.
using Aleator.AutoDiff;
using Aleator.Torch;
using Aleator.Util;
using static TorchSharp.torch;
var target = new TorchDifferentiableTarget(3, theta => -0.5 * (theta * theta).sum());
var nuts = new NoUTurnSampler(target, random: new DefaultRandomSource(42));
Each bridge call owns and disposes the input tensor and all callback temporaries. Tensors captured by the callback
(for example model parameters or fixed data) remain caller-owned. Gradient evaluation uses input-only
autograd.grad, so it does not accumulate .grad on captured trainable tensors.
Carries the heavy TorchSharp + libtorch-cpu native dependency (hundreds of MB) — reference it
only when you need the bridge. Excluded from NativeAOT publishes by design.
For a CUDA host, use Aleator.Torch.Managed and the matching libtorch CUDA runtime.
Documentation: atalib.com/docs. Runnable examples (torch-bridge, amortised-vi): atalib.com/examples.html.
Questions, bug reports and feedback: contact the maintainers through nuget.org. The source repository is
private, so there is no public issue tracker yet. Report a suspected vulnerability the same way, with SECURITY: at the
start of the subject, and do not disclose it publicly before it is fixed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Aleator.AutoDiff (>= 0.5.1)
- Aleator.Core (>= 0.5.1)
- libtorch-cpu (>= 2.10.0)
- System.Numerics.Tensors (>= 10.0.15)
- TorchSharp (>= 0.107.0)
-
net8.0
- Aleator.AutoDiff (>= 0.5.1)
- Aleator.Core (>= 0.5.1)
- libtorch-cpu (>= 2.10.0)
- System.Numerics.Tensors (>= 10.0.15)
- TorchSharp (>= 0.107.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.1 | 93 | 11/21/2026 |
| 0.4.1 | 107 | 11/12/2026 |
| 0.3.0-preview.1 | 138 | 9/6/2026 |