webonnx / wonnx

A WebGPU-accelerated ONNX inference run-time written 100% in Rust, ready for native and the web
Other
1.54k stars 54 forks source link

`cargo install wonnx-cli` compile error #188

Closed schell closed 9 months ago

schell commented 9 months ago

Describe the bug cargo install wonnx-cli and cargo install --git https://github.com/webonnx/wonnx.git wonnx-cli fails with a compilation error:

   Compiling wonnx-preprocessing v0.5.0 (/Users/schell/.cargo/git/checkouts/wonnx-bca7827a70163d40/fbb7ab1/wonnx-preprocessing)
error[E0277]: a slice of type `&[u32]` cannot be built since we need to store the elements somewhere
    --> wonnx-preprocessing/src/text.rs:75:67
     |
75   |         let ids = encoding.get_tokens().iter().map(|x| *x as u32).collect();
     |                                                                   ^^^^^^^ try explicitly collecting into a `Vec<u32>`
     |
     = help: the trait `FromIterator<u32>` is not implemented for `&[u32]`
note: the method call chain might not have had the expected associated types
    --> wonnx-preprocessing/src/text.rs:75:48
     |
75   |         let ids = encoding.get_tokens().iter().map(|x| *x as u32).collect();
     |                   --------              ------ ^^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `u32` here
     |                   |                     |
     |                   |                     `Iterator::Item` is `&i64` here
     |                   this expression has type `&EncodedText`
note: required by a bound in `collect`
    --> /Users/schell/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1891:19
     |
1891 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `wonnx-preprocessing` (lib) due to previous error

rustup show

❯ rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/schell/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
nightly-2023-04-15-aarch64-apple-darwin
nightly-2023-05-27-aarch64-apple-darwin
nightly-aarch64-apple-darwin
1.70-aarch64-apple-darwin

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
wasm32-unknown-unknown

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.72.1 (d5c2e9c34 2023-09-13)

Desktop (please complete the following information):

pixelspark commented 9 months ago

Hm, apparently the published 0.5.0 version of wonnx-preprocessing fails to compile for some reason.

Could you try cloning the repository and running cargo run? This works for me on macOS with rustc 1.72.1 (d5c2e9c34 2023-09-13).

pixelspark commented 9 months ago

I was able to reproduce the error after cargo update. Will publish new versions of the crates.