2 unstable releases

0.2.0 Sep 19, 2024
0.1.0 Sep 14, 2024

#360 in Machine learning

Download history 241/week @ 2024-09-13 78/week @ 2024-09-20 19/week @ 2024-09-27 3/week @ 2024-10-04

76 downloads per month

MIT/Apache

215KB
4.5K SLoC

PJRT-RS

Docs Status Latest Version Discord

pjrt is a safe PJRT C API bindings for Rust.

Example

use pjrt::ProgramFormat::MLIR;
use pjrt::{self, Client, HostBuffer, LoadedExecutable, Result};

const CODE: &'static [u8] = include_bytes!("program.mlir");

fn main() -> Result<()> {
    let api = pjrt::load_plugin("pjrt_c_api_cpu_plugin.so")?;
    println!("api_version = {:?}", api.version());

    let client = Client::builder(&api).build()?;
    println!("platform_name = {}", client.platform_name());

    let program = pjrt::Program::new(MLIR, CODE);

    let loaded_executable = LoadedExecutable::builder(&client, &program).build()?;

    let a = HostBuffer::scalar(1.0f32);
    println!("input = {:?}", a);

    let inputs = a.copy_to_sync(&client)?;

    let result = loaded_executable.execution(inputs).run_sync()?;

    let ouput = &result[0][0];
    let output = ouput.copy_to_host_sync()?;
    println!("output= {:?}", output);

    Ok(())
}

LICENSE

This project is licensed under either of

at your option.

Dependencies

~3–12MB
~133K SLoC