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

Redesign Wasmtime's CLI #6925

Merged
merged 11 commits into from
Sep 11, 2023
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ wasmtime-runtime = { workspace = true }
clap = { workspace = true, features = ["color", "suggestions", "derive"] }
anyhow = { workspace = true }
target-lexicon = { workspace = true }
humantime = "2.0.0"
once_cell = { workspace = true }
listenfd = "1.0.0"
wat = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions ci/run-wasi-nn-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ pushd $WASMTIME_DIR/crates/wasi-nn/examples/classification-example
cargo build --release --target=wasm32-wasi
cp target/wasm32-wasi/release/wasi-nn-example.wasm $TMP_DIR
popd
cargo run -- run --mapdir fixture::$TMP_DIR \
--wasi-modules=experimental-wasi-nn $TMP_DIR/wasi-nn-example.wasm
cargo run -- run --dir fixture::$TMP_DIR -S nn $TMP_DIR/wasi-nn-example.wasm

# Build and run another example, this time using Wasmtime's graph flag to
# preload the model.
pushd $WASMTIME_DIR/crates/wasi-nn/examples/classification-example-named
cargo build --release --target=wasm32-wasi
cp target/wasm32-wasi/release/wasi-nn-example-named.wasm $TMP_DIR
popd
cargo run -- run --mapdir fixture::$TMP_DIR --wasi-nn-graph openvino::$TMP_DIR \
--wasi-modules=experimental-wasi-nn $TMP_DIR/wasi-nn-example-named.wasm
cargo run -- run --dir fixture::$TMP_DIR -S nn,nn-graph=openvino::$TMP_DIR \
$TMP_DIR/wasi-nn-example-named.wasm

# Clean up the temporary directory only if it was not specified (users may want
# to keep the directory around).
Expand Down
14 changes: 6 additions & 8 deletions crates/bench-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ use std::slice;
use std::{env, path::PathBuf};
use target_lexicon::Triple;
use wasmtime::{Engine, Instance, Linker, Module, Store};
use wasmtime_cli_flags::{CommonOptions, WasiModules};
use wasmtime_cli_flags::CommonOptions;
use wasmtime_wasi::{sync::WasiCtxBuilder, I32Exit, WasiCtx};

pub type ExitCode = c_int;
Expand Down Expand Up @@ -423,7 +423,7 @@ struct HostState {

impl BenchState {
fn new(
options: CommonOptions,
mut options: CommonOptions,
compilation_timer: *mut u8,
compilation_start: extern "C" fn(*mut u8),
compilation_end: extern "C" fn(*mut u8),
Expand Down Expand Up @@ -456,17 +456,15 @@ impl BenchState {
Ok(())
})?;

let epoch_interruption = options.epoch_interruption;
let fuel = options.fuel;
let epoch_interruption = options.wasm.epoch_interruption.unwrap_or(false);
let fuel = options.wasm.fuel;

let wasi_modules = options.wasi_modules.unwrap_or(WasiModules::default());

if wasi_modules.wasi_common {
if options.wasi.common != Some(false) {
wasmtime_wasi::add_to_linker(&mut linker, |cx| &mut cx.wasi)?;
}

#[cfg(feature = "wasi-nn")]
if wasi_modules.wasi_nn {
if options.wasi.nn == Some(true) {
wasmtime_wasi_nn::witx::add_to_linker(&mut linker, |cx| &mut cx.wasi_nn)?;
}

Expand Down
1 change: 1 addition & 0 deletions crates/cli-flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ file-per-thread-logger = { workspace = true }
pretty_env_logger = { workspace = true }
rayon = "1.5.0"
wasmtime = { workspace = true }
humantime = "2.0.0"

[features]
default = [
Expand Down
Loading