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§
Implementations§
Trait Implementations§
Source§impl<'a> Clone for ValueOrView<'a>
impl<'a> Clone for ValueOrView<'a>
Source§fn clone(&self) -> ValueOrView<'a>
fn clone(&self) -> ValueOrView<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl ExtractBuffer for ValueOrView<'_>
impl ExtractBuffer for ValueOrView<'_>
Source§fn extract_buffer(self) -> Option<Buffer>
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>
impl<'a, T: 'static, S: Storage<Elem = T>, L: MutLayout> From<&'a TensorBase<S, L>> for ValueOrView<'a>
Source§fn from(val: &'a TensorBase<S, L>) -> Self
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>
impl<'a> From<&'a Value> for ValueOrView<'a>
Source§impl<T, L: MutLayout> From<TensorBase<Vec<T>, L>> for ValueOrView<'static>
impl<T, L: MutLayout> From<TensorBase<Vec<T>, L>> for ValueOrView<'static>
Source§fn from(val: TensorBase<Vec<T>, L>) -> Self
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>
impl<'a, T, L: MutLayout> From<TensorBase<ViewData<'a, T>, L>> for ValueOrView<'a>
Source§fn from(val: TensorBase<ViewData<'a, T>, L>) -> Self
fn from(val: TensorBase<ViewData<'a, T>, L>) -> Self
Converts to this type from the input type.
Source§impl From<Value> for ValueOrView<'static>
impl From<Value> for ValueOrView<'static>
Source§impl<'a> From<ValueView<'a>> for ValueOrView<'a>
impl<'a> From<ValueView<'a>> for ValueOrView<'a>
Source§impl Layout for ValueOrView<'_>
impl Layout for ValueOrView<'_>
Source§type Indices = DynIndices
type Indices = DynIndices
Iterator over indices in this tensor.
Source§fn offset(&self, index: Self::Index<'_>) -> Option<usize>
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 moreSource§fn stride(&self, dim: usize) -> usize
fn stride(&self, dim: usize) -> usize
Returns the offset between adjacent indices along dimension
dim
.Source§fn offset_unchecked(&self, index: Self::Index<'_>) -> usize
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
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
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
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
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 moreSource§fn min_data_len(&self) -> usize
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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