-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a pure Wasm image classification benchmark
Add a benchmark which performs image classification in pure Wasm using tract and ONNX. This can be useful to track the performance of float heavy computations.
- Loading branch information
1 parent
8bc0d50
commit d0ac5de
Showing
11 changed files
with
1,162 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/rust-benchmark/target | ||
/rust-benchmark/Cargo.lock | ||
/assets/mobilenetv2-7.onnx |
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,13 @@ | ||
FROM rust:1.75 | ||
RUN rustup target add wasm32-wasi | ||
WORKDIR /usr/src | ||
ADD rust-benchmark rust-benchmark | ||
ADD assets assets | ||
WORKDIR /usr/src/rust-benchmark | ||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | ||
RUN cargo build --release --target wasm32-wasi | ||
RUN ls target/wasm32-wasi/release | ||
RUN mkdir /benchmark | ||
RUN cp target/wasm32-wasi/release/benchmark.wasm /benchmark/ | ||
# We output the Wasm file to the `/benchmark` directory, where the client | ||
# expects it. |
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,7 @@ | ||
# Image Classification Wasmtime Benchmark | ||
|
||
A benchmark that runs an image classifier in pure Wasm. This can be used to | ||
benchmark the performance of float heavy computations. | ||
|
||
Note that the classifier model is not included in the repo because it is large | ||
and is instead downloaded if needed when running the `setup.sh` script. |
Empty file.
1 change: 1 addition & 0 deletions
1
benchmarks/tract-onnx-image-classification/benchmark.stdout.expected
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 @@ | ||
[Classification { label: "tiger", score: 17.559244 }, Classification { label: "tiger cat", score: 14.740076 }, Classification { label: "zebra", score: 12.357242 }] |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions
16
benchmarks/tract-onnx-image-classification/rust-benchmark/Cargo.toml
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,16 @@ | ||
[package] | ||
name = "benchmark" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
bytes = "1.5.0" | ||
prost = "0.11.0" | ||
image = { version = "0.25.1", features = ["png"], default-features = false } | ||
tract-onnx = { git = "https://github.com/sonos/tract", version = "=0.21.4-pre" } |
Oops, something went wrong.