izackp 04caa09c0c
CodeQL Advanced / Analyze (swift) (push) Has been cancelled
Add setInterOpNumThreads to ORTSessionOptions
Wraps the C API's SetInterOpNumThreads, mirroring the existing
setIntraOpNumThreads binding.

Automated-By: Claude Fable 5
2026-06-09 17:57:40 -04:00
2025-07-15 17:12:49 -07:00
2025-07-19 16:35:03 -07:00
2026-02-24 18:08:50 -08:00
2023-07-05 16:16:34 -07:00
2023-07-05 16:16:32 -07:00
2023-07-05 16:16:33 -07:00

Swift Package Manager for ONNX Runtime

Swift-native ONNX Runtime bindings derived from the public Objective-C wrapper surface, but implemented without the Objective-C bridge so the package can build on Linux.

Status

  • Public API covers inference, session/run options, tensor values, checkpoint state, and training session entry points.
  • Backend is wired to the ONNX Runtime C API and training C API through a Swift system library target.
  • The package expects libonnxruntime and headers to be available on the host, typically via pkg-config.

Requirements

  • Swift 6.1+
  • ONNX Runtime installed on the system with:
    • libonnxruntime
    • onnxruntime_c_api.h
    • onnxruntime_training_c_api.h
    • pkg-config metadata for libonnxruntime

Usage

import OnnxRuntimeBindings

let environment = try ORTEnv(loggingLevel: .warning)
let sessionOptions = try ORTSessionOptions()
let session = try ORTSession(
    env: environment,
    modelPath: "/path/to/model.onnx",
    sessionOptions: sessionOptions
)

let inputTensor = try ORTValue(
    tensorData: NSMutableData(data: inputData),
    elementType: .float,
    shape: [1, 224, 224, 3]
)

let outputs = try session.run(
    inputs: ["input": inputTensor],
    outputNames: ["output"]
)

Notes

  • The objectivec/ directory remains in the repo as the reference contract surface from upstream ONNX Runtime.
  • The shipped Swift package target is the pure Swift OnnxRuntimeBindings implementation under swift/OnnxRuntimeBindings.
S
Description
Swift-native ONNX Runtime bindings forked from microsoft/onnxruntime-swift-package-manager
Readme MIT 248 KiB
Languages
Objective-C++ 42.1%
Swift 32.4%
Objective-C 24.1%
C 1.3%