keel-onnx: ONNX Runtime inference over a runtime-loaded library

[ foreign, library, machine-learning, mit ] [ Propose Tags ] [ Report a vulnerability ]

Inference-only bindings to ONNX Runtime's C API, resolved entirely at run time: keel-dyn loads the (MIT-licensed, official) shared library, OrtGetApiBase() hands back the versioned function-pointer table, and every call goes through it. No build-time native dependency, no cbits in the shipped library. . The OrtApi function-pointer slot indices are pinned against the vendored onnxruntime_c_api.h (v1.24.4) by a test-suite-only C gate — the ABI contract is that slots are append-only, so any runtime >= the pinned API version serves them at the same indices. . The vendored headers are Microsoft's, MIT-licensed; their license text ships alongside as LICENSE.onnxruntime.


[Skip to Readme]

Modules

  • Keel
    • Keel.Onnx
      • Keel.Onnx.Raw

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.20 && <4.23), bytestring (>=0.11 && <0.13), keel-dyn (>=0.1 && <0.2), vector (>=0.13 && <0.14) [details]
Tested with ghc ==9.10.3 || ==9.12.4 || ==9.14.1
License MIT
Author Zhe Zhang
Maintainer Zhe Zhang
Uploaded by azng_0 at 2026-08-19T23:30:30Z
Category Machine Learning, Foreign
Home page https://github.com/skymanbp/keel
Bug tracker https://github.com/skymanbp/keel/issues
Source repo head: git clone https://github.com/skymanbp/keel
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-08-19 [all 2 reports]

Readme for keel-onnx-0.1.0.0

[back to package description]

keel-onnx

Inference-only bindings to ONNX Runtime's C API, resolved entirely at run time: keel-dyn loads the official shared library, OrtGetApiBase() hands back the versioned function-pointer table, and every call goes through it. No build-time native dependency, no cbits in the shipped library.

import Keel.Onnx
import Data.ByteString qualified as BS

main :: IO ()
main = do
  Right ort <- loadOnnxRuntime
  model <- BS.readFile "model.onnx"
  withOrtEnv ort $ \env ->
    withSessionFromBytes env model $ \sess -> do
      [inName] <- inputNames sess
      [outName] <- outputNames sess
      out <- runFloats sess [(inName, [1, 4], xs)] [outName]
      print out

The runtime is located by the keel search policy (KEEL_ONNXRUNTIME env override, the per-user keel data dir — populated by keel setup onnx from the umbrella package — then the system search path). Absence of the runtime is an ordinary Left, never a crash.

The OrtApi slot indices are pinned against the vendored onnxruntime_c_api.h and verified by a test-suite-only C gate; the requested API version is the oldest whose frozen table prefix contains every slot used, so any ONNX Runtime release serves it. Inference results agree with Python onnxruntime to 1e-6 in the test suite, with a leak gate over 500 inference calls.

The vendored headers are Microsoft's, MIT-licensed — see LICENSE.onnxruntime.

Part of the keel workspace — see the project repository.