Skip to main content

tract_data/
lib.rs

1#![allow(clippy::len_zero)]
2#![allow(clippy::missing_safety_doc)]
3
4pub extern crate itertools;
5
6#[macro_use]
7mod macros;
8
9/// A Smallvec instantiation with 4 embeddable values.
10///
11/// Used about everywhere in tract, for node inputs and outputs, or
12/// tensor dimensions.
13pub type TVec<T> = smallvec::SmallVec<[T; 4]>;
14
15pub type TractError = anyhow::Error;
16pub type TractResult<T> = anyhow::Result<T>;
17
18pub mod prelude {
19    pub use crate::TVec;
20    pub use crate::blob::Blob;
21    pub use crate::datum::{Datum, DatumType, QParams, round_ties_to_even};
22    pub use crate::dim::{Assertion, Symbol, SymbolScope, SymbolValues, TDim, ToDim};
23    pub use crate::tensor::litteral::*;
24    pub use crate::tensor::named::{NamedStorage, WeightSource};
25    pub use crate::tensor::plain_view::{PlainView, PlainViewMut};
26    pub use crate::tensor::storage::{PlainStorage, TensorStorage};
27    pub use crate::tensor::{IntoArcTensor, IntoTensor, Tensor, natural_strides};
28    #[cfg(feature = "complex")]
29    pub use crate::tensor::{reinterpret_complex_as_inner_dim, reinterpret_inner_dim_as_complex};
30    pub use crate::tvec;
31    pub use crate::{TractError, TractResult};
32    pub use crate::{
33        dispatch_copy, dispatch_copy_by_size, dispatch_datum, dispatch_datum_by_size,
34        dispatch_floatlike, dispatch_hash, dispatch_numbers, dispatch_signed,
35    };
36    pub use half::f16;
37    pub use itertools as tract_itertools;
38    #[cfg(feature = "complex")]
39    pub use num_complex::Complex;
40}
41
42pub mod internal {
43    pub use crate::datum::ClampCast;
44    pub use crate::dim::{DimLike, parse_tdim, solve_for};
45    // The module only: see dyn_eq's docs for why the trait itself must not be
46    // re-exported here.
47    pub use crate::dyn_eq;
48    pub use crate::exotic::ExoticFact;
49    pub use crate::prelude::*;
50    pub use crate::tensor::Approximation;
51    pub use crate::tensor::view::TensorView;
52    pub use crate::tensor::{clip_range_bounds, vector_size};
53    pub use crate::ulp::{UlpFloat, ulp_distance};
54    pub use anyhow::{Context as TractErrorContext, anyhow, bail, ensure, format_err};
55    pub use ndarray as tract_ndarray;
56    pub use num_integer;
57    pub use num_traits as tract_num_traits;
58    pub use smallvec as tract_smallvec;
59    pub type StaticName = std::borrow::Cow<'static, str>;
60}
61
62pub use dim::TooEarly;
63pub use half;
64
65pub mod knobs;
66
67mod blob;
68mod datum;
69mod dim;
70pub mod dyn_eq;
71mod exotic;
72pub mod npy;
73#[cfg(feature = "npz")]
74pub mod npz;
75mod scatter;
76mod tensor;
77pub mod ulp;