Enum tract_core::value::TValue
source · pub enum TValue {
Const(Arc<Tensor>),
Var(Rc<Tensor>),
}
Variants§
Implementations§
source§impl TValue
impl TValue
pub fn is_exclusive(&self) -> bool
pub fn from_const(t: Arc<Tensor>) -> Self
Methods from Deref<Target = Tensor>§
pub fn broadcast_scalar_to_shape( &self, shape: &[usize] ) -> Result<Tensor, Error>
pub fn broadcast_to_shape(&self, shape: &[usize]) -> Result<Tensor, Error>
pub fn broadcast_vector_to_shape( &self, shape: &[usize], axis: usize ) -> Result<Tensor, Error>
sourcepub fn datum_type(&self) -> DatumType
pub fn datum_type(&self) -> DatumType
Get the datum type of the tensor.
sourcepub fn dump(&self, force_full: bool) -> Result<String, Error>
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.
sourcepub fn close_enough(
&self,
other: &Tensor,
approx: impl Into<Approximation> + Debug
) -> Result<(), Error>
pub fn close_enough( &self, other: &Tensor, approx: impl Into<Approximation> + Debug ) -> Result<(), Error>
Compare two tensors, allowing for rounding errors.
sourcepub fn to_array_view<D>(
&self
) -> Result<ArrayBase<ViewRepr<&D>, Dim<IxDynImpl>>, Error>where
D: Datum,
pub fn to_array_view<D>(
&self
) -> Result<ArrayBase<ViewRepr<&D>, Dim<IxDynImpl>>, Error>where
D: Datum,
Transform the data as a ndarray::Array
.
sourcepub unsafe fn to_array_view_unchecked<D>(
&self
) -> ArrayBase<ViewRepr<&D>, Dim<IxDynImpl>>where
D: Datum,
pub unsafe fn to_array_view_unchecked<D>(
&self
) -> ArrayBase<ViewRepr<&D>, Dim<IxDynImpl>>where
D: Datum,
Transform the data as a ndarray::Array
.
sourcepub fn as_ptr<D>(&self) -> Result<*const D, Error>where
D: Datum,
pub fn as_ptr<D>(&self) -> Result<*const D, Error>where
D: Datum,
Access the data as a pointer.
sourcepub unsafe fn as_ptr_unchecked<D>(&self) -> *const Dwhere
D: Datum,
pub unsafe fn as_ptr_unchecked<D>(&self) -> *const Dwhere
D: Datum,
Access the data as a pointer.
sourcepub unsafe fn as_slice_unchecked<D>(&self) -> &[D]where
D: Datum,
pub unsafe fn as_slice_unchecked<D>(&self) -> &[D]where
D: Datum,
Access the data as a slice.
sourcepub fn to_scalar_tensor(&self) -> Result<Tensor, Error>
pub fn to_scalar_tensor(&self) -> Result<Tensor, Error>
Make the tensor a scalar tensor (assumes it contains a single value).
sourcepub unsafe fn to_scalar_unchecked<D>(&self) -> &Dwhere
D: Datum,
pub unsafe fn to_scalar_unchecked<D>(&self) -> &Dwhere
D: Datum,
Access the data as a scalar.
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn is_uniform(&self) -> bool
pub fn as_uniform(&self) -> Option<Tensor>
pub fn is_zero(&self) -> Result<bool, Error>
sourcepub fn cast_to<D>(&self) -> Result<Cow<'_, Tensor>, Error>where
D: Datum,
pub fn cast_to<D>(&self) -> Result<Cow<'_, Tensor>, Error>where
D: Datum,
Optionnaly convert data to a tensor for a new DatumType.
sourcepub fn cast_to_dt(&self, dst_dt: DatumType) -> Result<Cow<'_, Tensor>, Error>
pub fn cast_to_dt(&self, dst_dt: DatumType) -> Result<Cow<'_, Tensor>, Error>
Optionnaly convert data to a tensor for a new DatumType.
sourcepub fn cast_to_scalar<D>(&self) -> Result<D, Error>
pub fn cast_to_scalar<D>(&self) -> Result<D, Error>
Access the data as a scalar, after a cast.
sourcepub fn nth(&self, nth: usize) -> Result<Tensor, Error>
pub fn nth(&self, nth: usize) -> Result<Tensor, Error>
Access the nth element of the tensor, returned as a 0-rank Tensor
pub fn deep_clone(&self) -> Tensor
pub fn slice( &self, axis: usize, start: usize, end: usize ) -> Result<Tensor, Error>
pub fn view(&self) -> TensorView<'_>
pub fn view_at_prefix(&self, prefix: &[usize]) -> Result<TensorView<'_>, Error>
pub fn view_offsetting(&self, coords: &[usize]) -> Result<TensorView<'_>, Error>
pub unsafe fn view_offsetting_unchecked( &self, coords: &[usize] ) -> TensorView<'_>
sourcepub fn offset_u8_as_i8(self: &Arc<Tensor>) -> Arc<Tensor>
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.
sourcepub fn offset_i8_as_u8(self: &Arc<Tensor>) -> Arc<Tensor>
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.
pub fn to_aligned_default(&self) -> Result<Tensor, Error>
Trait Implementations§
source§impl IntoArcTensor for TValue
impl IntoArcTensor for TValue
source§impl IntoTensor for TValue
impl IntoTensor for TValue
source§fn into_tensor(self) -> Tensor
fn into_tensor(self) -> Tensor
source§impl PartialEq for TValue
impl PartialEq for TValue
impl Eq for TValue
Auto Trait Implementations§
impl Freeze for TValue
impl RefUnwindSafe for TValue
impl !Send for TValue
impl !Sync for TValue
impl Unpin for TValue
impl UnwindSafe for TValue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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