[][src]Struct tract_data::prelude::Tensor

pub struct Tensor { /* fields omitted */ }

Tensor is a concrete tensor in tract.

Implementations

impl Tensor[src]

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

Create an uninitialized tensor (dt as type paramater).

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

Create an uninitialized tensor (dt as regular parameter).

pub unsafe fn uninitialized_aligned<T: Datum>(
    shape: &[usize],
    alignment: usize
) -> Result<Tensor>
[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>
[src]

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

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

pub unsafe fn clear<T: Datum + Zero>(&mut self)[src]

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

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

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

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

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

Create an tensor from raw data.

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

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

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

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

pub unsafe fn from_slice_align<T: Datum>(
    content: &[T],
    align: usize
) -> Result<Tensor>
[src]

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

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

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get the shape of the tensor.

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

Get the number of valeus in the tensor.

pub fn strides(&self) -> &[isize]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get the shape of the tensor.

pub unsafe fn set_shape_unchecked(&mut self, shape: &[usize])[src]

Force the tensor shape, no consistency check.

pub fn set_shape(&mut self, shape: &[usize]) -> Result<()>[src]

Force the tensor shape.

pub fn permute_axes(self, axes: &[usize]) -> Result<Tensor>[src]

pub fn into_shape(mut self: Self, shape: &[usize]) -> Result<Tensor>[src]

Reshape the tensor to shape.

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

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

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

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

pub fn broadcast_scalar_to_shape(&self, shape: &[usize]) -> Result<Tensor>[src]

pub fn assign_slice(
    &mut self,
    range: impl RangeBounds<usize>,
    src: &Tensor,
    src_range: impl RangeBounds<usize>,
    axis: usize
) -> Result<()>
[src]

pub unsafe fn assign_slice_unchecked(
    &mut self,
    range: impl RangeBounds<usize>,
    src: &Tensor,
    src_range: impl RangeBounds<usize>,
    axis: usize
)
[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(&self, force_full: bool) -> Result<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 close_enough(&self, other: &Self, approx: bool) -> Result<()>[src]

Compare two tensors, allowing for rounding errors.

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

Transform the tensor into a ndarray::Array.

pub unsafe fn into_array_unchecked<D: Datum>(self) -> ArrayD<D>[src]

Transform the tensor into a ndarray::Array.

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

Transform the data as a ndarray::Array.

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

Transform the data as a mutable ndarray::Array.

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

Transform the data as a ndarray::Array.

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

Transform the data as a mutable ndarray::Array.

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

Access the data as a pointer.

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

Access the data as a pointer.

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

Access the data as a pointer.

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

Access the data as a mutable pointer.

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

Access the data as a slice.

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

Access the data as a mutable slice.

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Access the data as a slice.

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Access the data as a mutable slice.

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

Access the data as a scalar.

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

Access the data as a scalar.

pub unsafe fn as_bytes(&self) -> &[u8]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

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

pub fn as_uniform(&self) -> Option<Tensor>[src]

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

Optionnaly convert data to a tensor for a new DatumType.

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

Optionnaly convert data to a tensor for a new DatumType.

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

Access the data as a scalar, after a cast.

pub fn nth(&self, nth: usize) -> Result<Tensor>[src]

Access the nth element of the tensor, returned as a 0-rank Tensor

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

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

pub fn view(&self) -> TensorView<'_>[src]

pub fn view_at_prefix(&self, prefix: &[usize]) -> Result<TensorView<'_>>[src]

pub fn view_mut(&mut self) -> TensorView<'_>[src]

pub fn view_at_prefix_mut(&mut self, prefix: &[usize]) -> Result<TensorView<'_>>[src]

Trait Implementations

impl Clone for Tensor[src]

impl Debug for Tensor[src]

impl Default for Tensor[src]

impl Drop for Tensor[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<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<u32> for Tensor[src]

impl From<u64> 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> 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.