Struct tract_data::prelude::Tensor [−][src]
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]
shape: &[usize],
alignment: usize
) -> Result<Tensor>
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]
dt: DatumType,
shape: &[usize],
alignment: usize
) -> Result<Tensor>
Create an uninitialized tensor with a given alignment (in bytes).
pub fn stack_tensors(
axis: usize,
tensors: &[impl Borrow<Tensor>]
) -> Result<Tensor>[src]
axis: usize,
tensors: &[impl Borrow<Tensor>]
) -> Result<Tensor>
pub unsafe fn clear<T: Datum + Zero>(&mut self)[src]
pub fn zero<T: Datum + Zero>(shape: &[usize]) -> Result<Tensor>[src]
pub fn zero_scalar<T: Datum + Zero>() -> Result<Tensor>[src]
pub fn zero_scalar_dt(dt: DatumType) -> 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]
dt: DatumType,
shape: &[usize],
alignment: usize
) -> Result<Tensor>
pub fn zero_aligned<T: Datum + Zero>(
shape: &[usize],
alignment: usize
) -> Result<Tensor>[src]
shape: &[usize],
alignment: usize
) -> Result<Tensor>
pub unsafe fn from_raw<T: Datum>(
shape: &[usize],
content: &[u8]
) -> Result<Tensor>[src]
shape: &[usize],
content: &[u8]
) -> Result<Tensor>
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]
shape: &[usize],
content: &[u8],
align: usize
) -> Result<Tensor>
pub unsafe fn from_raw_dt(
dt: DatumType,
shape: &[usize],
content: &[u8]
) -> Result<Tensor>[src]
dt: DatumType,
shape: &[usize],
content: &[u8]
) -> Result<Tensor>
pub unsafe fn from_raw_dt_align(
dt: DatumType,
shape: &[usize],
content: &[u8],
align: usize
) -> Result<Tensor>[src]
dt: DatumType,
shape: &[usize],
content: &[u8],
align: usize
) -> Result<Tensor>
pub unsafe fn from_slice_align<T: Datum>(
content: &[T],
align: usize
) -> Result<Tensor>[src]
content: &[T],
align: usize
) -> Result<Tensor>
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 fn strides(&self) -> &[isize]ⓘ[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(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(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]
&mut self,
range: impl RangeBounds<usize>,
src: &Tensor,
src_range: impl RangeBounds<usize>,
axis: usize
) -> Result<()>
pub unsafe fn assign_slice_unchecked(
&mut self,
range: impl RangeBounds<usize>,
src: &Tensor,
src_range: impl RangeBounds<usize>,
axis: usize
)[src]
&mut self,
range: impl RangeBounds<usize>,
src: &Tensor,
src_range: impl RangeBounds<usize>,
axis: usize
)
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]
&'a mut self
) -> Result<ArrayViewMutD<'a, D>>
Transform the data as a mutable ndarray::Array.
pub unsafe fn to_array_view_unchecked<'a, D: Datum>(
&'a self
) -> ArrayViewD<'a, D>[src]
&'a self
) -> ArrayViewD<'a, D>
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]
&'a mut self
) -> ArrayViewMutD<'a, D>
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]ⓘ[src]
Access the data as a slice.
pub unsafe fn as_slice_mut_unchecked<D: Datum>(&mut self) -> &mut [D]ⓘ[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]ⓘ[src]
pub unsafe fn as_bytes_mut(&mut self) -> &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]
fn hash<H: Hasher>(&self, state: &mut H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl IntoArcTensor for Tensor[src]
fn into_arc_tensor(self) -> Arc<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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,