Package 'xlaport'

Title: Run Exported XLA Programs (StableHLO) as R Functions
Description: Ship kernels written in JAX (or anything else that emits StableHLO) inside an R package and call them as ordinary R functions, with no Python at runtime. Programs are compiled through 'pjrt' on the user's machine for the device in use and cached per session.
Authors: Ben Traven [aut, cre]
Maintainer: Ben Traven <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2026-11-21 14:58:36 UTC
Source: https://github.com/btraven00/xlaport

Help Index


Run exported XLA programs (StableHLO) as R functions

Description

A kernel directory holds StableHLO text files plus a 'manifest.json' that names each kernel's file, inputs and outputs (written by 'python/xlaport_export.py'). 'xla_kernel()' turns one entry into an R function; 'xla_kernels()' does all of them. Programs compile on first call, on the user's machine, for the device in use ('PJRT_PLATFORM', default "cpu"), and stay compiled for the rest of the session.

Usage

xla_kernel(name, dir, device = NULL)

xla_kernels(dir, device = NULL)

Arguments

name

Kernel name (a key of the manifest's 'kernels').

dir

Kernel directory, e.g. 'system.file("xla", package = "yourpkg")'.

device

Passed to [pjrt::pjrt_compile()] and [pjrt::pjrt_buffer()]; 'NULL' uses the default device of 'PJRT_PLATFORM'.

Value

A function taking the kernel's inputs in manifest order. It returns one array, or a named list when the kernel has several outputs.

'xla_kernels()': a named list of kernel functions.