Skip to content

Commit

Permalink
Add image classification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
berestovskyy committed Jun 20, 2024
1 parent 92c2e52 commit 0e1cc54
Show file tree
Hide file tree
Showing 19 changed files with 378 additions and 183 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/provision-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,15 @@ tar -xf "wasmtime-v${wasmtime_version}-x86_64-macos.tar.xz" --directory "${HOME}
mv "${HOME}/bin/wasmtime-v${wasmtime_version}-x86_64-macos/wasmtime" "${HOME}/bin/wasmtime"
rm "wasmtime-v${wasmtime_version}-x86_64-macos.tar.xz"

# Install wasi2ic
git clone https://github.com/wasm-forge/wasi2ic
cargo install --path wasi2ic --root "${HOME}"

# Install wasm-opt
version=117
curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-macos.tar.gz"
tar -xzf "binaryen-version_${version}-x86_64-macos.tar.gz" --directory "${HOME}/" --strip-components 1
rm "binaryen-version_${version}-x86_64-macos.tar.gz"

# Exit temporary directory.
popd
10 changes: 10 additions & 0 deletions .github/workflows/provision-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ tar -xf "wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz" --directory "${HOME}
mv "${HOME}/bin/wasmtime-v${wasmtime_version}-x86_64-linux/wasmtime" "${HOME}/bin/wasmtime"
rm "wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz"

# Install wasi2ic
git clone https://github.com/wasm-forge/wasi2ic
cargo install --path wasi2ic --root "${HOME}"

# Install wasm-opt
version=117
curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-linux.tar.gz"
tar -xzf "binaryen-version_${version}-x86_64-linux.tar.gz" --directory "${HOME}/" --strip-components 1
rm "binaryen-version_${version}-x86_64-linux.tar.gz"

# Set environment variables.
echo "$HOME/bin" >> $GITHUB_PATH
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/rust-image-classification-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: rust-image-classification
on:
push:
branches:
- master
pull_request:
paths:
- rust/image-classification/**
- .github/workflows/provision-darwin.sh
- .github/workflows/provision-linux.sh
- .github/workflows/rust-image-classification-example.yaml
- .ic-commit
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rust-image-classification-example-darwin:
runs-on: macos-12
steps:
- uses: actions/checkout@v1
- name: Provision Darwin
run: DFX_VERSION="0.20.2-beta.0" bash .github/workflows/provision-darwin.sh
- name: Remove networks.json
run: rm -f ~/.config/dfx/networks.json
- name: Rust Image Classification Darwin
run: |
dfx start --background
pushd rust/image-classification
make test
popd
rust-image-classification-example-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Provision Linux
run: DFX_VERSION="0.20.2-beta.0" bash .github/workflows/provision-linux.sh
- name: Remove networks.json
run: rm -f ~/.config/dfx/networks.json
- name: Rust Image Classification Linux
run: |
dfx start --background
pushd rust/image-classification
make test
popd
5 changes: 5 additions & 0 deletions rust/image-classification/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build]
target = ["wasm32-wasi"]

[target.wasm32-wasi]
rustflags = ["-Ctarget-feature=+simd128"]
2 changes: 2 additions & 0 deletions rust/image-classification/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ _MACOSX
target/
*.old.did
.idea
src/backend/assets/mobilenetv2-7.onnx
.env
Loading

0 comments on commit 0e1cc54

Please sign in to comment.