Add @stdlib/onnx module for local ONNX Runtime inference#442
Open
nbeerbower wants to merge 1 commit into
Open
Conversation
Adds a new standard library module that enables running ONNX models locally via libonnxruntime FFI, following the same pattern as the sqlite and vector modules. Architecture: - stdlib/c/onnx_wrapper.c: Thin C wrapper that flattens OrtApi's struct-of-function-pointers into flat exported C functions callable through Hemlock's FFI system - stdlib/onnx.hml: Pure Hemlock module providing high-level API for session management, tensor creation/inspection, and inference - stdlib/docs/onnx.md: Full documentation with examples API surface: - Session lifecycle: create_session(), free_session() - Model inspection: input_names(), output_names(), input_shape(), output_shape(), input_type(), output_type(), describe() - Tensor creation: create_tensor_f32/f64/i32/i64(), free_tensor() - Tensor inspection: tensor_shape(), tensor_data_f32/f64/i32/i64(), tensor_element_count(), tensor_type() - Inference: run() with named (object) or positional (array) inputs - Utilities: version(), api_version(), dtype_name() Also includes: - Makefile updates for conditional ONNX Runtime detection and wrapper compilation on Linux and macOS - Test runner skip logic for when libonnxruntime is not installed - Tests for constants, tensor operations, error handling, and inference https://claude.ai/code/session_01PAARTAYAKLvdGGuiNaW9xF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new standard library module that enables running ONNX models
locally via libonnxruntime FFI, following the same pattern as the
sqlite and vector modules.
Architecture:
struct-of-function-pointers into flat exported C functions callable
through Hemlock's FFI system
session management, tensor creation/inspection, and inference
API surface:
output_shape(), input_type(), output_type(), describe()
tensor_element_count(), tensor_type()
Also includes:
compilation on Linux and macOS
https://claude.ai/code/session_01PAARTAYAKLvdGGuiNaW9xF