class

OnnxRuntime::InferenceSession

Inherits Reference / Object

Constructors

new(path_or_bytes, provider : Provider | Nil = nil, **session_options)
Source

Class methods

open(path_or_bytes, provider : Provider | Nil = nil, release_env : Bool = false, **session_options, &)

Block-based API for RAII-style session management.

Example: InferenceSession.open("model.onnx") do |session| session.run({"input" => [1.0_f32]}) end

Set release_env: true to also release the global environment when the block exits.

Source
release_env

Class method to explicitly release the environment This method is now a wrapper around OrtEnvironment.instance.release

Source

Instance methods

allocator
Source
check_status(status)

Make check_status public so it can be used by SparseTensor

Source
create_api
Source
finalize

Finalizer only releases session-specific resources Environment is managed separately and should be released explicitly by the user

Source
inputs
Source
metadata

Get model metadata

Source
outputs
Source
release

Unified lifecycle API Alias for release_session (kept for API consistency with other wrapper classes)

Source
release_allocator

Method to explicitly release the allocator Note: Default allocator may not need to be released, so commented out

Source
release_session

Method to explicitly release the session

Source
run(input_feed, output_names = nil, run_options : RunOptions | Nil = nil, **options)

ameba:disable Metrics/CyclomaticComplexity

Source
session

Use OrtEnvironment singleton for environment management

Source