ValueOrView

Enum ValueOrView 

Source
pub enum ValueOrView<'a> {
    View(ValueView<'a>),
    Value(Value),
}
Expand description

An owned or borrowed value that can be used as a model or operator input.

Variants§

§

View(ValueView<'a>)

A borrowed view (like a slice)

§

Value(Value)

An owned value (like a Vec<T>)

Implementations§

Source§

impl ValueOrView<'_>

Source

pub fn as_view(&self) -> ValueView<'_>

Convert this value to a tensor view.

Source

pub fn to_owned(&self) -> Value

Convert this value to an owned tensor.

Source

pub fn into_owned(self) -> Value

Convert this value to an owned tensor.

Trait Implementations§

Source§

impl<'a> Clone for ValueOrView<'a>

Source§

fn clone(&self) -> ValueOrView<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ExtractBuffer for ValueOrView<'_>

Source§

fn extract_buffer(self) -> Option<Buffer>

Consume self and return its data buffer if it was uniquely owned, or None otherwise.
Source§

impl<'a, T: 'static, S: Storage<Elem = T>, L: MutLayout> From<&'a TensorBase<S, L>> for ValueOrView<'a>
where ValueView<'a>: From<TensorView<'a, T>>,

Source§

fn from(val: &'a TensorBase<S, L>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Value> for ValueOrView<'a>

Source§

fn from(val: &'a Value) -> Self

Converts to this type from the input type.
Source§

impl<T, L: MutLayout> From<TensorBase<Vec<T>, L>> for ValueOrView<'static>
where Value: From<Tensor<T>>, DynLayout: From<L>,

Source§

fn from(val: TensorBase<Vec<T>, L>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T, L: MutLayout> From<TensorBase<ViewData<'a, T>, L>> for ValueOrView<'a>
where ValueView<'a>: From<TensorView<'a, T>>,

Source§

fn from(val: TensorBase<ViewData<'a, T>, L>) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for ValueOrView<'static>

Source§

fn from(val: Value) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<ValueView<'a>> for ValueOrView<'a>

Source§

fn from(val: ValueView<'a>) -> Self

Converts to this type from the input type.
Source§

impl Layout for ValueOrView<'_>

Source§

type Index<'b> = SmallVec<[usize; 4]>

Type used to represent indices. Read more
Source§

type Indices = DynIndices

Iterator over indices in this tensor.
Source§

fn ndim(&self) -> usize

Return the number of dimensions.
Source§

fn offset(&self, index: Self::Index<'_>) -> Option<usize>

Map an index to a storage offset, or return None if the index is out of bounds along any dimension. Read more
Source§

fn len(&self) -> usize

Returns the number of elements in the array.
Source§

fn is_empty(&self) -> bool

Returns true if the array has no elements.
Source§

fn shape(&self) -> Self::Index<'_>

Returns an array of the sizes of each dimension.
Source§

fn size(&self, dim: usize) -> usize

Returns the size of the dimension dim.
Source§

fn strides(&self) -> Self::Index<'_>

Returns an array of the strides of each dimension.
Source§

fn stride(&self, dim: usize) -> usize

Returns the offset between adjacent indices along dimension dim.
Source§

fn indices(&self) -> Self::Indices

Return an iterator over all valid indices in this tensor.
Source§

fn offset_unchecked(&self, index: Self::Index<'_>) -> usize

Map an index to a storage offset, without checking if it is valid for the tensor’s shape. Read more
Source§

fn is_contiguous(&self) -> bool

Return true if this layout describes a contiguous tensor, where the logical order of elements matches the order in which they are stored.
Source§

fn is_broadcast(&self) -> bool

Return true if iterating over elements in this layout will visit elements multiple times.
Source§

fn can_broadcast_to(&self, target_shape: &[usize]) -> bool

Return true if this layout’s shape can be broadcast to the given shape.
Source§

fn can_broadcast_with(&self, shape: &[usize]) -> bool

Return true if the tensor/view can be broadcast with another tensor or view with a given shape as part of a binary operation. Read more
Source§

fn min_data_len(&self) -> usize

Return the minimum length required for the element data buffer used with this layout.

Auto Trait Implementations§

§

impl<'a> Freeze for ValueOrView<'a>

§

impl<'a> RefUnwindSafe for ValueOrView<'a>

§

impl<'a> Send for ValueOrView<'a>

§

impl<'a> Sync for ValueOrView<'a>

§

impl<'a> Unpin for ValueOrView<'a>

§

impl<'a> UnwindSafe for ValueOrView<'a>

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<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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.