Skip to content

Commit e2c4549

Browse files
committed
chore: remove wasm32-unknown-unknown support
1 parent 08aaa0f commit e2c4549

File tree

14 files changed

+24
-433
lines changed

14 files changed

+24
-433
lines changed

.github/workflows/test.yml

-13
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ jobs:
5353
cargo test -p ort --verbose --features fetch-models -- --test-threads 1
5454
# Test examples that use in-tree graphs (do NOT run any of the examples that download ~700 MB graphs from pyke parcel...)
5555
cargo run --example custom-ops
56-
test-wasm:
57-
name: Test WebAssembly
58-
runs-on: ubuntu-latest
59-
steps:
60-
- uses: actions/checkout@v4
61-
- name: Install nightly Rust toolchain
62-
uses: dtolnay/rust-toolchain@nightly
63-
- name: Install wasm-pack
64-
run: cargo install wasm-pack
65-
- name: Run tests
66-
working-directory: examples/webassembly
67-
run: |
68-
wasm-pack test --node
6956
# Disable cross-compile until cross updates aarch64-unknown-linux-gnu to Ubuntu 22.04
7057
# ref https://github.com/cross-rs/cross/pull/973
7158
#cross-compile:

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ WixTools/
187187
**/*.onnx
188188
**/*.ort
189189
**/*.pbseq
190-
!examples/webassembly/**/*.ort
191190
!tests/data/*.onnx
192191
!tests/data/*.ort
193192

Cargo.toml

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ members = [
88
'examples/yolov8',
99
'examples/modnet',
1010
'examples/sentence-transformers',
11-
'examples/training',
12-
'examples/webassembly'
11+
'examples/training'
1312
]
1413
default-members = [
1514
'.',
@@ -49,7 +48,7 @@ codegen-units = 1
4948

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

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

102-
[target.'cfg(target_family = "wasm")'.dependencies]
103-
js-sys = "0.3"
104-
web-sys = "0.3"
105-
106101
[dev-dependencies]
107102
anyhow = "1.0"
108103
ureq = "2.1"
@@ -112,7 +107,6 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [ "
112107
glassbench = "0.4"
113108
tokio = { version = "1.36", features = [ "test-util" ] }
114109
tokio-test = "0.4.3"
115-
wasm-bindgen-test = "0.3"
116110

117111
[[bench]]
118112
name = "squeezenet"

docs/pages/setup/platforms.mdx

+7-9
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ Here are the supported platforms and binary availability status, as of v2.0.0-rc
1212
* ⭕ - Supported. Precompiled binaries not available.
1313
* ❌ - Not supported.
1414

15-
| Platform | x86 | x86-64 | ARMv7 | ARM64 | WASM32 |
16-
|:-------- |:------- |:------ |:------ |:------ |:------ |
17-
| **Windows** || 🟢<sup>\*</sup> || 🔷<sup>\*</sup> ||
18-
| **Linux** || 🟢† || 🔷‡ ||
19-
| **macOS** || 🔷§ || 🔷 ||
20-
| **iOS** ||||||
21-
| **Android** ||||||
22-
| **Web** ||||| 🔷¶ |
15+
| Platform | x86 | x86-64 | ARMv7 | ARM64 |
16+
|:-------- |:------- |:------ |:------ |:------ |
17+
| **Windows** || 🟢<sup>\*</sup> || 🔷<sup>\*</sup> |
18+
| **Linux** || 🟢† || 🔷‡ |
19+
| **macOS** || 🔷§ || 🔷 |
20+
| **iOS** |||||
21+
| **Android** |||||
2322

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

3230
If your platform is marked as 🟢 or 🔷, you're in luck! Almost no setup will be required to get `ort` up and running.

docs/pages/setup/webassembly.mdx

-26
This file was deleted.

examples/webassembly/Cargo.toml

-26
This file was deleted.

examples/webassembly/src/lib.rs

-75
This file was deleted.

examples/webassembly/src/mnist.ort

-33.7 KB
Binary file not shown.

ort-sys/build.rs

+8-19
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,6 @@ fn prepare_libort_dir() -> (PathBuf, bool) {
215215
println!("cargo:rustc-link-lib=static=noexcep_operators");
216216
}
217217

218-
if target_arch == "wasm32" {
219-
for lib in &["webassembly", "providers_js"] {
220-
let lib_path = lib_dir.join(platform_format_lib(&format!("onnxruntime_{lib}")));
221-
if lib_path.exists() {
222-
println!("cargo:rustc-link-lib=static=onnxruntime_{lib}");
223-
}
224-
}
225-
}
226-
227218
let protobuf_build = transform_dep(external_lib_dir.join("protobuf-build"), &profile);
228219
add_search_dir(&protobuf_build);
229220
for lib in ["protobuf-lited", "protobuf-lite", "protobuf"] {
@@ -245,17 +236,15 @@ fn prepare_libort_dir() -> (PathBuf, bool) {
245236
println!("cargo:rustc-link-lib=static=nsync_cpp");
246237
}
247238

248-
if target_arch != "wasm32" {
249-
add_search_dir(transform_dep(external_lib_dir.join("pytorch_cpuinfo-build"), &profile));
250-
let clog_path = transform_dep(external_lib_dir.join("pytorch_cpuinfo-build").join("deps").join("clog"), &profile);
251-
if clog_path.exists() {
252-
add_search_dir(clog_path);
253-
} else {
254-
add_search_dir(transform_dep(external_lib_dir.join("pytorch_clog-build"), &profile));
255-
}
256-
println!("cargo:rustc-link-lib=static=cpuinfo");
257-
println!("cargo:rustc-link-lib=static=clog");
239+
add_search_dir(transform_dep(external_lib_dir.join("pytorch_cpuinfo-build"), &profile));
240+
let clog_path = transform_dep(external_lib_dir.join("pytorch_cpuinfo-build").join("deps").join("clog"), &profile);
241+
if clog_path.exists() {
242+
add_search_dir(clog_path);
243+
} else {
244+
add_search_dir(transform_dep(external_lib_dir.join("pytorch_clog-build"), &profile));
258245
}
246+
println!("cargo:rustc-link-lib=static=cpuinfo");
247+
println!("cargo:rustc-link-lib=static=clog");
259248

260249
add_search_dir(transform_dep(external_lib_dir.join("re2-build"), &profile));
261250
println!("cargo:rustc-link-lib=static=re2");

ort-sys/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub type ortchar = c_ushort;
1919
#[cfg(not(target_os = "windows"))]
2020
pub type ortchar = c_char;
2121

22-
#[cfg(any(target_arch = "x86_64", target_arch = "x86", target_arch = "wasm32"))]
22+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
2323
pub type size_t = usize;
2424
#[cfg(all(target_arch = "aarch64", target_os = "windows"))]
2525
pub type size_t = c_ulonglong;

src/execution_providers/xnnpack.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl ExecutionProvider for XNNPACKExecutionProvider {
3939
cfg!(any(
4040
target_arch = "aarch64",
4141
all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
42-
target_arch = "x86_64",
43-
target_arch = "wasm32"
42+
target_arch = "x86_64"
4443
))
4544
}
4645

src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ pub(crate) mod tensor;
2727
pub(crate) mod training;
2828
pub(crate) mod util;
2929
pub(crate) mod value;
30-
#[cfg_attr(docsrs, doc(cfg(target_arch = "wasm32")))]
31-
#[cfg(target_arch = "wasm32")]
32-
pub mod wasm;
3330

3431
#[cfg(feature = "load-dynamic")]
3532
use std::sync::Arc;

src/session/builder.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
use std::ffi::CString;
33
#[cfg(feature = "fetch-models")]
44
use std::fmt::Write;
5-
#[cfg(not(target_arch = "wasm32"))]
6-
use std::path::Path;
75
use std::{
86
any::Any,
97
marker::PhantomData,
8+
path::Path,
109
ptr::{self, NonNull},
1110
rc::Rc,
1211
sync::{atomic::Ordering, Arc}
@@ -162,8 +161,6 @@ impl SessionBuilder {
162161
/// newly optimized model to the given path (for 'offline' graph optimization).
163162
///
164163
/// Note that the file will only be created after the model is committed.
165-
#[cfg(not(target_arch = "wasm32"))]
166-
#[cfg_attr(docsrs, doc(cfg(not(target_arch = "wasm32"))))]
167164
pub fn with_optimized_model_path<S: AsRef<str>>(self, path: S) -> Result<Self> {
168165
#[cfg(windows)]
169166
let path = path.as_ref().encode_utf16().chain([0]).collect::<Vec<_>>();
@@ -175,8 +172,6 @@ impl SessionBuilder {
175172

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

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

@@ -232,8 +227,6 @@ impl SessionBuilder {
232227
}
233228

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

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

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

0 commit comments

Comments
 (0)