Skip to content

Commit

Permalink
chore: remove wasm32-unknown-unknown support
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Aug 13, 2024
1 parent 08aaa0f commit e2c4549
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 433 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,6 @@ jobs:
cargo test -p ort --verbose --features fetch-models -- --test-threads 1
# Test examples that use in-tree graphs (do NOT run any of the examples that download ~700 MB graphs from pyke parcel...)
cargo run --example custom-ops
test-wasm:
name: Test WebAssembly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install nightly Rust toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Run tests
working-directory: examples/webassembly
run: |
wasm-pack test --node
# Disable cross-compile until cross updates aarch64-unknown-linux-gnu to Ubuntu 22.04
# ref https://github.com/cross-rs/cross/pull/973
#cross-compile:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ WixTools/
**/*.onnx
**/*.ort
**/*.pbseq
!examples/webassembly/**/*.ort
!tests/data/*.onnx
!tests/data/*.ort

Expand Down
10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ members = [
'examples/yolov8',
'examples/modnet',
'examples/sentence-transformers',
'examples/training',
'examples/webassembly'
'examples/training'
]
default-members = [
'.',
Expand Down Expand Up @@ -49,7 +48,7 @@ codegen-units = 1

[package.metadata.docs.rs]
features = [ "ndarray", "half", "training", "operator-libraries", "fetch-models", "load-dynamic", "copy-dylibs" ]
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = [ "--cfg", "docsrs" ]

[features]
Expand Down Expand Up @@ -99,10 +98,6 @@ libc = { version = "0.2", optional = true }
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", optional = true, features = [ "std", "libloaderapi" ] }

[target.'cfg(target_family = "wasm")'.dependencies]
js-sys = "0.3"
web-sys = "0.3"

[dev-dependencies]
anyhow = "1.0"
ureq = "2.1"
Expand All @@ -112,7 +107,6 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [ "
glassbench = "0.4"
tokio = { version = "1.36", features = [ "test-util" ] }
tokio-test = "0.4.3"
wasm-bindgen-test = "0.3"

[[bench]]
name = "squeezenet"
Expand Down
16 changes: 7 additions & 9 deletions docs/pages/setup/platforms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ Here are the supported platforms and binary availability status, as of v2.0.0-rc
* ⭕ - Supported. Precompiled binaries not available.
* ❌ - Not supported.

| Platform | x86 | x86-64 | ARMv7 | ARM64 | WASM32 |
|:-------- |:------- |:------ |:------ |:------ |:------ |
| **Windows** || 🟢<sup>\*</sup> || 🔷<sup>\*</sup> ||
| **Linux** || 🟢† || 🔷‡ ||
| **macOS** || 🔷§ || 🔷 ||
| **iOS** ||||||
| **Android** ||||||
| **Web** ||||| 🔷¶ |
| Platform | x86 | x86-64 | ARMv7 | ARM64 |
|:-------- |:------- |:------ |:------ |:------ |
| **Windows** || 🟢<sup>\*</sup> || 🔷<sup>\*</sup> |
| **Linux** || 🟢† || 🔷‡ |
| **macOS** || 🔷§ || 🔷 |
| **iOS** |||||
| **Android** |||||

<div style={{ opacity: 0.5, display: 'flex', flexDirection: 'column', fontSize: '0.75rem' }}>
<p>\* A recent version of Windows 10/11 & Visual Studio 2022 are required for pyke binaries.</p>
<p>† glibc ≥ 2.31 (Ubuntu ≥ 20.04) required for pyke binaries.</p>
<p>‡ glibc ≥ 2.35 (Ubuntu ≥ 22.04) required for pyke binaries.</p>
<p>§ macOS ≥ 10.15 required.</p>
<p>¶ WASM supports a limited subset of ONNX Runtime features. For more info, see [the docs on WebAssembly support](/setup/webassembly).</p>
</div>

If your platform is marked as 🟢 or 🔷, you're in luck! Almost no setup will be required to get `ort` up and running.
Expand Down
26 changes: 0 additions & 26 deletions docs/pages/setup/webassembly.mdx

This file was deleted.

26 changes: 0 additions & 26 deletions examples/webassembly/Cargo.toml

This file was deleted.

75 changes: 0 additions & 75 deletions examples/webassembly/src/lib.rs

This file was deleted.

Binary file removed examples/webassembly/src/mnist.ort
Binary file not shown.
27 changes: 8 additions & 19 deletions ort-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,6 @@ fn prepare_libort_dir() -> (PathBuf, bool) {
println!("cargo:rustc-link-lib=static=noexcep_operators");
}

if target_arch == "wasm32" {
for lib in &["webassembly", "providers_js"] {
let lib_path = lib_dir.join(platform_format_lib(&format!("onnxruntime_{lib}")));
if lib_path.exists() {
println!("cargo:rustc-link-lib=static=onnxruntime_{lib}");
}
}
}

let protobuf_build = transform_dep(external_lib_dir.join("protobuf-build"), &profile);
add_search_dir(&protobuf_build);
for lib in ["protobuf-lited", "protobuf-lite", "protobuf"] {
Expand All @@ -245,17 +236,15 @@ fn prepare_libort_dir() -> (PathBuf, bool) {
println!("cargo:rustc-link-lib=static=nsync_cpp");
}

if target_arch != "wasm32" {
add_search_dir(transform_dep(external_lib_dir.join("pytorch_cpuinfo-build"), &profile));
let clog_path = transform_dep(external_lib_dir.join("pytorch_cpuinfo-build").join("deps").join("clog"), &profile);
if clog_path.exists() {
add_search_dir(clog_path);
} else {
add_search_dir(transform_dep(external_lib_dir.join("pytorch_clog-build"), &profile));
}
println!("cargo:rustc-link-lib=static=cpuinfo");
println!("cargo:rustc-link-lib=static=clog");
add_search_dir(transform_dep(external_lib_dir.join("pytorch_cpuinfo-build"), &profile));
let clog_path = transform_dep(external_lib_dir.join("pytorch_cpuinfo-build").join("deps").join("clog"), &profile);
if clog_path.exists() {
add_search_dir(clog_path);
} else {
add_search_dir(transform_dep(external_lib_dir.join("pytorch_clog-build"), &profile));
}
println!("cargo:rustc-link-lib=static=cpuinfo");
println!("cargo:rustc-link-lib=static=clog");

add_search_dir(transform_dep(external_lib_dir.join("re2-build"), &profile));
println!("cargo:rustc-link-lib=static=re2");
Expand Down
2 changes: 1 addition & 1 deletion ort-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub type ortchar = c_ushort;
#[cfg(not(target_os = "windows"))]
pub type ortchar = c_char;

#[cfg(any(target_arch = "x86_64", target_arch = "x86", target_arch = "wasm32"))]
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub type size_t = usize;
#[cfg(all(target_arch = "aarch64", target_os = "windows"))]
pub type size_t = c_ulonglong;
Expand Down
3 changes: 1 addition & 2 deletions src/execution_providers/xnnpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ impl ExecutionProvider for XNNPACKExecutionProvider {
cfg!(any(
target_arch = "aarch64",
all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
target_arch = "x86_64",
target_arch = "wasm32"
target_arch = "x86_64"
))
}

Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ pub(crate) mod tensor;
pub(crate) mod training;
pub(crate) mod util;
pub(crate) mod value;
#[cfg_attr(docsrs, doc(cfg(target_arch = "wasm32")))]
#[cfg(target_arch = "wasm32")]
pub mod wasm;

#[cfg(feature = "load-dynamic")]
use std::sync::Arc;
Expand Down
19 changes: 5 additions & 14 deletions src/session/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
use std::ffi::CString;
#[cfg(feature = "fetch-models")]
use std::fmt::Write;
#[cfg(not(target_arch = "wasm32"))]
use std::path::Path;
use std::{
any::Any,
marker::PhantomData,
path::Path,
ptr::{self, NonNull},
rc::Rc,
sync::{atomic::Ordering, Arc}
Expand Down Expand Up @@ -162,8 +161,6 @@ impl SessionBuilder {
/// newly optimized model to the given path (for 'offline' graph optimization).
///
/// Note that the file will only be created after the model is committed.
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
pub fn with_optimized_model_path<S: AsRef<str>>(self, path: S) -> Result<Self> {
#[cfg(windows)]
let path = path.as_ref().encode_utf16().chain([0]).collect::<Vec<_>>();
Expand All @@ -175,8 +172,6 @@ impl SessionBuilder {

/// Enables profiling. Profile information will be writen to `profiling_file` after profiling completes.
/// See [`Session::end_profiling`].
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
pub fn with_profiling<S: AsRef<str>>(self, profiling_file: S) -> Result<Self> {
#[cfg(windows)]
let profiling_file = profiling_file.as_ref().encode_utf16().chain([0]).collect::<Vec<_>>();
Expand Down Expand Up @@ -205,8 +200,8 @@ impl SessionBuilder {
}

/// Registers a custom operator library at the given library path.
#[cfg(all(feature = "operator-libraries", not(target_arch = "wasm32")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "operator-libraries", not(target_arch = "wasm32")))))]
#[cfg(feature = "operator-libraries")]
#[cfg_attr(docsrs, doc(cfg(feature = "operator-libraries")))]
pub fn with_operator_library(mut self, lib_path: impl AsRef<str>) -> Result<Self> {
let path_cstr = CString::new(lib_path.as_ref())?;

Expand All @@ -232,8 +227,6 @@ impl SessionBuilder {
}

/// Enables [`onnxruntime-extensions`](https://github.com/microsoft/onnxruntime-extensions) custom operators.
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
pub fn with_extensions(self) -> Result<Self> {
let status = ortsys![unsafe EnableOrtCustomOps(self.session_options_ptr.as_ptr())];
status_to_result(status).map_err(Error::CreateSessionOptions)?;
Expand All @@ -248,8 +241,8 @@ impl SessionBuilder {
}

/// Downloads a pre-trained ONNX model from the given URL and builds the session.
#[cfg(all(feature = "fetch-models", not(target_arch = "wasm32")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "fetch-models", not(target_arch = "wasm32")))))]
#[cfg(feature = "fetch-models")]
#[cfg_attr(docsrs, doc(cfg(feature = "fetch-models")))]
pub fn commit_from_url(self, model_url: impl AsRef<str>) -> Result<Session> {
let mut download_dir = ort_sys::internal::dirs::cache_dir()
.expect("could not determine cache directory")
Expand Down Expand Up @@ -299,8 +292,6 @@ impl SessionBuilder {
}

/// Loads an ONNX model from a file and builds the session.
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
pub fn commit_from_file<P>(mut self, model_filepath_ref: P) -> Result<Session>
where
P: AsRef<Path>
Expand Down
Loading

0 comments on commit e2c4549

Please sign in to comment.