Crates.io | pjrt |
lib.rs | pjrt |
version | 0.2.0 |
source | src |
created_at | 2024-09-14 17:20:29.792057 |
updated_at | 2024-09-19 15:59:08.826839 |
description | A safe PJRT C API bindings for Rust |
homepage | https://github.com/rai-explorers/pjrt-rs |
repository | https://github.com/rai-explorers/pjrt-rs |
max_upload_size | |
id | 1374955 |
size | 174,119 |
pjrt
is a safe PJRT C API bindings for Rust.
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(())
}
This project is licensed under either of
at your option.