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
56
57
58
59
60
61
62
63
64
//! Engine-neutral inference seam.
//!
//! xberg runs its ONNX models — layout detection, table classification, document
//! orientation, and more — through a small backend abstraction rather than
//! calling an engine directly. Two traits split the concerns:
//!
//! - [`InferenceBackend`] loads an `.onnx` artifact into a session.
//! - [`InferenceSession`] runs it, exchanging [`InferenceTensor`] values.
//!
//! [`default_backend`] selects the engine at compile time via the `inference_ort`
//! cfg (set by `build.rs` whenever ONNX Runtime is linked, i.e. `ort-bundled` or
//! `ort-dynamic` is active): ONNX Runtime ([`ort_backend::OrtBackend`]) where it
//! links, the pure-Rust tract engine ([`tract_backend::TractBackend`]) on no-ORT
//! targets (WASM, Android x86_64). ORT stays the native default even when the
//! `tract` feature is also on — tract compiles alongside it there only so the two
//! engines can be compared in cross-engine parity tests.
//!
//! Not part of the language-binding surface — the whole module is `pub(crate)`
//! and its files are absent from `alef.toml` sources, so the generator emits
//! nothing for it.
//!
//! Since v5.0.0 (issue #1275).
// — so there it is `cfg(test)`-only, keeping non-test builds dead-code-clean.
pub use ;
pub use InferenceTensor;
/// Construct the default inference backend for this build.
///
/// Returns ONNX Runtime where it is linked (`inference_ort`), otherwise the
/// pure-Rust tract backend. The two are mutually exclusive *as the default*: on
/// native, ORT wins even when `tract` is compiled for parity tests; on no-ORT
/// targets only tract is available.
pub
/// tract-only builds (no ONNX Runtime linked): the pure-Rust engine is the default.
pub