Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test WasmEdge WASI-NN examples
name: Build and Test WasmEdge WASI-NN OpenVINO backend

on:
push:
Expand Down Expand Up @@ -47,6 +47,7 @@ jobs:
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DWASMEDGE_PLUGIN_WASI_NN_BACKEND="OpenVINO" .;\
cmake --build build;"
- name: Build and run Rust example - Mobilenet
continue-on-error: true
run: |
bash -c "\
source /opt/intel/openvino_2021/bin/setupvars.sh;\
Expand All @@ -56,6 +57,7 @@ jobs:
./download_mobilenet.sh;\
wasmedge --dir .:. wasmedge-wasinn-example-mobilenet.wasm mobilenet.xml mobilenet.bin tensor-1x224x224x3-f32.bgr"
- name: Build and run Rust example - Mobilenet Image
continue-on-error: true
run: |
bash -c "\
source /opt/intel/openvino_2021/bin/setupvars.sh;\
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/build-pytorch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Test WasmEdge WASI-NN PyTorch backend

on:
push:
branches: [master]
paths-ignore:
- "**/*.md"
pull_request:
branches: [master]
paths-ignore:
- "**/*.md"

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
container:
image: wasmedge/wasmedge:latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install PyTorch
shell: bash
env:
PYTORCH_VERSION: "1.8.2"
PYTORCH_INSTALL_TO: "."
run: |
apt update
apt install unzip
bash ./scripts/install_libtorch.sh
- name: Build WasmEdge Wasi-NN with PyTorch backend using g++
shell: bash
env:
CMAKE_BUILD_TYPE: "Release"
PYTORCH_INSTALL_TO: "."
run: |
export Torch_DIR=$(pwd)/${PYTORCH_INSTALL_TO}/libtorch
git clone https://github.com/WasmEdge/WasmEdge
cd ./WasmEdge
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DWASMEDGE_PLUGIN_WASI_NN_BACKEND="PyTorch" .
cmake --build build
- name: Build and run Rust example - Mobilenet
shell: bash
env:
PYTORCH_INSTALL_TO: "."
run: |
export Torch_DIR=$(pwd)/${PYTORCH_INSTALL_TO}/libtorch
export LD_LIBRARY_PATH=$Torch_DIR/lib:$LD_LIBRARY_PATH
cd WasmEdge && cmake --install build && cd ..
cd pytorch-mobilenet-image
./download_data.sh
wasmedge --dir .:. wasmedge-wasinn-example-mobilenet-image.wasm mobilenet.pt input.jpg
28 changes: 22 additions & 6 deletions scripts/install_libtorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,26 @@ if [[ ! -n ${PYTORCH_VERSION} ]]; then
PYTORCH_VERSION="1.8.2"
fi

DOWNLOAD_TO=$1
if [ ! -d $1/libtorch ]; then
curl -s -L -O --remote-name-all https://download.pytorch.org/libtorch/lts/1.8/cpu/libtorch-cxx11-abi-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip
echo "b76d6dd4380e2233ce6f7654e672e13aae7c871231d223a4267ef018dcbfb616 libtorch-cxx11-abi-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" | sha256sum -c
unzip -q "libtorch-cxx11-abi-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip"
rm -f "libtorch-cxx11-abi-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip"
if [[ ! -n ${PYTORCH_INSTALL_TO} ]]; then
PYTORCH_INSTALL_TO=.
fi

PYTORCH_LINK="libtorch-cxx11-abi"
PYTORCH_SHA="b76d6dd4380e2233ce6f7654e672e13aae7c871231d223a4267ef018dcbfb616"

for i in "$@"; do
case $i in
--disable-cxx11-abi)
PYTORCH_LINK="libtorch"
PYTORCH_SHA="b5ddadc9addc054d8503f4086546f0cbcfdc3fc70087863bbd7b0e3300e3247f"
shift
;;
esac
done

if [ ! -d ${PYTORCH_INSTALL_TO}/libtorch ]; then
curl -s -L -O --remote-name-all https://download.pytorch.org/libtorch/lts/1.8/cpu/${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip
echo "${PYTORCH_SHA} ${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" | sha256sum -c
unzip -q "${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" -d ${PYTORCH_INSTALL_TO}
rm -f "${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip"
fi