pjrt

Crates.iopjrt
lib.rspjrt
version0.2.0
sourcesrc
created_at2024-09-14 17:20:29.792057
updated_at2024-09-19 15:59:08.826839
descriptionA safe PJRT C API bindings for Rust
homepagehttps://github.com/rai-explorers/pjrt-rs
repositoryhttps://github.com/rai-explorers/pjrt-rs
max_upload_size
id1374955
size174,119
cksac (cksac)

documentation

README

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.

Commit count: 52

cargo fmt