Crates.io | megenginelite-rs |
lib.rs | megenginelite-rs |
version | 1.8.2 |
source | src |
created_at | 2021-12-13 10:57:25.693302 |
updated_at | 2022-03-25 08:46:14.601376 |
description | A safe megenginelite wrapper in Rust |
homepage | |
repository | https://github.com/MegEngine/megenginelite-rs |
max_upload_size | |
id | 497062 |
size | 43,621 |
A safe megenginelite wrapper in Rust
⚠️ The project is still in early development, expect bugs, safety issues, and things that don't work ⚠️
[dependencies]
megenginelite-rs = "1.8.2"
// The dynamic library version needs to be greater than or equal to the compiled version.
// It is needless if the feature `auto-load` is enable (default enable).
unsafe {
load("dynamic_library_path")?;
}
// set some options, and load model
let mut network = Network::builder()
.dev_id(0)
.stream_id(0)
// ...
.build("model_path")?;
// get an input of the model by name
let mut input = network.io_tensor("input_name").unwrap();
let data = Tensor::host()?;
input.copy_from(&data);
// exec, and wait
network.exec_wait()?;
// exec, async
network.exec().await?;
// get an output of the model by name
let output = network.io_tensor("output_name").unwrap();
println!("{:?}", output.as_slice::<f32>());
see more in megenginelite.