wasi-nn: update openvino crate, use external CI action (#4383)
* ci: replace OpenVINO installer action To test wasi-nn, we currently use an OpenVINO backend. The Wasmtime CI must install OpenVINO using a custom GitHub action. This CI action has not been updated in some time and in the meantime OpenVINO (and the OpenVINO crates) have released several new versions. https://github.com/abrown/install-openvino-action is an external action that we plan to keep up to date with the latest releases. This change replaces the current CI action with that one. * wasi-nn: upgrade openvino dependency to v0.4.1 This eliminates a `lazy_static` dependency and changes a few parameters to pass by reference. Importantly, it enables support for the latest versions of OpenVINO (v2022.*) in wasi-nn. * ci: update wasi-nn script to source correct env script * ci: really use the correct path for the env script Also, clarify which directory OpenVINO is installed in (the symlink may not be present).
This commit is contained in:
2
.github/actions/install-openvino/.gitignore
vendored
2
.github/actions/install-openvino/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
CHECKSUM
|
||||
GPG-PUB-KEY*
|
||||
8
.github/actions/install-openvino/README.md
vendored
8
.github/actions/install-openvino/README.md
vendored
@@ -1,8 +0,0 @@
|
||||
# install-openvino
|
||||
|
||||
A GitHub action to install OpenVINO from a package repository. This is only necessary for `wasi-nn` support but there
|
||||
are enough steps here to package the functionality separately and avoid cluttering the CI.
|
||||
|
||||
Future improvements:
|
||||
- make this installer work for different OS/distributions (e.g. https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_windows.html)
|
||||
- it would be nice to output the install directory (i.e. `/opt/intel/openvino`)
|
||||
13
.github/actions/install-openvino/action.yml
vendored
13
.github/actions/install-openvino/action.yml
vendored
@@ -1,13 +0,0 @@
|
||||
name: 'Install OpenVINO'
|
||||
description: 'Install OpenVINO binaries from a package repository; this is significantly faster than building from source'
|
||||
|
||||
inputs:
|
||||
version:
|
||||
description: 'The release version of OpenVINO to install'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: ${{ github.action_path }}/install.sh ${{ inputs.version }}
|
||||
shell: bash
|
||||
40
.github/actions/install-openvino/install.sh
vendored
40
.github/actions/install-openvino/install.sh
vendored
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Determine the OpenVINO version to install from the first parameter. Also, split out the parts of
|
||||
# this version; `${version_parts[0]}` should contain the year. E.g.:
|
||||
# version=2021.4.752
|
||||
# version_year=2021
|
||||
if [ "$#" -ne 1 ]; then
|
||||
version="2021.4.752"
|
||||
else
|
||||
version="$1"
|
||||
fi
|
||||
IFS='.' read -ra version_parts <<< "$version"
|
||||
version_year="${version_parts[0]}"
|
||||
|
||||
# Determine the OS name and version (Linux-specific for now). E.g.:
|
||||
# os_name=ubuntu
|
||||
# os_version=20.04
|
||||
# os_version_year=20
|
||||
eval $(source /etc/os-release; echo os_name="$ID"; echo os_version="$VERSION_ID";)
|
||||
IFS='.' read -ra os_version_parts <<< "$os_version"
|
||||
os_version_year="${os_version_parts[0]}"
|
||||
|
||||
# Determine the directory of this script. E.g.:
|
||||
# script_dir=/some/directory
|
||||
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Retrieve the OpenVINO checksum.
|
||||
curl -sSL https://apt.repos.intel.com/openvino/$version_year/GPG-PUB-KEY-INTEL-OPENVINO-$version_year > $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-$version_year
|
||||
echo "5f5cff8a2d26ba7de91942bd0540fa4d $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-$version_year" > $scriptdir/CHECKSUM
|
||||
md5sum --check $scriptdir/CHECKSUM
|
||||
|
||||
# Add the OpenVINO repository (DEB-specific for now).
|
||||
sudo apt-key add $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-$version_year
|
||||
echo "deb https://apt.repos.intel.com/openvino/$version_year all main" | sudo tee /etc/apt/sources.list.d/intel-openvino-$version_year.list
|
||||
sudo apt update
|
||||
|
||||
# Install the OpenVINO package.
|
||||
sudo apt install -y intel-openvino-runtime-$os_name$os_version_year-$version
|
||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -310,7 +310,7 @@ jobs:
|
||||
submodules: true
|
||||
- uses: ./.github/actions/install-rust
|
||||
- run: rustup target add wasm32-wasi
|
||||
- uses: ./.github/actions/install-openvino
|
||||
- uses: abrown/install-openvino-action@v3
|
||||
- run: ./ci/run-wasi-nn-example.sh
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -441,15 +441,6 @@ dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "component-macro-test"
|
||||
version = "0.1.0"
|
||||
@@ -1899,9 +1890,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "openvino"
|
||||
version = "0.3.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61670c4f1f1fbd3889b97d3772462f6f81d959859a9031c5603850b5dfe93a61"
|
||||
checksum = "d9627908ea4af5766040aa191c8607479af7f70b45fdf6e999b450069fea851a"
|
||||
dependencies = [
|
||||
"openvino-sys",
|
||||
"thiserror",
|
||||
@@ -1909,9 +1900,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openvino-finder"
|
||||
version = "0.3.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83a50d2e3f93a32f4b384583c1623f15eec4268a299ff86228b04c475744b5c6"
|
||||
checksum = "213893e484dcf3db4af79d498a955f7c4c209d06e7020779cda68fca779c2578"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
@@ -1919,14 +1910,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openvino-sys"
|
||||
version = "0.3.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a35a2728ef9dd1663ed6640fbe329d7c5f334f5867796d4f6840a921b1f40604"
|
||||
checksum = "e2ba37c26ad2591acc48abee5350d65daa263bf0ab7a79d2ab6999d4b20130ec"
|
||||
dependencies = [
|
||||
"cmake",
|
||||
"lazy_static",
|
||||
"libloading",
|
||||
"once_cell",
|
||||
"openvino-finder",
|
||||
"pretty_env_logger",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -20,10 +20,10 @@ fi
|
||||
|
||||
# Inform the environment of OpenVINO library locations. Then we use OPENVINO_INSTALL_DIR below to avoid building all of
|
||||
# OpenVINO from source (quite slow).
|
||||
source /opt/intel/openvino_2021/bin/setupvars.sh
|
||||
source /opt/intel/openvino_2022/setupvars.sh
|
||||
|
||||
# Build Wasmtime with wasi-nn enabled; we attempt this first to avoid extra work if the build fails.
|
||||
OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo build -p wasmtime-cli --features wasi-nn
|
||||
OPENVINO_INSTALL_DIR=/opt/intel/openvino_2022 cargo build -p wasmtime-cli --features wasi-nn
|
||||
|
||||
# Download all necessary test fixtures to the temporary directory.
|
||||
wget --no-clobber $FIXTURE/mobilenet.bin --output-document=$TMP_DIR/model.bin
|
||||
|
||||
@@ -17,7 +17,7 @@ anyhow = "1.0"
|
||||
wiggle = { path = "../wiggle", version = "=0.40.0" }
|
||||
|
||||
# These dependencies are necessary for the wasi-nn implementation:
|
||||
openvino = { version = "0.3.3", features = ["runtime-linking"] }
|
||||
openvino = { version = "0.4.1", features = ["runtime-linking"] }
|
||||
thiserror = "1.0"
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -87,10 +87,10 @@ impl BackendExecutionContext for OpenvinoExecutionContext {
|
||||
// should not have to default to NHWC.
|
||||
let desc = TensorDesc::new(Layout::NHWC, &dimensions, precision);
|
||||
let data = tensor.data.as_slice()?;
|
||||
let blob = openvino::Blob::new(desc, &data)?;
|
||||
let blob = openvino::Blob::new(&desc, &data)?;
|
||||
|
||||
// Actually assign the blob to the request.
|
||||
self.1.set_blob(&input_name, blob)?;
|
||||
self.1.set_blob(&input_name, &blob)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user