Package 'churon'

Title: 'ONNX' Runtime Integration for R
Description: Provides high-performance R bindings for 'ONNX' Runtime, enabling efficient machine learning model inference. Written in Rust for memory safety and speed, the package supports cross-platform model execution with multiple execution providers. Includes comprehensive error handling and validation, with bundled 'MNIST' example model for immediate testing and prototyping. Designed for production use with support for macOS (arm64/x64), Linux (x64/arm64), and Windows (x64/arm64).
Authors: Chanyub Park [aut, cre]
Maintainer: Chanyub Park <[email protected]>
License: MIT + file LICENSE
Version: 0.1.10
Built: 2026-05-18 09:07:23 UTC
Source: https://github.com/mrchypark/churon

Help Index


S3 Methods for TensorInfo and RSession

Description

These methods provide convenient access to object properties.

Usage

## S3 method for class 'TensorInfo'
x$name

Arguments

x

A TensorInfo or RSession object

name

Property name to access


Optimize Session Performance Batch Process Data

Description

Process data in batches for memory efficiency with large datasets.

Usage

batch_process_data(session, data_list, batch_size = 32)

Arguments

session

An RSession object created by onnx_session()

data_list

A list of input data to process

batch_size

Number of items to process in each batch

Value

A list of results from batch processing


Check if ONNX Runtime is Available

Description

This function checks if ONNX Runtime is properly configured and available.

Usage

check_onnx_runtime_available()

Value

Logical indicating whether ONNX Runtime is available


Get ONNX Runtime Information

Description

This function returns information about the current ONNX Runtime configuration.

Usage

get_onnx_runtime_info()

Value

A list containing ONNX Runtime configuration information


Install ONNX Runtime

Description

Download and install ONNX Runtime library for your platform. This is required before using the churon package if ONNX Runtime is not already installed on your system.

Usage

install_onnx_runtime(version = "1.23.2", quiet = FALSE, ...)

Arguments

version

Character string specifying the ONNX Runtime version to install. Defaults to "1.23.2". Use "latest" to download the latest stable version.

quiet

Logical. If TRUE, suppress download progress messages.

...

Additional arguments passed to download.file()

Value

Invisible TRUE on success, stops with error on failure.

Examples

## Not run: 
# Install ONNX Runtime
install_onnx_runtime()

# Install specific version
install_onnx_runtime(version = "1.23.0")

# Install with no output
install_onnx_runtime(quiet = TRUE)

## End(Not run)

ONNX Example Models

Description

List available example models bundled with the package.

Usage

onnx_example_models()

Value

A named character vector with model names as names and paths as values


ONNX Example Session

Description

Create a session with an example model.

Usage

onnx_example_session(model_name = "mnist", providers = NULL)

Arguments

model_name

Character string specifying the model name (default: "mnist")

providers

Optional execution providers

Value

An RSession object


Get Input Information

Description

Retrieve information about model input tensors.

Usage

onnx_input_info(session)

Arguments

session

An RSession object created by onnx_session()

Value

A list of TensorInfo objects containing input tensor metadata

Examples

## Not run: 
session <- onnx_session("path/to/model.onnx")
input_info <- onnx_input_info(session)
print(input_info)

## End(Not run)

Get Model Path

Description

Get the model path from a session.

Usage

onnx_model_path(session)

Arguments

session

An RSession object created by onnx_session()

Value

Character string with the model path

Examples

## Not run: 
session <- onnx_session("path/to/model.onnx")
model_path <- onnx_model_path(session)
cat("Model path:", model_path, "\n")

## End(Not run)

Get Output Information

Description

Retrieve information about model output tensors.

Usage

onnx_output_info(session)

Arguments

session

An RSession object created by onnx_session()

Value

A list of TensorInfo objects containing output tensor metadata

Examples

## Not run: 
session <- onnx_session("path/to/model.onnx")
output_info <- onnx_output_info(session)
print(output_info)

## End(Not run)

Get Execution Providers

Description

Get the execution providers available for the session.

Usage

onnx_providers(session)

Arguments

session

An RSession object created by onnx_session()

Value

A character vector of available execution providers

Examples

## Not run: 
session <- onnx_session("path/to/model.onnx")
providers <- onnx_providers(session)
cat("Available execution providers:", paste(providers, collapse = ", "), "\n")

## End(Not run)

Run ONNX Inference

Description

Execute inference on an ONNX model with input data.

Usage

onnx_run(session, inputs)

Arguments

session

An RSession object created by onnx_session()

inputs

A named list of input tensors. Names should match model input names.

Value

A named list of output tensors

Examples

## Not run: 
session <- onnx_session("path/to/model.onnx")
inputs <- list(input_tensor = matrix(rnorm(10), nrow = 2, ncol = 5))
outputs <- onnx_run(session, inputs)

## End(Not run)

Create ONNX Session

Description

Create a new ONNX Runtime session from a model file.

Usage

onnx_session(model_path, providers = NULL)

Arguments

model_path

Character string specifying the path to the ONNX model file

providers

Optional character vector specifying execution providers to use. Available providers: "cuda", "tensorrt", "directml", "onednn", "coreml", "cpu". If NULL, uses default provider priority.

Value

An RSession object for running inference

Examples

## Not run: 
# Create session with default providers
session <- onnx_session("path/to/model.onnx")

# Create session with specific providers
session <- onnx_session("path/to/model.onnx", providers = c("cuda", "cpu"))

## End(Not run)

Safe ONNX Run

Description

Run inference with automatic error handling and monitoring.

Usage

safe_onnx_run(session, inputs, monitor_performance = FALSE)

Arguments

session

An RSession object created by onnx_session()

inputs

A named list of input tensors

monitor_performance

Logical indicating whether to monitor performance

Value

Result of inference or NULL if failed


Safe ONNX Session Creation

Description

Safe ONNX Session Creation

Usage

safe_onnx_session(model_path, providers = NULL)

Arguments

model_path

Character string specifying the path to the ONNX model file

providers

Optional character vector specifying execution providers

Details

Create an ONNX session with automatic error handling.

Value

An RSession object or NULL if creation fails