[][src]Struct tract_core::tensor::Tensor

pub struct Tensor { /* fields omitted */ }

Tensor is a concrete tensor in tract.

Methods

impl Tensor[src]

pub unsafe fn uninitialized<T: Datum>(shape: &[usize]) -> TractResult<Tensor>[src]

Create an uninitialized tensor (dt as type paramater).

pub unsafe fn uninitialized_dt(
    dt: DatumType,
    shape: &[usize]
) -> TractResult<Tensor>
[src]

Create an uninitialized tensor (dt as regular parameter).

pub unsafe fn uninitialized_aligned<T: Datum>(
    shape: &[usize],
    alignment: usize
) -> TractResult<Tensor>
[src]

Create an uninitialized tensor with a given alignment (in bytes).

pub unsafe fn uninitialized_aligned_dt(
    dt: DatumType,
    shape: &[usize],
    alignment: usize
) -> TractResult<Tensor>
[src]

Create an uninitialized tensor with a given alignment (in bytes).

pub unsafe fn from_raw<T: Datum>(
    shape: &[usize],
    content: &[u8]
) -> TractResult<Tensor>
[src]

Create an tensor from raw data.

It copies the data, aligning it to the size of T.

pub unsafe fn from_raw_dt(
    dt: DatumType,
    shape: &[usize],
    content: &[u8]
) -> TractResult<Tensor>
[src]

pub fn rank(&self) -> usize[src]

Get the number of dimensions (or axes) of the tensor.

pub fn shape(&self) -> &[usize][src]

Get the shape of the tensor.

pub fn len(&self) -> usize[src]

Get the number of valeus in the tensor.

pub unsafe fn into_shape(self, shape: &[usize]) -> TractResult<Tensor>[src]

Reshape the tensor to shape.

pub fn insert_axis(&mut self, axis: usize) -> TractResult<()>[src]

pub fn remove_axis(&mut self, axis: usize) -> TractResult<()>[src]

pub fn datum_type(&self) -> DatumType[src]

Get the datum type of the tensor.

pub fn dump_t<D: Datum>(&self, force_full: bool) -> TractResult<String>[src]

Dump the tensor in a human readable form.

force_full will force the tensor to be dump in full even if it is big.

pub fn dump(&self, force_full: bool) -> TractResult<String>[src]

Dump the tensor in a human readable form.

force_full will force the tensor to be dump in full even if it is big.

pub fn l1(&self, other: &Self) -> TractResult<f64>[src]

Compute a normalized L1 distance between two tensors.

pub fn close_enough(&self, other: &Self, approx: bool) -> TractResult<()>[src]

Compare two tensors, allowing for rounding errors.

pub fn into_array<D: Datum>(self) -> TractResult<ArrayD<D>>[src]

Transform the tensor into a ndarray::Array.

pub fn to_array_view<'a, D: Datum>(&'a self) -> TractResult<ArrayViewD<'a, D>>[src]

Transform the data as a ndarray::Array.

pub fn to_array_view_mut<'a, D: Datum>(
    &'a mut self
) -> TractResult<ArrayViewMutD<'a, D>>
[src]

Transform the data as a mutable ndarray::Array.

pub fn as_ptr<D: Datum>(&self) -> TractResult<*const D>[src]

Access the data as a pointer.

pub fn as_ptr_mut<D: Datum>(&mut self) -> TractResult<*mut D>[src]

Access the data as a mutable pointer.

pub fn as_slice<D: Datum>(&self) -> TractResult<&[D]>[src]

Access the data as a slice.

pub fn as_slice_mut<D: Datum>(&mut self) -> TractResult<&mut [D]>[src]

Access the data as a mutable slice.

pub fn to_scalar<'a, D: Datum>(&'a self) -> TractResult<&D>[src]

Access the data as a scalar.

pub fn is_uniform(&self) -> TractResult<bool>[src]

pub fn cast_to<D: Datum>(&self) -> TractResult<Cow<Tensor>>[src]

Optionnaly convert data to a tensor for a new DatumType.

pub fn cast_to_dt(&self, dt: DatumType) -> TractResult<Cow<Tensor>>[src]

Optionnaly convert data to a tensor for a new DatumType.

pub fn cast_to_scalar<D: Datum + Copy>(&self) -> TractResult<D>[src]

Access the data as a scalar, after a cast.

pub fn deep_clone(&self) -> Tensor[src]

pub fn slice(
    &self,
    axis: usize,
    start: usize,
    end: usize
) -> TractResult<Tensor>
[src]

Trait Implementations

impl Clone for Tensor[src]

impl Debug for Tensor[src]

impl Default for Tensor[src]

impl Drop for Tensor[src]

impl<'a> From<&'a Tensor> for InferenceFact[src]

impl<'t> From<&'t Tensor> for TypedFact[src]

impl<'t> From<&'t Tensor> for NormalizedFact[src]

impl<D: Dimension, T: Datum> From<ArrayBase<OwnedRepr<T>, D>> for Tensor[src]

impl From<Blob> for Tensor[src]

impl From<String> for Tensor[src]

impl From<TDim> for Tensor[src]

impl From<Tensor> for TypedFact[src]

impl From<bool> for Tensor[src]

impl From<f16> for Tensor[src]

impl From<f32> for Tensor[src]

impl From<f64> for Tensor[src]

impl From<i16> for Tensor[src]

impl From<i32> for Tensor[src]

impl From<i64> for Tensor[src]

impl From<i8> for Tensor[src]

impl From<u16> for Tensor[src]

impl From<u8> for Tensor[src]

impl IntoArcTensor for Tensor[src]

impl PartialEq<Tensor> for Tensor[src]

impl Send for Tensor[src]

impl Sync for Tensor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.