Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pure Wasm image classification benchmark #270

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ exclude = [
"benchmarks/shootout-switch",
"benchmarks/shootout-xblabla20",
"benchmarks/shootout-xchacha20",
"engines/native/libengine"
"benchmarks/tract-onnx-image-classification",
"engines/native/libengine",
]
1 change: 1 addition & 0 deletions benchmarks/all.suite
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ shootout/shootout-switch.wasm
shootout/shootout-xblabla20.wasm
shootout/shootout-xchacha20.wasm
spidermonkey/benchmark.wasm
tract-onnx-image-classification/benchmark.wasm
6 changes: 3 additions & 3 deletions benchmarks/libsodium/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ RUN apt update && apt install -y wget xz-utils unzip git
# Download and extract the latest stable version of Zig and retrieve the
# `stable` branch of libsodium that can be built by it.
WORKDIR /
RUN wget https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz
RUN tar --extract --verbose --file=zig-linux-x86_64-0.11.0.tar.xz
ENV PATH="${PATH}:/zig-linux-x86_64-0.11.0"
RUN wget https://ziglang.org/download/0.12.0/zig-linux-x86_64-0.12.0.tar.xz
RUN tar --extract --verbose --file=zig-linux-x86_64-0.12.0.tar.xz
ENV PATH="${PATH}:/zig-linux-x86_64-0.12.0"
RUN echo "zig version = $(zig version)"
RUN wget https://github.com/jedisct1/libsodium/archive/stable.zip
RUN unzip stable.zip
Expand Down
Binary file modified benchmarks/libsodium/libsodium-aead_aegis128l.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_aegis256.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_aes256gcm.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_aes256gcm2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_chacha20poly1305.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_chacha20poly13052.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-aead_xchacha20poly1305.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth3.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth5.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth6.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-auth7.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box7.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box8.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box_easy.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box_easy2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box_seal.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-box_seed.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-chacha20.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-codecs.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core1.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core3.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core4.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core5.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core6.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core_ed25519.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-core_ristretto255.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-ed25519_convert.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-generichash.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-generichash2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-generichash3.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-hash.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-hash3.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-kdf.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-kdf_hkdf.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-keygen.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-kx.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-metamorphic.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-misuse.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-onetimeauth.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-onetimeauth2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-onetimeauth7.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-pwhash_argon2i.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-pwhash_argon2id.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-pwhash_scrypt.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-pwhash_scrypt_ll.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-randombytes.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult5.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult6.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult7.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult8.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult_ed25519.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-scalarmult_ristretto255.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox7.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox8.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox_easy.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretbox_easy2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-secretstream_xchacha20poly1305.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-shorthash.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-sign.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-siphashx24.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-sodium_core.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-sodium_utils.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-sodium_version.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-stream.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-stream2.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-stream3.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-stream4.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-verify1.wasm
Binary file not shown.
Binary file modified benchmarks/libsodium/libsodium-xchacha20.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions benchmarks/tract-onnx-image-classification/.gitignore
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
14 changes: 14 additions & 0 deletions benchmarks/tract-onnx-image-classification/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM rust:1.75
RUN rustup target add wasm32-wasi
WORKDIR /usr/src
ADD rust-benchmark rust-benchmark
ADD assets assets
ADD setup.sh setup.sh
RUN ./setup.sh
WORKDIR /usr/src/rust-benchmark
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN cargo build --release --target wasm32-wasi
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.
7 changes: 7 additions & 0 deletions benchmarks/tract-onnx-image-classification/README.md
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
Empty file.
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.
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 = "0.21.4"
Loading
Loading