Skip to main content

TValue

Struct TValue 

Source
pub struct TValue(/* private fields */);

Implementations§

Source§

impl TValue

Source

pub fn is_exclusive(&self) -> bool

Source

pub fn from_const(t: Arc<Tensor>) -> Self

Source

pub fn as_arc_tensor(&self) -> Option<&Arc<Tensor>>

Methods from Deref<Target = Tensor>§

Source

pub fn storage_as<T>(&self) -> Option<&T>
where T: TensorStorage,

Source

pub fn try_storage_as<T>(&self) -> Result<&T, Error>
where T: TensorStorage,

Source

pub fn as_plain(&self) -> Option<PlainView<'_>>

Returns an immutable PlainView if this tensor has plain storage.

Source

pub fn try_as_plain(&self) -> Result<PlainView<'_>, Error>

Returns an immutable PlainView, or an error if storage is not plain.

Source

pub fn is_plain(&self) -> bool

Returns true if this tensor uses plain (contiguous) storage.

Source

pub fn is_exotic(&self) -> bool

Returns true if this tensor uses exotic (non-plain) storage.

Source

pub fn exotic_fact(&self) -> Result<Option<Box<dyn ExoticFact>>, Error>

Build the ExoticFact matching this tensor’s storage, or None for plain tensors.

Source

pub fn rank(&self) -> usize

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

Source

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

Get the shape of the tensor.

Source

pub fn len(&self) -> usize

Get the number of values in the tensor.

Source

pub fn volume(&self) -> usize

Get the number of valeus in the tensor.

Source

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

Get the shape of the tensor.

Source

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

Source

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

Source

pub fn broadcast_vector_to_shape( &self, shape: &[usize], axis: usize, ) -> Result<Tensor, Error>

Source

pub fn datum_type(&self) -> DatumType

Get the datum type of the tensor.

Source

pub fn dump(&self, force_full: bool) -> Result<String, Error>

Dump the tensor in a human readable form.

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

Source

pub fn close_enough( &self, other: &Tensor, approx: impl Into<Approximation> + Debug, ) -> Result<(), Error>

Compare two tensors, allowing for rounding errors.

Source

pub fn ulp_comparison_dt(&self) -> DatumType

The float type ULP distances against this tensor are measured in.

Float tensors are compared in their own type, so an f16 comparison stays an f16 comparison. Anything else falls back to f32, matching what close_enough does for its tolerance check.

Source

pub fn max_ulp_distance( &self, other: &Tensor, ) -> Result<(u64, Option<usize>), Error>

Largest integer ULP distance between self and other, and the flat index where it occurs.

Comparison happens in Self::ulp_comparison_dt. See crate::ulp for the exact convention around signed zeros, infinities and NaN.

Source

pub fn to_plain_array_view<D>( &self, ) -> Result<ArrayBase<ViewRepr<&D>, Dim<IxDynImpl>>, Error>
where D: Datum,

Returns a plain array view of the tensor.

Errors if the storage is not plain or the datum type does not match D.

Source

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

Transform the data as a ndarray::Array.

Source

pub fn as_ptr<D>(&self) -> Result<*const D, Error>
where D: Datum,

Access the data as a pointer.

Source

pub unsafe fn as_ptr_unchecked<D>(&self) -> *const D
where D: Datum,

Access the data as a pointer.

Source

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

Access the data as a slice.

Source

pub fn to_scalar_tensor(&self) -> Result<Tensor, Error>

Make the tensor a scalar tensor (assumes it contains a single value).

Source

pub unsafe fn to_scalar_unchecked<D>(&self) -> &D
where D: Datum,

Access the data as a scalar.

Source

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

Source

pub fn is_uniform(&self) -> bool

Source

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

Source

pub fn is_all_zero(&self) -> Result<bool, Error>

Source

pub fn is_zero(&self) -> Result<bool, Error>

Source

pub fn cast_to<D>(&self) -> Result<Cow<'_, Tensor>, Error>
where D: Datum,

Optionnaly convert data to a tensor for a new DatumType.

Source

pub fn cast_to_dt(&self, dst_dt: DatumType) -> Result<Cow<'_, Tensor>, Error>

Optionnaly convert data to a tensor for a new DatumType.

Source

pub fn cast_to_scalar<D>(&self) -> Result<D, Error>
where D: Datum + Copy,

Access the data as a scalar, after a cast.

Source

pub fn nth(&self, nth: usize) -> Result<Tensor, Error>

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

Source

pub fn deep_clone(&self) -> Tensor

Source

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

Source

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

Source

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

Source

pub fn view_offsetting(&self, coords: &[usize]) -> Result<TensorView<'_>, Error>

Source

pub unsafe fn view_offsetting_unchecked( &self, coords: &[usize], ) -> TensorView<'_>

Source

pub fn offset_u8_as_i8(self: &Arc<Tensor>) -> Arc<Tensor>

Offsets the tensor as an i8 type if it’s an u8 type, otherwise passes it unchanged.

Source

pub fn offset_i8_as_u8(self: &Arc<Tensor>) -> Arc<Tensor>

Offsets the tensor as an u8 type if it’s an i8 type, otherwise passes it unchanged.

Source

pub fn to_aligned_default(&self) -> Result<Tensor, Error>

Trait Implementations§

Source§

impl Borrow<Tensor> for TValue

Source§

fn borrow(&self) -> &Tensor

Immutably borrows from an owned value. Read more
Source§

impl Clone for TValue

Source§

fn clone(&self) -> TValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for TValue

Source§

type Target = Tensor

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Eq for TValue

Source§

impl From<Tensor> for TValue

Source§

fn from(t: Tensor) -> Self

Converts to this type from the input type.
Source§

impl IntoArcTensor for TValue

Source§

fn into_arc_tensor(self) -> Arc<Tensor>

Convert Self to a Arc. Read more
Source§

impl IntoTensor for TValue

Source§

fn into_tensor(self) -> Tensor

Convert Self to a Tensor. Read more
Source§

impl PartialEq for TValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> DynEq for T
where T: Eq + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.