Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: churon
Title: 'ONNX' Runtime Integration for R
Version: 0.1.11
Title: 'ONNX Runtime' Integration
Version: 0.1.12
Authors@R: c(
person(given = "Chanyub", family = "Park", role = c("aut", "cre"),
email = "mrchypark@gmail.com",
Expand All @@ -12,13 +12,14 @@ Authors@R: c(
person(given = "Microsoft Corporation", role = "cph",
comment = "ONNX Runtime, downloaded only on explicit user request")
)
Description: Provides high-performance R bindings for 'ONNX' Runtime, enabling
efficient machine learning model inference. Written in Rust for memory safety
Description: Provides high-performance R bindings for 'ONNX Runtime'
<https://onnxruntime.ai/>, 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.
with bundled MNIST example model for immediate testing and prototyping.
Designed for production use with support for macOS (arm64), Linux (x64/arm64),
and Windows (x64).
and Windows (x64). Runtime libraries are downloaded on explicit request from
<https://github.com/microsoft/onnxruntime/releases>.
License: MIT + file LICENSE
URL: https://github.com/mrchypark/churon
BugReports: https://github.com/mrchypark/churon/issues
Expand Down
69 changes: 34 additions & 35 deletions R/install_onnx_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,39 @@
#' @param version Character string specifying the ONNX Runtime version to install.
#' Defaults to "1.29.0". Supported versions are "1.28.0" and "1.29.0";
#' "latest" selects "1.29.0".
#' @param destdir Required character string naming the installation directory.
#' @param quiet Logical. If TRUE, suppress download progress messages.
#' @param ... Additional arguments passed to download.file()
#'
#' @return Invisible TRUE on success, stops with error on failure.
#' @export
#' @examples
#' \dontrun{
#' # Install ONNX Runtime
#' install_onnx_runtime()
#'
#' # Install specific version
#' install_onnx_runtime(version = "1.28.0")
#'
#' # Install with no output
#' install_onnx_runtime(quiet = TRUE)
#' }
install_onnx_runtime <- function(version = "1.29.0", quiet = FALSE, ...) {
#' @details
#' This function installs external software only when explicitly called. Supply
#' `destdir` yourself; no installation directory is selected by default.
#' The library is placed in `destdir/lib` and configured for this R session.
#' In later sessions, set `ORT_DYLIB_PATH` to the installed library file before
#' loading churon. Restart R before switching an already loaded runtime.
install_onnx_runtime <- function(
version = "1.29.0",
quiet = FALSE,
destdir,
...
) {
if (!is.character(version) || length(version) != 1L || is.na(version)) {
stop("version must be one non-missing character string.")
}

if (
missing(destdir) ||
!is.character(destdir) ||
length(destdir) != 1L ||
is.na(destdir) ||
!nzchar(trimws(destdir))
) {
stop("destdir must be supplied as one non-empty directory path.")
}
destdir <- path.expand(destdir)

# Platform detection
platform <- Sys.info()[["sysname"]]
machine <- Sys.info()[["machine"]]
Expand Down Expand Up @@ -149,7 +161,7 @@ install_onnx_runtime <- function(version = "1.29.0", quiet = FALSE, ...) {
}

# Determine library path
lib_dir <- file.path(.libPaths()[1], "churon", "onnxruntime", "lib")
lib_dir <- file.path(destdir, "lib")

# Create directory if needed
if (!dir.exists(lib_dir)) {
Expand Down Expand Up @@ -186,7 +198,7 @@ install_onnx_runtime <- function(version = "1.29.0", quiet = FALSE, ...) {
)
if (!copied) {
stop(
"Failed to copy the ONNX Runtime library into the package library."
"Failed to copy the ONNX Runtime library into destdir."
)
}

Expand All @@ -206,35 +218,18 @@ install_onnx_runtime <- function(version = "1.29.0", quiet = FALSE, ...) {
stop("Could not find ", lib_filename, " in extracted archive")
}

# Copy include directory (for future use)
include_dir <- file.path(
.libPaths()[1],
"churon",
"onnxruntime",
"include"
)
if (!dir.exists(include_dir)) {
dir.create(include_dir, showWarnings = FALSE, recursive = TRUE)
}
include_src_dir <- file.path(extracted_dir, "include")
if (dir.exists(include_src_dir)) {
file.copy(
list.files(include_src_dir, full.names = TRUE, recursive = TRUE),
include_dir,
overwrite = TRUE,
recursive = TRUE
)
}

# Clean up
unlink(temp_dir, recursive = TRUE)

# Verify installation
lib_file <- onnx_runtime_lib_path()
lib_file <- file.path(lib_dir, lib_filename)
if (!file.exists(lib_file)) {
stop("Installation verification failed: library file not found")
}

Sys.setenv(ORT_DYLIB_PATH = normalizePath(lib_file))
setup_onnx_runtime()

if (!quiet) {
message(sprintf("ONNX Runtime installed successfully!"))
message(sprintf("Library: %s", lib_file))
Expand Down Expand Up @@ -291,6 +286,10 @@ onnx_runtime_is_installed <- function() {
#' @return Character string with the library path.
#' @keywords internal
onnx_runtime_lib_path <- function() {
configured_path <- Sys.getenv("ORT_DYLIB_PATH", unset = "")
if (nzchar(configured_path) && file.exists(configured_path)) {
return(configured_path)
}
platform <- Sys.info()[["sysname"]]
pkg_path <- system.file(package = "churon")

Expand Down
50 changes: 25 additions & 25 deletions R/onnx_interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ NULL
#' @return An RSession object for running inference
#' @export
#' @examples
#' \dontrun{
#' # Create session with default providers
#' session <- onnx_session("path/to/model.onnx")
#' if (check_onnx_runtime_available()) {
#' # Create session with default providers
#' session <- onnx_example_session()
#'
#' # Create session with specific providers
#' session <- onnx_session("path/to/model.onnx", providers = c("cuda", "cpu"))
#' # Create session with specific providers
#' session <- onnx_example_session(providers = "cpu")
#' }
onnx_session <- function(model_path, providers = NULL) {
# Input validation
Expand Down Expand Up @@ -131,10 +131,10 @@ onnx_session <- function(model_path, providers = NULL) {
#' @return A named list of output tensors
#' @export
#' @examples
#' \dontrun{
#' session <- onnx_session("path/to/model.onnx")
#' inputs <- list(input_tensor = matrix(rnorm(10), nrow = 2, ncol = 5))
#' outputs <- onnx_run(session, inputs)
#' if (check_onnx_runtime_available()) {
#' session <- onnx_example_session()
#' inputs <- list(Input3 = array(0, dim = c(1, 1, 28, 28)))
#' outputs <- onnx_run(session, inputs)
#' }
onnx_run <- function(session, inputs) {
.validate_session(session)
Expand Down Expand Up @@ -261,10 +261,10 @@ onnx_run <- function(session, inputs) {
#' @return A list of TensorInfo objects containing input tensor metadata
#' @export
#' @examples
#' \dontrun{
#' session <- onnx_session("path/to/model.onnx")
#' input_info <- onnx_input_info(session)
#' print(input_info)
#' if (check_onnx_runtime_available()) {
#' session <- onnx_example_session()
#' input_info <- onnx_input_info(session)
#' print(input_info)
#' }
onnx_input_info <- function(session) {
.validate_session(session)
Expand Down Expand Up @@ -294,10 +294,10 @@ onnx_input_info <- function(session) {
#' @return A list of TensorInfo objects containing output tensor metadata
#' @export
#' @examples
#' \dontrun{
#' session <- onnx_session("path/to/model.onnx")
#' output_info <- onnx_output_info(session)
#' print(output_info)
#' if (check_onnx_runtime_available()) {
#' session <- onnx_example_session()
#' output_info <- onnx_output_info(session)
#' print(output_info)
#' }
onnx_output_info <- function(session) {
.validate_session(session)
Expand Down Expand Up @@ -327,10 +327,10 @@ onnx_output_info <- function(session) {
#' @return A character vector of available execution providers
#' @export
#' @examples
#' \dontrun{
#' session <- onnx_session("path/to/model.onnx")
#' providers <- onnx_providers(session)
#' cat("Available execution providers:", paste(providers, collapse = ", "), "\n")
#' if (check_onnx_runtime_available()) {
#' session <- onnx_example_session()
#' providers <- onnx_providers(session)
#' cat("Available execution providers:", paste(providers, collapse = ", "), "\n")
#' }
onnx_providers <- function(session) {
.validate_session(session)
Expand Down Expand Up @@ -360,10 +360,10 @@ onnx_providers <- function(session) {
#' @return Character string with the model path
#' @export
#' @examples
#' \dontrun{
#' session <- onnx_session("path/to/model.onnx")
#' model_path <- onnx_model_path(session)
#' cat("Model path:", model_path, "\n")
#' if (check_onnx_runtime_available()) {
#' session <- onnx_example_session()
#' model_path <- onnx_model_path(session)
#' cat("Model path:", model_path, "\n")
#' }
onnx_model_path <- function(session) {
.validate_session(session)
Expand Down
4 changes: 4 additions & 0 deletions R/s3_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#'
#' @param x A TensorInfo or RSession object
#' @param name Property name to access
#' @return For `name` and `data_type`, a character scalar identifying the tensor
#' or its element type. For `shape`, an integer vector of tensor dimensions
#' (negative dimensions indicate dynamic sizes). For a method name, a function
#' bound to the object; for an unknown name, `NULL`.
#' @export
`$.TensorInfo` <- function(x, name) {
if (name == "name") {
Expand Down
4 changes: 3 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
if (!check_onnx_runtime_available()) {
packageStartupMessage("")
packageStartupMessage("ONNX Runtime is not installed.")
packageStartupMessage("To install, run: install_onnx_runtime()")
packageStartupMessage(
"To install, call install_onnx_runtime() with an explicit destdir."
)
packageStartupMessage("")
} else {
packageStartupMessage("ONNX Runtime loaded successfully.")
Expand Down
41 changes: 30 additions & 11 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
## Test environments
## Resubmission (0.1.12)

* GitHub Actions: R-devel, R-release, and R 4.0 on Ubuntu (without ONNX
Runtime and without network access during package installation)
* GitHub Actions: R-release on Ubuntu x86_64 and arm64, macOS, and Windows
* r-universe: R-devel, R-release, and R-oldrel native builders, plus WebAssembly
This resubmission addresses the CRAN review of version 0.1.11:

## R CMD check results
* Removed the redundant "for R" from the title and quoted software names
consistently; MNIST is no longer quoted.
* Added ONNX Runtime and GitHub release URLs to DESCRIPTION.
* Documented the return types and meaning of `$.TensorInfo` results.
* Replaced non-running placeholder examples with executable examples using
the bundled MNIST model, conditional on runtime availability.
* Removed software installation calls from the installer examples.
* Required an explicit `destdir` for runtime installation. The installer no
longer writes into the package library, and configures `ORT_DYLIB_PATH`
for the current session. Later-session configuration is documented.
* Removed automatic R package installation from the development setup script.

0 errors | 0 warnings | 0 notes
## Local validation (2026-09-11)

* macOS arm64, R 4.5.2, Rust 1.97.1.
* Runtime-enabled tests: 90 passed, no failures, warnings, or skips.
* Offline `R CMD check --as-cran --no-manual`: 0 errors, 0 warnings, 1 note.
The note reports that current time could not be verified with network access
disabled. The official Debian `checkbashisms` utility was supplied for this check.
Package installation, documentation, examples, and tests passed.

## Additional notes

This is a new submission.
Rust dependencies are vendored in the source package for offline builds.
ONNX Runtime is not bundled. The dedicated installer downloads it only on
explicit request with a user-supplied destination. Tests requiring a runtime
are skipped when it is absent; tests do not download or install software.

## Submission status

Rust dependencies are vendored in the source package for offline builds. ONNX
Runtime is not bundled; users may download it explicitly with
`install_onnx_runtime()`. Tests that require it are skipped when it is absent.
Version 0.1.12 was uploaded and submitted through the CRAN web form on
2026-09-11 (upload ID 354755). The maintainer subsequently confirmed publication on CRAN.
The Git repository is being synchronized with the published 0.1.12 release.
6 changes: 6 additions & 0 deletions man/cash-.TensorInfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions man/install_onnx_runtime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/onnx_input_info.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/onnx_model_path.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading