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>
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 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 unsafe fn as_bytes(&self) -> &[u8] ⓘ
pub fn is_uniform(&self) -> bool
pub fn as_uniform(&self) -> Option<Tensor>
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>where
D: Datum + Copy,
pub fn cast_to_scalar<D>(&self) -> Result<D, Error>where D: Datum + Copy,
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>
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
Convert Self to a Tensor. Read more
source§impl PartialEq<TValue> for TValue
impl PartialEq<TValue> for TValue
impl Eq for TValue
impl StructuralEq for TValue
impl StructuralPartialEq for TValue
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
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 + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.