Expand description
megenginelite-rs
provides the safe megenginelite wrapper in Rust.
See more in megenginelite.
§Examples
// 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>());
§Default feature flags
The following features are turned on by default:
auto-load
: automatically load megenginelite dynamic library from the megenginelite python package, and find that bypython3 -c "import megenginelite;print(megenginelite.__file__)"
.
§Optional feature flags
The following features is optional.
ndarray-basis
: enable ndarray support.ndarray-rayon
: enable ndarray/rayon feature.
Modules§
Macros§
- A helper macro used to slice tensor.
Structs§
- A type to describe fastrun strategy
- A type to describe data
- A type to describe device
- A type to describe network’s input and output
- A type to describe network’s input and output
- An tensor index of the
TensorPool
- The simple layout description
- The network is construct from a model, implement model load, init, forward, and display some model information
- The network builder
- The Lite Tensor object
- A tensor pool to reuse memory
Enums§
- A error type
Functions§
- Clear the physical and virtual address pair in mge.
- Default network config
- Get device count
- Dump the algo policy cache to file, if the network is set to profile
- load⚠Find and load megenginelite dynamic library.
- Register the physical and virtual address pair to the mge, some device need the map from physical to virtual.
- Set the algo policy cache file for CPU/CUDA …
- Try to coalesce all free memory in megenine
- Update decryption key by name.