1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use NonZeroUsize;
use ;
/// [XNNPACK execution provider](https://onnxruntime.ai/docs/execution-providers/Xnnpack-ExecutionProvider.html) for
/// ARM, x86, and WASM platforms.
///
/// # Threading
/// XNNPACK uses its own threadpool separate from the [`Session`](crate::session::Session)'s intra-op threadpool. If
/// most of your model's compute lies in nodes supported by XNNPACK (i.e. `Conv`, `Gemm`, `MatMul`), it's best to
/// disable the session intra-op threadpool to reduce contention:
/// ```no_run
/// # use core::num::NonZeroUsize;
/// # use ort::{ep, session::Session};
/// # fn main() -> ort::Result<()> {
/// # let env = ort::test_util::test_env().clone();
/// let session = Session::builder(&env)?
/// .with_intra_op_spinning(false)?
/// .with_intra_threads(1)?
/// .with_execution_providers([ep::XNNPACK::default()
/// .with_intra_op_num_threads(NonZeroUsize::new(4).unwrap())
/// .build()])?
/// .commit_from_file("model.onnx")?;
/// # Ok(())
/// # }
/// ```
;
impl_ep!;