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

WASI-NN OpenVINO backend error: "source slice length (13956476) does not match destination slice length (5233680) #9379

Closed
danbugs opened this issue Oct 6, 2024 · 2 comments · Fixed by #9473
Labels
bug Incorrect behavior in the current implementation that needs fixing

Comments

@danbugs
Copy link
Contributor

danbugs commented Oct 6, 2024

Test Case

Zipped Wasm file: wasi_nn_example.zip

Steps to Reproduce

(1) cargo component new wasi_nn_example

(2) add dependency to wit-bindgen in Cargo.toml. Here's the full Cargo.toml:

[package]
name = "wasi_nn_example"
version = "0.1.0"
edition = "2021"

[dependencies]
wit-bindgen = { version = "0.33.0",  default-features = false, features = ["macros"] }
image2tensor = "0.3.1"

[profile.release]
codegen-units = 1
opt-level = "s"
debug = false
strip = true
lto = true

[package.metadata.component]
package = "component:wasi-nn-example"

[package.metadata.component.dependencies]

(3) populate main.rs w/:

use std::fs;
use crate::wasi::nn::graph;
use crate::wasi::nn::graph::{ExecutionTarget, GraphEncoding};

wit_bindgen::generate!({
    path: "wit",
    world: "ml",
});

fn main() {
    let xml = fs::read_to_string("fixture/model.xml").unwrap();
    println!("Read graph XML, first 50 characters: {}", &xml[..50]);

    let weights = fs::read("fixture/model.bin").unwrap();
    println!("Read graph weights, size in bytes: {}", weights.len());

    let graph = graph::load(
        &[xml.into_bytes(), weights],
        GraphEncoding::Openvino,
        ExecutionTarget::Cpu,
    ).unwrap();
    println!("Loaded graph into wasi-nn with ID: {:#?}", graph);
}

(4) cargo component build --release

(5) wasmtime -Snn --dir .\fixture\::fixture ..\..\target\wasm32-wasip1\debug\wasi_nn_example.wasm

Expected Results

I expected the graph::load function to return a proper Graph and not panic. It's failing in the copy_from_slice here:

buffer.copy_from_slice(&weights);

Actual Results

wasmtime -Snn --dir .\fixture\::fixture ..\..\target\wasm32-wasip1\debug\wasi_nn_example.wasm  
Read graph XML, first 50 characters: <?xml version="1.0" ?>
<net name="mobilenet_v2_1.0
Read graph weights, size in bytes: 13956476
thread 'main' panicked at C:\Users\danil\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-wasi-nn-25.0.1\src\backend\openvino.rs:41:16:
source slice length (13956476) does not match destination slice length (5233680)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Versions and Environment

Wasmtime version or commit: v25.0.1

Operating system: Microsoft Windows 11 Pro

Architecture: x86_64

Extra Info

cargo-component version used: v0.16.0

I got the model.xml and model.bin from here: https://download.01.org/openvinotoolkit/fixtures/mobilenet/

cc: @abrown

@danbugs danbugs added the bug Incorrect behavior in the current implementation that needs fixing label Oct 6, 2024
@abrown
Copy link
Contributor

abrown commented Oct 7, 2024

@danbugs, take a look at intel/openvino-rs#143: the issue is a breaking change in how OpenVINO v2024.2 laid out its element type enum so if one is using pre-2024.2 bindings with a post-2024.2 library this issue pops up. The fix is in intel/openvino-rs#144. Can you confirm which version of OpenVINO you installed?

@danbugs
Copy link
Contributor Author

danbugs commented Oct 7, 2024

@danbugs, take a look at intel/openvino-rs#143: the issue is a breaking change in how OpenVINO v2024.2 laid out its element type enum so if one is using pre-2024.2 bindings with a post-2024.2 library this issue pops up. The fix is in intel/openvino-rs#144. Can you confirm which version of OpenVINO you installed?

@abrown ~ understood. I do haveOpenVINO 2024.4 installed!

abrown added a commit to abrown/wasmtime that referenced this issue Oct 16, 2024
Recent changes to OpenVINO's C bindings introduced breaking changes that
prevent use of older OpenVINO libraries with newer bindings (see
[openvino-rs#143] if you're interested in the details). This updates
both the bindings and the version of OpenVINO used to test against.

Fixes bytecodealliance#9379.

[openvino-rs#143]: intel/openvino-rs#143
github-merge-queue bot pushed a commit that referenced this issue Oct 16, 2024
* wasi-nn: update OpenVINO bindings

Recent changes to OpenVINO's C bindings introduced breaking changes that
prevent use of older OpenVINO libraries with newer bindings (see
[openvino-rs#143] if you're interested in the details). This updates
both the bindings and the version of OpenVINO used to test against.

Fixes #9379.

[openvino-rs#143]: intel/openvino-rs#143

* vet: certify openvino version updates

All of these updates include code I've reviewed.

* ci: update `install-openvino-action`

prtest:full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior in the current implementation that needs fixing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants