diff --git a/.github/actions/install-openvino/install.sh b/.github/actions/install-openvino/install.sh index b96ab5bd6d..54cb1269ec 100755 --- a/.github/actions/install-openvino/install.sh +++ b/.github/actions/install-openvino/install.sh @@ -2,23 +2,39 @@ 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="2020.4.287" + 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 OpenVINO checksum. -curl -sSL https://apt.repos.intel.com/openvino/2020/GPG-PUB-KEY-INTEL-OPENVINO-2020 > $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-2020 -echo "5f5cff8a2d26ba7de91942bd0540fa4d $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-2020" > $scriptdir/CHECKSUM +# 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 OpenVINO repository (deb). -sudo apt-key add $scriptdir/GPG-PUB-KEY-INTEL-OPENVINO-2020 -echo "deb https://apt.repos.intel.com/openvino/2020 all main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2020.list +# 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 OpenVINO package. -sudo apt install -y intel-openvino-runtime-ubuntu18-$version +# Install the OpenVINO package. +sudo apt install -y intel-openvino-runtime-$os_name$os_version_year-$version diff --git a/Cargo.lock b/Cargo.lock index d68c8fe12f..f75183da09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1933,9 +1933,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openvino" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5bdffdb7513e0edb1a8876e89739471405c4ef1b4fde51a8d5ffbe1d1d2f821" +checksum = "61670c4f1f1fbd3889b97d3772462f6f81d959859a9031c5603850b5dfe93a61" dependencies = [ "openvino-sys", "thiserror", @@ -1943,9 +1943,9 @@ dependencies = [ [[package]] name = "openvino-finder" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fa4b1ca518d244f2eaab6e8c42229cdcd5086fe1323db3db3817a0237a09e2" +checksum = "83a50d2e3f93a32f4b384583c1623f15eec4268a299ff86228b04c475744b5c6" dependencies = [ "cfg-if 1.0.0", "log", @@ -1953,9 +1953,9 @@ dependencies = [ [[package]] name = "openvino-sys" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8273c32d01900e47cc29f57c3c0a7e1c3a1ca9b3e974ed4a79f30012432db3a2" +checksum = "a35a2728ef9dd1663ed6640fbe329d7c5f334f5867796d4f6840a921b1f40604" dependencies = [ "cmake", "lazy_static", diff --git a/ci/run-wasi-nn-example.sh b/ci/run-wasi-nn-example.sh index 97b55362c6..6639ea949c 100755 --- a/ci/run-wasi-nn-example.sh +++ b/ci/run-wasi-nn-example.sh @@ -20,7 +20,7 @@ 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/bin/setupvars.sh +source /opt/intel/openvino_2021/bin/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 diff --git a/crates/wasi-nn/Cargo.toml b/crates/wasi-nn/Cargo.toml index bd0c8b726d..b594774ca5 100644 --- a/crates/wasi-nn/Cargo.toml +++ b/crates/wasi-nn/Cargo.toml @@ -17,7 +17,7 @@ anyhow = "1.0" wiggle = { path = "../wiggle", version = "=0.35.0" } # These dependencies are necessary for the wasi-nn implementation: -openvino = { version = "0.3.1", features = ["runtime-linking"] } +openvino = { version = "0.3.3", features = ["runtime-linking"] } thiserror = "1.0" [build-dependencies] diff --git a/crates/wasi-nn/src/openvino.rs b/crates/wasi-nn/src/openvino.rs index 817a0a3d6b..4d2a017796 100644 --- a/crates/wasi-nn/src/openvino.rs +++ b/crates/wasi-nn/src/openvino.rs @@ -40,7 +40,15 @@ impl Backend for OpenvinoBackend { .0 .as_mut() .expect("openvino::Core was previously constructed"); - let cnn_network = core.read_network_from_buffer(&xml, &weights)?; + let mut cnn_network = core.read_network_from_buffer(&xml, &weights)?; + + // TODO this is a temporary workaround. We need a more eligant way to specify the layout in the long run. + // However, without this newer versions of OpenVINO will fail due to parameter mismatch. + for i in 0..cnn_network.get_inputs_len()? { + let name = cnn_network.get_input_name(i)?; + cnn_network.set_input_layout(&name, Layout::NHWC)?; + } + let exec_network = core.load_network(&cnn_network, map_execution_target_to_string(target))?;