@cap/onnx
ONNX Runtime (v1.32.0) high-performance ML inference engine for CP via official prebuilt dynamic library
$ cap add @cap/onnx
AI Interface Stub .d.cp
No .d.cp AI interface stub published for this version.
README
Markdown@cap/onnx
High-performance cross-platform ML inference engine for CP, powered by Microsoft ONNX Runtime v1.32.0 (MIT License) using official prebuilt shared libraries (sys.onnxruntime.prebuilt) with zero local C++ build time.
Architecture
- Prebuilt Dynamic Library: Links directly against Microsoft's official
libonnxruntime(prebuilt/<os>-<arch>/libonnxruntime.{so,dylib,dll}), with automatic runtimeLD_LIBRARY_PATH/DYLD_LIBRARY_PATHinjection bycap run. - Thin C ABI Shim (
c/onnx_ffi.c): ~50-line bridge isolating CP from the large version-sensitiveOrtApifunction-table struct layout, compiled in <0.2s intolibonnx_shim.a. - Zero-Leak RAII (
src/index.cp): ProvidesOrtEnv,OrtSessionOptions, andversionString()with deterministic~init()cleanup.
Downloading Official Prebuilt Binaries
Official prebuilt shared libraries are distributed via Microsoft's official NuGet package Microsoft.ML.OnnxRuntime (v1.32.0, MIT License) and are excluded from Git tracking (prebuilt/ is gitignored):
- NuGet Archive:
https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/1.32.0/microsoft.ml.onnxruntime.1.32.0.nupkg
| Target | Path Inside .nupkg | Destination Path |
| --- | --- | --- |
| linux-x86_64 | runtimes/linux-x64/native/libonnxruntime.so | prebuilt/linux-x86_64/libonnxruntime.so |
| linux-aarch64 | runtimes/linux-arm64/native/libonnxruntime.so | prebuilt/linux-aarch64/libonnxruntime.so |
| macos-aarch64 | runtimes/osx-arm64/native/libonnxruntime.dylib | prebuilt/macos-aarch64/libonnxruntime.dylib |
| macos-x86_64 | runtimes/osx-x64/native/libonnxruntime.dylib | prebuilt/macos-x86_64/libonnxruntime.dylib |
| windows-x86_64 | runtimes/win-x64/native/onnxruntime.dll | prebuilt/windows-x86_64/onnxruntime.dll |
Example setup on Linux x86_64:
curl -sSL -o /tmp/ort.nupkg https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/1.32.0/microsoft.ml.onnxruntime.1.32.0.nupkg
unzip -j -o /tmp/ort.nupkg "build/native/include/onnxruntime_*.h" -d include/
unzip -j -o /tmp/ort.nupkg "runtimes/linux-x64/native/libonnxruntime.so" -d prebuilt/linux-x86_64/
strip --strip-unneeded prebuilt/linux-x86_64/libonnxruntime.so
ln -sf libonnxruntime.so prebuilt/linux-x86_64/libonnxruntime.so.1
Quick Start
import { OrtEnv, OrtSessionOptions, versionString } from "@cap/onnx";
import std from "std";
pub fn main(): void! {
std.debug.print("ONNX Runtime: {s}\n", .{versionString()});
let env = try OrtEnv.create("cp_agent");
let opts = try OrtSessionOptions.create();
try opts.setIntraOpThreads(4);
std.debug.print("env_valid={} opts_valid={}\n", .{env.isValid(), opts.isValid()});
}Version History
1 release| Version | Format / Size | Integrity (SHA-256) | Downloads | Published | Status |
|---|---|---|---|---|---|
| v1.32.0 | .cap · 136 KB | sha256-7e3815ebd19702e1… | 0 | 2026-11-26 | latest |