forked from pykeio/ort
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '90b8d3045fe7b483ebea0b7bf0d31a4368bc2e49' into adapt-to…
…-voicevox-core
- Loading branch information
Showing
26 changed files
with
715 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,3 +191,6 @@ WixTools/ | |
|
||
# IDEA | ||
.idea | ||
|
||
# Glassbench results | ||
/glassbench*.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,21 @@ members = [ | |
'ort-sys', | ||
'examples/gpt2', | ||
'examples/model-info', | ||
'examples/yolov8' | ||
'examples/yolov8', | ||
'examples/modnet' | ||
] | ||
default-members = [ | ||
'.', | ||
'examples/gpt2', | ||
'examples/model-info', | ||
'examples/yolov8' | ||
'examples/yolov8', | ||
'examples/modnet' | ||
] | ||
|
||
[package] | ||
name = "voicevox-ort" | ||
description = "A safe Rust wrapper for ONNX Runtime 1.16 - Optimize and Accelerate Machine Learning Inferencing" | ||
version = "2.0.0-alpha.4" | ||
description = "A safe Rust wrapper for ONNX Runtime 1.17 - Optimize and Accelerate Machine Learning Inferencing" | ||
version = "2.0.0-rc.0" | ||
edition = "2021" | ||
rust-version = "1.70" | ||
license = "MIT OR Apache-2.0" | ||
|
@@ -28,7 +30,7 @@ authors = [ | |
"pyke.io <[email protected]>", | ||
"Nicolas Bigaouette <[email protected]>" | ||
] | ||
include = [ "src/", "examples/", "tests/", "LICENSE-APACHE", "LICENSE-MIT", "README.md" ] | ||
include = [ "src/", "LICENSE-APACHE", "LICENSE-MIT", "README.md" ] | ||
|
||
[profile.release] | ||
opt-level = 3 | ||
|
@@ -77,6 +79,7 @@ ndarray = { version = "0.15", optional = true } | |
thiserror = "1.0" | ||
voicevox-ort-sys = { version = "2.0.0-alpha.4", path = "ort-sys" } | ||
libloading = { version = "0.8", optional = true } | ||
compact_str = "0.7" | ||
|
||
ureq = { version = "2.1", optional = true, default-features = false, features = [ "tls" ] } | ||
tracing = "0.1" | ||
|
@@ -95,3 +98,8 @@ ureq = "2.1" | |
image = "0.24" | ||
test-log = { version = "0.2", default-features = false, features = [ "trace" ] } | ||
tracing-subscriber = { version = "0.3", default-features = false, features = [ "env-filter", "fmt" ] } | ||
glassbench = "0.4" | ||
|
||
[[bench]] | ||
name = "squeezenet" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use std::{path::Path, sync::Arc}; | ||
|
||
use glassbench::{pretend_used, Bench}; | ||
use image::{imageops::FilterType, ImageBuffer, Pixel, Rgb}; | ||
use ndarray::{s, Array4}; | ||
use ort::{GraphOptimizationLevel, Session}; | ||
|
||
fn load_squeezenet_data() -> ort::Result<(Session, Array4<f32>)> { | ||
const IMAGE_TO_LOAD: &str = "mushroom.png"; | ||
|
||
ort::init().with_name("integration_test").commit()?; | ||
|
||
let session = Session::builder()? | ||
.with_optimization_level(GraphOptimizationLevel::Level1)? | ||
.with_intra_threads(1)? | ||
.with_model_downloaded("https://parcel.pyke.io/v2/cdn/assetdelivery/ortrsv2/ex_models/squeezenet.onnx") | ||
.expect("Could not download model from file"); | ||
|
||
let input0_shape: &Vec<i64> = session.inputs[0].input_type.tensor_dimensions().expect("input0 to be a tensor type"); | ||
|
||
let image_buffer: ImageBuffer<Rgb<u8>, Vec<u8>> = image::open(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests").join("data").join(IMAGE_TO_LOAD)) | ||
.unwrap() | ||
.resize(input0_shape[2] as u32, input0_shape[3] as u32, FilterType::Nearest) | ||
.to_rgb8(); | ||
|
||
let mut array = ndarray::Array::from_shape_fn((1, 3, 224, 224), |(_, c, j, i)| { | ||
let pixel = image_buffer.get_pixel(i as u32, j as u32); | ||
let channels = pixel.channels(); | ||
(channels[c] as f32) / 255.0 | ||
}); | ||
|
||
let mean = [0.485, 0.456, 0.406]; | ||
let std = [0.229, 0.224, 0.225]; | ||
for c in 0..3 { | ||
let mut channel_array = array.slice_mut(s![0, c, .., ..]); | ||
channel_array -= mean[c]; | ||
channel_array /= std[c]; | ||
} | ||
|
||
Ok((session, array)) | ||
} | ||
|
||
fn bench_squeezenet(bench: &mut Bench) { | ||
let (session, data) = load_squeezenet_data().unwrap(); | ||
bench.task("ArrayView", |task| { | ||
task.iter(|| { | ||
pretend_used(session.run(ort::inputs![data.view()].unwrap()).unwrap()); | ||
}) | ||
}); | ||
|
||
let raw = Arc::new(data.as_standard_layout().as_slice().unwrap().to_owned().into_boxed_slice()); | ||
let shape: Vec<i64> = data.shape().iter().map(|c| *c as _).collect(); | ||
bench.task("Raw data", |task| { | ||
task.iter(|| { | ||
pretend_used(session.run(ort::inputs![(shape.clone(), Arc::clone(&raw))].unwrap()).unwrap()); | ||
}) | ||
}); | ||
} | ||
|
||
glassbench::glassbench!("SqueezeNet", bench_squeezenet,); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
ignore: | ||
- src/download/**/*.rs | ||
- src/download.rs | ||
- "src/execution_providers" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ description: Information about `ort`'s versioning and relation to ONNX Runtime v | |
## A note on SemVer | ||
`ort` versions pre-2.0 were not SemVer compatible. From v2.0 onwards, breaking API changes are accompanied by a **major version update**. | ||
|
||
Updates to the version of ONNX Runtime used by `ort` may occur on **minor** version updates, i.e. 2.0 ships with ONNX Runtime 1.16.2, but 2.1 may ship with 1.17.0. ONNX Runtime is generally forward compatible, but in case you require a specific version of ONNX Runtime, you should pin the minor version in your `Cargo.toml` using a [tilde requirement](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements): | ||
Updates to the version of ONNX Runtime used by `ort` may occur on **minor** version updates, i.e. 2.0 ships with ONNX Runtime 1.17.0, but 2.1 may ship with 1.18.0. ONNX Runtime is generally forward compatible, but in case you require a specific version of ONNX Runtime, you should pin the minor version in your `Cargo.toml` using a [tilde requirement](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements): | ||
```toml | ||
[dependencies] | ||
ort = { version = "~2.0", ... } | ||
|
@@ -16,12 +16,10 @@ ort = { version = "~2.0", ... } | |
|
||
| **ort** | **ONNX Runtime** | | ||
| -------- | ----------------:| | ||
| v2.0.0+ | v1.16.2 | | ||
| v2.0.0+ | v1.17.0 | | ||
| v1.16.0-v1.16.2 | v1.16.0 | | ||
| v1.15.0-v1.15.5 | v1.15.1 | | ||
| v1.14.2-v1.14.8 | v1.14.1 | | ||
| v1.14.0-v1.14.1 | v1.14.0 | | ||
| v1.13.1-v1.13.3 | v1.13.1 | | ||
| v1.13.0 | v1.12.1 | | ||
|
||
If you need support for an old (<1.15) version of `ort`, or need an even older version of ONNX Runtime, [contact us](mailto:[email protected]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.