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
65
66
67
68
69
70
//! Tensor struct is an input or output tensor to an executorch program.
//!
//! The two core structs are [`TensorImplBase`] and [`TensorBase`]:
//! - [`TensorImplBase`] is a container for the tensor's data/shape/strides/etc, and a concrete tensor point to such
//! container. It does not own the data, only holds reference to it.
//! It is templated with immutable/mutable and typed/erased marker types, and usually not instantiated directly,
//! rather through [`TensorImpl`] and [`TensorImplMut`] type aliases.
//! - [`TensorBase`] is a "base" class for all immutable/mutable/typed/type-erased tensors though generics of marker
//! types. It points to a a tensor implementation and does not own it.
//! Usually it is not instantiated directly, rather through type aliases:
//! - [`Tensor`] typed immutable tensor.
//! - [`TensorMut`] typed mutable tensor.
//! - [`TensorAny`] type-erased immutable tensor.
//!
//! A [`ScalarType`] enum represents the possible scalar types of a typed-erased tensor, which can be converted into a
//! typed tensor and visa-versa using the
//! [`into_type_erased`](`TensorBase::into_type_erased`) and [`into_typed`](`TensorBase::into_typed`) methods.
//!
//! Both [`TensorImplBase`] and [`TensorBase`] are templated with a [`Data`] type, which is a trait that defines the
//! tensor data type. The [`DataMut`] and [`DataTyped`] traits are used to define mutable and typed data types,
//! extending the `Data` trait. The structs [`View`], [`ViewMut`], [`ViewAny`], and [`ViewMutAny`] are market types
//! that implement these traits, and a user should not implement them for their own types.
//!
//! The [`TensorPtr`] is a smart pointer to a tensor that also manage the lifetime of the [`TensorImpl`], the
//! underlying data buffer and the metadata (sizes/strides/etc arrays) of the tensor.
//! It has the most user-friendly API, but can not be used in `no_std` environments.
//!
//! In addition to all of the above safe tensors, the [`RawTensor`] and [`RawTensorImpl`] structs exists,
//! which match the Cpp `Tensor` and `TensorImpl` as close as possible. These struct do not enforce mutability
//! guarantees at all, and expose unsafe API, but may be useful to low level users who want to avoid code size
//! overhead (avoiding the regular tensor structs generics) of the safe API.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
use executorch_sys as sys;
/// A type that represents the sizes (dimensions) of a tensor.
pub type SizesType = SizesType;
/// A type that represents the order of the dimensions of a tensor.
pub type DimOrderType = DimOrderType;
/// A type that represents the strides of a tensor.
///
/// Strides are in units of the elements size, not in bytes.
pub type StridesType = StridesType;
pub use ;
pub use *;