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::plain_view::{PlainView, PlainViewMut};
25    pub use crate::tensor::storage::{PlainStorage, TensorStorage};
26    pub use crate::tensor::{IntoArcTensor, IntoTensor, Tensor, natural_strides};
27    #[cfg(feature = "complex")]
28    pub use crate::tensor::{reinterpret_complex_as_inner_dim, reinterpret_inner_dim_as_complex};
29    pub use crate::tvec;
30    pub use crate::{TractError, TractResult};
31    pub use crate::{
32        dispatch_copy, dispatch_copy_by_size, dispatch_datum, dispatch_datum_by_size,
33        dispatch_floatlike, dispatch_hash, dispatch_numbers, dispatch_signed,
34    };
35    pub use half::f16;
36    pub use itertools as tract_itertools;
37    #[cfg(feature = "complex")]
38    pub use num_complex::Complex;
39}
40
41pub mod internal {
42    pub use crate::datum::ClampCast;
43    pub use crate::dim::{DimLike, parse_tdim, solve_for};
44    // The module only: see dyn_eq's docs for why the trait itself must not be
45    // re-exported here.
46    pub use crate::dyn_eq;
47    pub use crate::exotic::ExoticFact;
48    pub use crate::prelude::*;
49    pub use crate::tensor::Approximation;
50    pub use crate::tensor::view::TensorView;
51    pub use crate::tensor::{clip_range_bounds, vector_size};
52    pub use crate::ulp::{UlpFloat, ulp_distance};
53    pub use anyhow::{Context as TractErrorContext, anyhow, bail, ensure, format_err};
54    pub use ndarray as tract_ndarray;
55    pub use num_integer;
56    pub use num_traits as tract_num_traits;
57    pub use smallvec as tract_smallvec;
58    pub type StaticName = std::borrow::Cow<'static, str>;
59}
60
61pub use dim::TooEarly;
62pub use half;
63
64pub mod knobs;
65
66mod blob;
67mod datum;
68mod dim;
69pub mod dyn_eq;
70mod exotic;
71mod scatter;
72mod tensor;
73pub mod ulp;