[][src]Struct tract_hir::internal::Tensor

pub struct Tensor { /* fields omitted */ }

Tensor is a concrete tensor in tract.

Implementations

impl Tensor[src]

pub unsafe fn uninitialized<T>(shape: &[usize]) -> Result<Tensor, TractError> where
    T: Datum
[src]

Create an uninitialized tensor (dt as type paramater).

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

Create an uninitialized tensor (dt as regular parameter).

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

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

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

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

pub fn stack_tensors(
    axis: usize,
    tensors: &[impl Borrow<Tensor>]
) -> Result<Tensor, TractError>
[src]

pub fn zero<T>(shape: &[usize]) -> Result<Tensor, TractError> where
    T: Datum + Zero
[src]

pub fn zero_dt(dt: DatumType, shape: &[usize]) -> Result<Tensor, TractError>[src]

pub unsafe fn from_raw<T>(
    shape: &[usize],
    content: &[u8]
) -> Result<Tensor, TractError> where
    T: Datum
[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]
) -> Result<Tensor, TractError>
[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]) -> Result<Tensor, TractError>[src]

Reshape the tensor to shape.

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

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

pub fn broadcast_into_rank(self, rank: usize) -> Result<Tensor, TractError>[src]

pub fn broadcast_to_rank(&mut self, rank: usize) -> Result<(), TractError>[src]

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

Get the datum type of the tensor.

pub unsafe fn set_datum_type(&mut self, dt: DatumType)[src]

Set the datum type of the tensor.

pub fn dump_t<D>(&self, force_full: bool) -> Result<String, TractError> where
    D: Datum
[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) -> Result<String, TractError>[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: &Tensor) -> Result<f64, TractError>[src]

Compute a normalized L1 distance between two tensors.

pub fn close_enough(
    &self,
    other: &Tensor,
    approx: bool
) -> Result<(), TractError>
[src]

Compare two tensors, allowing for rounding errors.

pub fn into_array<D>(
    self
) -> Result<ArrayBase<OwnedRepr<D>, Dim<IxDynImpl>>, TractError> where
    D: Datum
[src]

Transform the tensor into a ndarray::Array.

pub fn to_array_view<D>(
    &'a self
) -> Result<ArrayBase<ViewRepr<&'a D>, Dim<IxDynImpl>>, TractError> where
    D: Datum
[src]

Transform the data as a ndarray::Array.

pub fn to_array_view_mut<D>(
    &'a mut self
) -> Result<ArrayBase<ViewRepr<&'a mut D>, Dim<IxDynImpl>>, TractError> where
    D: Datum
[src]

Transform the data as a mutable ndarray::Array.

pub unsafe fn to_array_view_unchecked<D>(
    &'a self
) -> ArrayBase<ViewRepr<&'a D>, Dim<IxDynImpl>> where
    D: Datum
[src]

Transform the data as a ndarray::Array.

pub unsafe fn to_array_view_mut_unchecked<D>(
    &'a mut self
) -> ArrayBase<ViewRepr<&'a mut D>, Dim<IxDynImpl>> where
    D: Datum
[src]

Transform the data as a mutable ndarray::Array.

pub fn as_ptr<D>(&self) -> Result<*const D, TractError> where
    D: Datum
[src]

Access the data as a pointer.

pub fn as_ptr_mut<D>(&mut self) -> Result<*mut D, TractError> where
    D: Datum
[src]

Access the data as a mutable pointer.

pub fn as_slice<D>(&self) -> Result<&[D], TractError> where
    D: Datum
[src]

Access the data as a slice.

pub fn as_slice_mut<D>(&mut self) -> Result<&mut [D], TractError> where
    D: Datum
[src]

Access the data as a mutable slice.

pub unsafe fn as_slice_unchecked<D>(&self) -> &[D] where
    D: Datum
[src]

Access the data as a slice.

pub unsafe fn as_slice_mut_unchecked<D>(&mut self) -> &mut [D] where
    D: Datum
[src]

Access the data as a mutable slice.

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

Access the data as a scalar.

pub fn is_uniform(&self) -> Result<bool, TractError>[src]

pub fn cast_to<D>(&self) -> Result<Cow<Tensor>, TractError> where
    D: Datum
[src]

Optionnaly convert data to a tensor for a new DatumType.

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

Optionnaly convert data to a tensor for a new DatumType.

pub fn cast_to_scalar<D>(&self) -> Result<D, TractError> where
    D: Datum + Copy
[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
) -> Result<Tensor, TractError>
[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 NormalizedFact[src]

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

impl<D, T> From<ArrayBase<OwnedRepr<T>, D>> for Tensor where
    D: Dimension,
    T: Datum
[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<Tensor> for InferenceFact[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 Hash 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

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

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.