https://github.com/megengine/megenginelite-rs
https://github.com/megengine/megenginelite-rs
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/megengine/megenginelite-rs
- Owner: MegEngine
- License: apache-2.0
- Created: 2021-12-10T11:05:53.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T08:26:28.000Z (almost 4 years ago)
- Last Synced: 2025-04-12T06:52:04.732Z (10 months ago)
- Language: Rust
- Size: 7.9 MB
- Stars: 7
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
megenginelite-rs
--------------
[](https://crates.io/crates/megenginelite-rs)
[](https://lib.rs/crates/megenginelite-rs)
[](https://docs.rs/megenginelite-rs)
A safe megenginelite wrapper in Rust
⚠️ The project is still in early development, expect bugs, safety issues, and things that don't work ⚠️
### Install
```toml
[dependencies]
megenginelite-rs = "1.8.2"
```
### How to use
```rust
// 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::());
```
see more in [megenginelite](https://github.com/MegEngine/MegEngine/tree/master/lite).