2 unstable releases
0.2.0 | Sep 19, 2024 |
---|---|
0.1.0 | Sep 14, 2024 |
#179 in Machine learning
76 downloads per month
215KB
4.5K
SLoC
PJRT-RS
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
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~3–12MB
~132K SLoC