#wrapper #megenginelite #dynamic #version #dont #issue #auto-load

sys megenginelite-sys

A safe megenginelite wrapper in Rust

3 releases (stable)

1.8.2 Mar 25, 2022
1.7.0 Dec 13, 2021
1.7.0-1 Dec 14, 2021

#109 in #issue

24 downloads per month
Used in megenginelite-rs

Apache-2.0

25MB
498K SLoC

C++ 403K SLoC // 0.1% comments Python 54K SLoC // 0.2% comments CUDA 36K SLoC // 0.1% comments Shell 3K SLoC // 0.1% comments Bazel 1.5K SLoC // 0.0% comments FlatBuffers Schema 253 SLoC // 0.0% comments Bitbake 87 SLoC // 0.0% comments Rust 83 SLoC C 59 SLoC // 0.2% comments Forge Config 11 SLoC JavaScript 9 SLoC

megenginelite-rs

Crates.io libs.rs Documentation

A safe megenginelite wrapper in Rust

⚠️ The project is still in early development, expect bugs, safety issues, and things that don't work ⚠️

Install

[dependencies]
megenginelite-rs = "1.8.2"

How to use

// 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.

Dependencies