|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Script to re-vendor the WIT files that Wasmtime uses as defined by a
|
|
|
|
# particular tag in upstream repositories.
|
|
|
|
#
|
|
|
|
# This script is executed on CI to ensure that everything is up-to-date.
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
# The make_vendor function takes a base path (e.g., "wasi") and a list
|
|
|
|
# of packages in the format "name@tag". It constructs the full destination
|
|
|
|
# path, downloads the tarballs from GitHub, extracts the relevant files, and
|
|
|
|
# removes any unwanted directories.
|
|
|
|
make_vendor() {
|
|
|
|
local name=$1
|
|
|
|
local packages=$2
|
|
|
|
local path="crates/$name/wit/deps"
|
|
|
|
|
|
|
|
rm -rf $path
|
|
|
|
mkdir -p $path
|
|
|
|
|
|
|
|
for package in $packages; do
|
|
|
|
IFS='@' read -r repo tag <<< "$package"
|
|
|
|
mkdir -p $path/$repo
|
|
|
|
cached_extracted_dir="$cache_dir/$repo-$tag"
|
|
|
|
|
|
|
|
if [[ ! -d $cached_extracted_dir ]]; then
|
|
|
|
mkdir -p $cached_extracted_dir
|
|
|
|
curl -sL https://github.com/WebAssembly/wasi-$repo/archive/$tag.tar.gz | \
|
|
|
|
tar xzf - --strip-components=1 -C $cached_extracted_dir
|
|
|
|
rm -rf $cached_extracted_dir/wit/deps*
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -r $cached_extracted_dir/wit/* $path/$repo
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_dir=$(mktemp -d)
|
|
|
|
|
|
|
|
make_vendor "wasi" "
|
|
|
|
cli@v0.2.0
|
|
|
|
clocks@v0.2.0
|
|
|
|
filesystem@v0.2.0
|
|
|
|
io@v0.2.0
|
|
|
|
random@v0.2.0
|
|
|
|
sockets@v0.2.0
|
|
|
|
http@v0.2.0
|
|
|
|
"
|
|
|
|
|
|
|
|
make_vendor "wasi-http" "
|
|
|
|
cli@v0.2.0
|
|
|
|
clocks@v0.2.0
|
|
|
|
filesystem@v0.2.0
|
|
|
|
io@v0.2.0
|
|
|
|
random@v0.2.0
|
|
|
|
sockets@v0.2.0
|
|
|
|
http@v0.2.0
|
|
|
|
"
|
|
|
|
|
|
|
|
make_vendor "wasi-runtime-config" "runtime-config@c667fe6"
|
|
|
|
|
|
|
|
rm -rf $cache_dir
|
|
|
|
|
|
|
|
# Separately (for now), vendor the `wasi-nn` WIT files since their retrieval is
|
|
|
|
# slightly different than above.
|
|
|
|
repo=https://raw.githubusercontent.com/WebAssembly/wasi-nn
|
|
|
|
revision=e2310b
|
|
|
|
curl -L $repo/$revision/wasi-nn.witx -o crates/wasi-nn/witx/wasi-nn.witx
|
wasi-nn: use resources (#8873)
* wasi-nn: use resources
Recent discussion in the wasi-nn proposal (see [wasi-nn#59], e.g.) has
concluded that the right approach for representing wasi-nn "things"
(tensors, graph, etc.) is with a component model _resource_. This
sweeping change brings Wasmtime's implementation in line with that
decision.
Initially I had structured this PR to remove all of the WITX-based
implementation (#8530). But, after consulting in a Zulip [thread] on
what other WASI proposals aim to do, this PR pivoted to support _both_`
the WITX-based and WIT-based ABIs (e.g., preview1 era versus preview2,
component model era). What is clear is that the WITX-based specification
will remain "frozen in time" while the WIT-based implementation moves
forward.
What that means for this PR is a "split world" paradigm. In many places,
we have to distinguish between the `wit` and `witx` versions of the same
thing. This change isn't the end state yet: it's a big step forward
towards bringing Wasmtime back in line with the WIT spec but, despite my
best efforts, doesn't fully fix all the TODOs left behind over several
years of development. I have, however, taken the liberty to refactor and
fix various parts as I came across them (e.g., the ONNX backend). I plan
to continue working on this in future PRs to figure out a good error
paradigm (the current one is too wordy) and device residence.
[wasi-nn#59]: https://github.com/WebAssembly/wasi-nn/pull/59
[thread]: https://bytecodealliance.zulipchat.com/#narrow/stream/219900-wasi/topic/wasi-nn's.20preview1.20vs.20preview2.20timeline
prtest:full
* vet: audit `ort`-related crate updates
* Simplify `WasiNnView`
With @alexcrichton's help, this change removes the `trait WasiNnView`
and `struct WasiNnImpl` wrapping that the WIT-based implementation used
for accessing the host context. Instead, `WasiNnView` is now a `struct`
containing the mutable references it needs to make things work. This
unwraps one complex layer of abstraction, though it does have the
downside that it complicates CLI code to split borrows of `Host`.
* Temporarily disable WIT check
* Refactor errors to use `trappable_error_type`
This change simplifies the return types of the host implementations of
the WIT-based wasi-nn. There is more work to be done with errors, e.g.,
to catch up with the upstream decision to return errors as resources.
But this is better than the previous mess.
4 months ago
|
|
|
# TODO: the in-tree `wasi-nn` implementation does not yet fully support the
|
|
|
|
# latest WIT specification on `main`. To create a baseline for moving forward,
|
|
|
|
# the in-tree WIT incorporates some but not all of the upstream changes. This
|
|
|
|
# TODO can be removed once the implementation catches up with the spec.
|
|
|
|
# curl -L $repo/$revision/wit/wasi-nn.wit -o crates/wasi-nn/wit/wasi-nn.wit
|