pub struct TensorBase<S: Storage, L: MutLayout> { /* private fields */ }
Expand description
The base type for multi-dimensional arrays. This consists of storage for elements, plus a layout which maps from a multi-dimensional array index to a storage offset. This base type is not normally used directly but instead through a type alias which selects the storage type and layout.
The storage can be owned (like a Vec<T>
), borrowed (like &[T]
) or
mutably borrowed (like &mut [T]
). The layout can have a dimension count
that is determined statically (ie. forms part of the tensor’s type), see
NdLayout
or is only known at runtime, see DynLayout
.
Implementations§
Source§impl<S: Storage, L: MutLayout> TensorBase<S, L>
impl<S: Storage, L: MutLayout> TensorBase<S, L>
Sourcepub fn from_data<D: IntoStorage<Output = S>>(
shape: L::Index<'_>,
data: D,
) -> TensorBase<S, L>
pub fn from_data<D: IntoStorage<Output = S>>( shape: L::Index<'_>, data: D, ) -> TensorBase<S, L>
Construct a new tensor from a given shape and storage.
Panics if the data length does not match the product of shape
.
Sourcepub fn try_from_data<D: IntoStorage<Output = S>>(
shape: L::Index<'_>,
data: D,
) -> Result<TensorBase<S, L>, FromDataError>
pub fn try_from_data<D: IntoStorage<Output = S>>( shape: L::Index<'_>, data: D, ) -> Result<TensorBase<S, L>, FromDataError>
Construct a new tensor from a given shape and storage.
This will fail if the data length does not match the product of shape
.
Sourcepub fn from_storage_and_layout(data: S, layout: L) -> TensorBase<S, L>
pub fn from_storage_and_layout(data: S, layout: L) -> TensorBase<S, L>
Create a tensor from a pre-created storage and layout.
Panics if the storage length is too short for the layout, or the storage is mutable and the layout may map multiple indices to the same offset.
Sourcepub fn from_data_with_strides<D: IntoStorage<Output = S>>(
shape: L::Index<'_>,
data: D,
strides: L::Index<'_>,
) -> Result<TensorBase<S, L>, FromDataError>
pub fn from_data_with_strides<D: IntoStorage<Output = S>>( shape: L::Index<'_>, data: D, strides: L::Index<'_>, ) -> Result<TensorBase<S, L>, FromDataError>
Construct a new tensor from a given shape and storage, and custom strides.
This will fail if the data length is incorrect for the shape and stride
combination, or if the strides lead to overlap (see OverlapPolicy
).
See also TensorBase::from_slice_with_strides
which is a similar method
for immutable views that does allow overlapping strides.
Sourcepub fn into_dyn(self) -> TensorBase<S, DynLayout>
pub fn into_dyn(self) -> TensorBase<S, DynLayout>
Convert the current tensor into a dynamic rank tensor without copying any data.
Source§impl<S: StorageMut, L: MutLayout> TensorBase<S, L>
impl<S: StorageMut, L: MutLayout> TensorBase<S, L>
Sourcepub fn axis_iter_mut(&mut self, dim: usize) -> AxisIterMut<'_, S::Elem, L> ⓘwhere
L: RemoveDim,
pub fn axis_iter_mut(&mut self, dim: usize) -> AxisIterMut<'_, S::Elem, L> ⓘwhere
L: RemoveDim,
Return an iterator over mutable slices of this tensor along a given axis. Each view yielded has one dimension fewer than the current layout.
Sourcepub fn axis_chunks_mut(
&mut self,
dim: usize,
chunk_size: usize,
) -> AxisChunksMut<'_, S::Elem, L> ⓘ
pub fn axis_chunks_mut( &mut self, dim: usize, chunk_size: usize, ) -> AxisChunksMut<'_, S::Elem, L> ⓘ
Return an iterator over mutable slices of this tensor along a given
axis. Each view yielded has the same rank as this tensor, but the
dimension dim
will only have chunk_size
entries.
Sourcepub fn apply<F: Fn(&S::Elem) -> S::Elem>(&mut self, f: F)
pub fn apply<F: Fn(&S::Elem) -> S::Elem>(&mut self, f: F)
Replace each element in this tensor with the result of applying f
to
the element.
Sourcepub fn as_dyn_mut(&mut self) -> TensorBase<ViewMutData<'_, S::Elem>, DynLayout>
pub fn as_dyn_mut(&mut self) -> TensorBase<ViewMutData<'_, S::Elem>, DynLayout>
Return a mutable view of this tensor with a dynamic dimension count.
Sourcepub fn copy_from<S2: Storage<Elem = S::Elem>>(
&mut self,
other: &TensorBase<S2, L>,
)
pub fn copy_from<S2: Storage<Elem = S::Elem>>( &mut self, other: &TensorBase<S2, L>, )
Copy elements from another tensor into this tensor.
This tensor and other
must have the same shape.
Sourcepub fn data_mut(&mut self) -> Option<&mut [S::Elem]>
pub fn data_mut(&mut self) -> Option<&mut [S::Elem]>
Return the data in this tensor as a slice if it is contiguous.
Sourcepub fn index_axis_mut(
&mut self,
axis: usize,
index: usize,
) -> TensorBase<ViewMutData<'_, S::Elem>, <L as RemoveDim>::Output>where
L: RemoveDim,
pub fn index_axis_mut(
&mut self,
axis: usize,
index: usize,
) -> TensorBase<ViewMutData<'_, S::Elem>, <L as RemoveDim>::Output>where
L: RemoveDim,
Index the tensor along a given axis.
Returns a mutable view with one dimension removed.
Panics if axis >= self.ndim()
or index >= self.size(axis)
.
Sourcepub fn storage_mut(&mut self) -> ViewMutData<'_, S::Elem>
pub fn storage_mut(&mut self) -> ViewMutData<'_, S::Elem>
Return a mutable view of the tensor’s underlying storage.
Sourcepub fn get_mut<I: AsIndex<L>>(&mut self, index: I) -> Option<&mut S::Elem>
pub fn get_mut<I: AsIndex<L>>(&mut self, index: I) -> Option<&mut S::Elem>
Return a mutable reference to the element at index
, or None
if the
index is invalid.
Sourcepub unsafe fn get_unchecked_mut<I: AsIndex<L>>(
&mut self,
index: I,
) -> &mut S::Elem
pub unsafe fn get_unchecked_mut<I: AsIndex<L>>( &mut self, index: I, ) -> &mut S::Elem
Return the element at a given index, without performing any bounds- checking.
§Safety
The caller must ensure that the index is valid for the tensor’s shape.
Sourcepub fn inner_iter_mut<const N: usize>(
&mut self,
) -> InnerIterMut<'_, S::Elem, NdLayout<N>> ⓘ
pub fn inner_iter_mut<const N: usize>( &mut self, ) -> InnerIterMut<'_, S::Elem, NdLayout<N>> ⓘ
Return a mutable iterator over the N innermost dimensions of this tensor.
Sourcepub fn inner_iter_dyn_mut(
&mut self,
n: usize,
) -> InnerIterMut<'_, S::Elem, DynLayout> ⓘ
pub fn inner_iter_dyn_mut( &mut self, n: usize, ) -> InnerIterMut<'_, S::Elem, DynLayout> ⓘ
Return a mutable iterator over the n innermost dimensions of this tensor.
Prefer inner_iter_mut
if N
is known
at compile time.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, S::Elem> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, S::Elem> ⓘ
Return a mutable iterator over the elements of this tensor, in their logical order.
Sourcepub fn lanes_mut(&mut self, dim: usize) -> LanesMut<'_, S::Elem> ⓘ
pub fn lanes_mut(&mut self, dim: usize) -> LanesMut<'_, S::Elem> ⓘ
Return an iterator over mutable 1D slices of this tensor along a given dimension.
Sourcepub fn nd_view_mut<const N: usize>(
&mut self,
) -> TensorBase<ViewMutData<'_, S::Elem>, NdLayout<N>>
pub fn nd_view_mut<const N: usize>( &mut self, ) -> TensorBase<ViewMutData<'_, S::Elem>, NdLayout<N>>
Return a view of this tensor with a static dimension count.
Panics if self.ndim() != N
.
Sourcepub fn permuted_mut(
&mut self,
order: L::Index<'_>,
) -> TensorBase<ViewMutData<'_, S::Elem>, L>
pub fn permuted_mut( &mut self, order: L::Index<'_>, ) -> TensorBase<ViewMutData<'_, S::Elem>, L>
Permute the order of dimensions according to the given order.
See AsView::permuted
.
Sourcepub fn reshaped_mut<SH: IntoLayout>(
&mut self,
shape: SH,
) -> Result<TensorBase<ViewMutData<'_, S::Elem>, SH::Layout>, ReshapeError>
pub fn reshaped_mut<SH: IntoLayout>( &mut self, shape: SH, ) -> Result<TensorBase<ViewMutData<'_, S::Elem>, SH::Layout>, ReshapeError>
Change the layout of the tensor without moving any data.
This will return an error if the view is not contiguous.
See also AsView::reshaped
.
Sourcepub fn slice_axis_mut(
&mut self,
axis: usize,
range: Range<usize>,
) -> TensorBase<ViewMutData<'_, S::Elem>, L>
pub fn slice_axis_mut( &mut self, axis: usize, range: Range<usize>, ) -> TensorBase<ViewMutData<'_, S::Elem>, L>
Slice this tensor along a given axis.
Sourcepub fn slice_mut<R: IntoSliceItems + IndexCount>(
&mut self,
range: R,
) -> TensorBase<ViewMutData<'_, S::Elem>, <L as SliceWith<R, R::Count>>::Layout>where
L: SliceWith<R, R::Count>,
pub fn slice_mut<R: IntoSliceItems + IndexCount>(
&mut self,
range: R,
) -> TensorBase<ViewMutData<'_, S::Elem>, <L as SliceWith<R, R::Count>>::Layout>where
L: SliceWith<R, R::Count>,
Slice this tensor and return a mutable view.
See slice
for notes on the layout of the returned
view.
Sourcepub fn try_slice_mut<R: IntoSliceItems + IndexCount>(
&mut self,
range: R,
) -> Result<TensorBase<ViewMutData<'_, S::Elem>, <L as SliceWith<R, R::Count>>::Layout>, SliceError>where
L: SliceWith<R, R::Count>,
pub fn try_slice_mut<R: IntoSliceItems + IndexCount>(
&mut self,
range: R,
) -> Result<TensorBase<ViewMutData<'_, S::Elem>, <L as SliceWith<R, R::Count>>::Layout>, SliceError>where
L: SliceWith<R, R::Count>,
A variant of slice_mut
that returns a
result instead of panicking.
Sourcepub fn view_mut(&mut self) -> TensorBase<ViewMutData<'_, S::Elem>, L>where
L: Clone,
pub fn view_mut(&mut self) -> TensorBase<ViewMutData<'_, S::Elem>, L>where
L: Clone,
Return a mutable view of this tensor.
Sourcepub fn weakly_checked_view_mut(
&mut self,
) -> WeaklyCheckedView<ViewMutData<'_, S::Elem>, L>
pub fn weakly_checked_view_mut( &mut self, ) -> WeaklyCheckedView<ViewMutData<'_, S::Elem>, L>
Return a mutable view that performs only “weak” checking when indexing,
this is faster but can hide bugs. See WeaklyCheckedView
.
Source§impl<T, L: Clone + MutLayout> TensorBase<Vec<T>, L>
impl<T, L: Clone + MutLayout> TensorBase<Vec<T>, L>
Sourcepub fn arange(start: T, end: T, step: Option<T>) -> TensorBase<Vec<T>, L>
pub fn arange(start: T, end: T, step: Option<T>) -> TensorBase<Vec<T>, L>
Create a new 1D tensor filled with an arithmetic sequence of values
in the range [start, end)
separated by step
. If step
is omitted,
it defaults to 1.
Sourcepub fn append<S2: Storage<Elem = T>>(
&mut self,
axis: usize,
other: &TensorBase<S2, L>,
) -> Result<(), ExpandError>where
T: Copy,
pub fn append<S2: Storage<Elem = T>>(
&mut self,
axis: usize,
other: &TensorBase<S2, L>,
) -> Result<(), ExpandError>where
T: Copy,
Append elements from other
to this tensor along a given axis.
This will fail if the shapes of self
and other
do not match along
dimensions other than axis
, or if the current tensor has
insufficient capacity to expand without re-allocating.
Sourcepub fn from_vec(vec: Vec<T>) -> TensorBase<Vec<T>, L>
pub fn from_vec(vec: Vec<T>) -> TensorBase<Vec<T>, L>
Create a new 1D tensor from a Vec<T>
.
Sourcepub fn clip_dim(&mut self, dim: usize, range: Range<usize>)where
T: Copy,
pub fn clip_dim(&mut self, dim: usize, range: Range<usize>)where
T: Copy,
Clip dimension dim
to [range.start, range.end)
. The new size for
the dimension must be <= the old size.
This currently requires T: Copy
to support efficiently moving data
from the new start offset to the beginning of the element buffer.
Sourcepub fn has_capacity(&self, axis: usize, new_size: usize) -> bool
pub fn has_capacity(&self, axis: usize, new_size: usize) -> bool
Return true if this tensor can be expanded along a given axis to a new size without re-allocating.
Sourcepub fn into_cow(self) -> TensorBase<CowData<'static, T>, L>
pub fn into_cow(self) -> TensorBase<CowData<'static, T>, L>
Convert the storage of this tensor into an owned CowData
.
This is useful in contexts where code needs to conditionally copy or
create a new tensor. See AsView::as_cow
.
Sourcepub fn into_data(self) -> Vec<T>where
T: Clone,
pub fn into_data(self) -> Vec<T>where
T: Clone,
Consume self and return the underlying data as a contiguous tensor.
See also TensorBase::to_vec
.
Sourcepub fn into_non_contiguous_data(self) -> Vec<T>
pub fn into_non_contiguous_data(self) -> Vec<T>
Consume self and return the underlying data in whatever order the elements are currently stored.
Sourcepub fn into_shape<S: IntoLayout>(
self,
shape: S,
) -> TensorBase<Vec<T>, S::Layout>where
T: Clone,
pub fn into_shape<S: IntoLayout>(
self,
shape: S,
) -> TensorBase<Vec<T>, S::Layout>where
T: Clone,
Consume self and return a new contiguous tensor with the given shape.
This avoids copying the data if it is already contiguous.
Sourcepub fn from_fn<F: FnMut(L::Index<'_>) -> T, Idx>(
shape: L::Index<'_>,
f: F,
) -> TensorBase<Vec<T>, L>
pub fn from_fn<F: FnMut(L::Index<'_>) -> T, Idx>( shape: L::Index<'_>, f: F, ) -> TensorBase<Vec<T>, L>
Create a new tensor with a given shape and values generated by calling
f
repeatedly.
Each call to f
will receive an element index and should return the
corresponding value. If the function does not need this index, use
from_simple_fn
instead, as it is faster.
Sourcepub fn from_simple_fn<F: FnMut() -> T>(
shape: L::Index<'_>,
f: F,
) -> TensorBase<Vec<T>, L>
pub fn from_simple_fn<F: FnMut() -> T>( shape: L::Index<'_>, f: F, ) -> TensorBase<Vec<T>, L>
Create a new tensor with a given shape and values generated by calling
f
repeatedly.
Sourcepub fn from_simple_fn_in<A: Alloc, F: FnMut() -> T>(
alloc: A,
shape: L::Index<'_>,
f: F,
) -> TensorBase<Vec<T>, L>
pub fn from_simple_fn_in<A: Alloc, F: FnMut() -> T>( alloc: A, shape: L::Index<'_>, f: F, ) -> TensorBase<Vec<T>, L>
Variant of from_simple_fn
that takes
an allocator.
Sourcepub fn from_scalar(value: T) -> TensorBase<Vec<T>, L>
pub fn from_scalar(value: T) -> TensorBase<Vec<T>, L>
Create a new 0D tensor from a scalar value.
Sourcepub fn full(shape: L::Index<'_>, value: T) -> TensorBase<Vec<T>, L>where
T: Clone,
pub fn full(shape: L::Index<'_>, value: T) -> TensorBase<Vec<T>, L>where
T: Clone,
Create a new tensor with a given shape and all elements set to value
.
Sourcepub fn full_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
value: T,
) -> TensorBase<Vec<T>, L>where
T: Clone,
pub fn full_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
value: T,
) -> TensorBase<Vec<T>, L>where
T: Clone,
Variant of full
which takes an allocator.
Sourcepub fn make_contiguous(&mut self)where
T: Clone,
pub fn make_contiguous(&mut self)where
T: Clone,
Make the underlying data in this tensor contiguous.
This means that after calling make_contiguous
, the elements are
guaranteed to be stored in the same order as the logical order in
which iter
yields elements. This method is cheap if the storage is
already contiguous.
Sourcepub fn rand<R: RandomSource<T>>(
shape: L::Index<'_>,
rand_src: &mut R,
) -> TensorBase<Vec<T>, L>
pub fn rand<R: RandomSource<T>>( shape: L::Index<'_>, rand_src: &mut R, ) -> TensorBase<Vec<T>, L>
Create a new tensor with a given shape and elements populated using
numbers generated by rand_src
.
A more general version of this method that generates values using any
function is from_simple_fn
.
Sourcepub fn zeros(shape: L::Index<'_>) -> TensorBase<Vec<T>, L>
pub fn zeros(shape: L::Index<'_>) -> TensorBase<Vec<T>, L>
Create a new tensor with a given shape, with all elements set to their default value (ie. zero for numeric types).
Sourcepub fn zeros_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
) -> TensorBase<Vec<T>, L>
pub fn zeros_in<A: Alloc>( alloc: A, shape: L::Index<'_>, ) -> TensorBase<Vec<T>, L>
Variant of zeros
which takes an allocator.
Sourcepub fn uninit(shape: L::Index<'_>) -> TensorBase<Vec<MaybeUninit<T>>, L>where
MaybeUninit<T>: Clone,
pub fn uninit(shape: L::Index<'_>) -> TensorBase<Vec<MaybeUninit<T>>, L>where
MaybeUninit<T>: Clone,
Return a new tensor containing uninitialized elements.
The caller must initialize elements and then call
assume_init
to convert to an initialized
Tensor<T>
.
Sourcepub fn uninit_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
) -> TensorBase<Vec<MaybeUninit<T>>, L>
pub fn uninit_in<A: Alloc>( alloc: A, shape: L::Index<'_>, ) -> TensorBase<Vec<MaybeUninit<T>>, L>
Variant of uninit
which takes an allocator.
Sourcepub fn with_capacity(
shape: L::Index<'_>,
expand_dim: usize,
) -> TensorBase<Vec<T>, L>where
T: Copy,
pub fn with_capacity(
shape: L::Index<'_>,
expand_dim: usize,
) -> TensorBase<Vec<T>, L>where
T: Copy,
Create a tensor which initially has zero elements, but can be expanded along a given dimension without reallocating.
shape
specifies the maximum shape that the tensor can be expanded to
without reallocating. The initial shape will be the same, except for
the dimension specified by expand_dim
, which will be zero.
Sourcepub fn with_capacity_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
expand_dim: usize,
) -> TensorBase<Vec<T>, L>where
T: Copy,
pub fn with_capacity_in<A: Alloc>(
alloc: A,
shape: L::Index<'_>,
expand_dim: usize,
) -> TensorBase<Vec<T>, L>where
T: Copy,
Variant of with_capacity
which takes an allocator.
Source§impl<T, L: MutLayout> TensorBase<CowData<'_, T>, L>
impl<T, L: MutLayout> TensorBase<CowData<'_, T>, L>
Sourcepub fn into_non_contiguous_data(self) -> Option<Vec<T>>
pub fn into_non_contiguous_data(self) -> Option<Vec<T>>
Consume self and return the underlying data in whatever order the
elements are currently stored, if the storage is owned, or None
if
it is borrowed.
Source§impl<T, S: Storage<Elem = MaybeUninit<T>> + AssumeInit, L: Clone + MutLayout> TensorBase<S, L>
impl<T, S: Storage<Elem = MaybeUninit<T>> + AssumeInit, L: Clone + MutLayout> TensorBase<S, L>
Sourcepub unsafe fn assume_init(self) -> TensorBase<<S as AssumeInit>::Output, L>
pub unsafe fn assume_init(self) -> TensorBase<<S as AssumeInit>::Output, L>
Convert a tensor of potentially uninitialized elements to one of initialized elements.
See also MaybeUninit::assume_init
.
§Safety
The caller must guarantee that all elements in this tensor have been
initialized before calling assume_init
.
Sourcepub fn init_from<S2: Storage<Elem = T>>(
self,
other: &TensorBase<S2, L>,
) -> TensorBase<<S as AssumeInit>::Output, L>
pub fn init_from<S2: Storage<Elem = T>>( self, other: &TensorBase<S2, L>, ) -> TensorBase<<S as AssumeInit>::Output, L>
Initialize this tensor with data from another view.
This tensor and other
must have the same shape.
Source§impl<'a, T, L: Clone + MutLayout> TensorBase<ViewData<'a, T>, L>
impl<'a, T, L: Clone + MutLayout> TensorBase<ViewData<'a, T>, L>
pub fn axis_iter(&self, dim: usize) -> AxisIter<'a, T, L> ⓘwhere
L: RemoveDim,
pub fn axis_chunks(&self, dim: usize, chunk_size: usize) -> AxisChunks<'a, T, L> ⓘ
Sourcepub fn as_dyn(&self) -> TensorBase<ViewData<'a, T>, DynLayout>
pub fn as_dyn(&self) -> TensorBase<ViewData<'a, T>, DynLayout>
Return a view of this tensor with a dynamic dimension count.
See AsView::as_dyn
.
Sourcepub fn as_cow(&self) -> TensorBase<CowData<'a, T>, L>
pub fn as_cow(&self) -> TensorBase<CowData<'a, T>, L>
Convert the storage of this view to a borrowed CowData
.
See AsView::as_cow
.
Sourcepub fn broadcast<S: IntoLayout>(
&self,
shape: S,
) -> TensorBase<ViewData<'a, T>, S::Layout>where
L: BroadcastLayout<S::Layout>,
pub fn broadcast<S: IntoLayout>(
&self,
shape: S,
) -> TensorBase<ViewData<'a, T>, S::Layout>where
L: BroadcastLayout<S::Layout>,
Broadcast this view to another shape.
See AsView::broadcast
.
Sourcepub fn try_broadcast<S: IntoLayout>(
&self,
shape: S,
) -> Result<TensorBase<ViewData<'a, T>, S::Layout>, ExpandError>where
L: BroadcastLayout<S::Layout>,
pub fn try_broadcast<S: IntoLayout>(
&self,
shape: S,
) -> Result<TensorBase<ViewData<'a, T>, S::Layout>, ExpandError>where
L: BroadcastLayout<S::Layout>,
Broadcast this view to another shape.
See AsView::broadcast
.
Sourcepub fn data(&self) -> Option<&'a [T]>
pub fn data(&self) -> Option<&'a [T]>
Return the data in this tensor as a slice if it is contiguous, ie.
the order of elements in the slice is the same as the logical order
yielded by iter
, and there are no gaps.
Sourcepub fn storage(&self) -> ViewData<'a, T>
pub fn storage(&self) -> ViewData<'a, T>
Return an immutable view of the tensor’s underlying storage.
pub fn get<I: AsIndex<L>>(&self, index: I) -> Option<&'a T>
Sourcepub fn from_slice_with_strides(
shape: L::Index<'_>,
data: &'a [T],
strides: L::Index<'_>,
) -> Result<TensorBase<ViewData<'a, T>, L>, FromDataError>
pub fn from_slice_with_strides( shape: L::Index<'_>, data: &'a [T], strides: L::Index<'_>, ) -> Result<TensorBase<ViewData<'a, T>, L>, FromDataError>
Create a new view with a given shape and data slice, and custom strides.
If you do not need to specify custom strides, use TensorBase::from_data
instead. This method is similar to TensorBase::from_data_with_strides
,
but allows strides that lead to internal overlap (see OverlapPolicy
).
Sourcepub unsafe fn get_unchecked<I: AsIndex<L>>(&self, index: I) -> &'a T
pub unsafe fn get_unchecked<I: AsIndex<L>>(&self, index: I) -> &'a T
Return the element at a given index, without performing any bounds- checking.
§Safety
The caller must ensure that the index is valid for the tensor’s shape.
Sourcepub fn index_axis(
&self,
axis: usize,
index: usize,
) -> TensorBase<ViewData<'a, T>, <L as RemoveDim>::Output>where
L: RemoveDim,
pub fn index_axis(
&self,
axis: usize,
index: usize,
) -> TensorBase<ViewData<'a, T>, <L as RemoveDim>::Output>where
L: RemoveDim,
Index the tensor along a given axis.
Returns a view with one dimension removed.
Panics if axis >= self.ndim()
or index >= self.size(axis)
.
Sourcepub fn inner_iter<const N: usize>(&self) -> InnerIter<'a, T, NdLayout<N>> ⓘ
pub fn inner_iter<const N: usize>(&self) -> InnerIter<'a, T, NdLayout<N>> ⓘ
Return an iterator over the inner N
dimensions of this tensor.
See AsView::inner_iter
.
Sourcepub fn inner_iter_dyn(&self, n: usize) -> InnerIter<'a, T, DynLayout> ⓘ
pub fn inner_iter_dyn(&self, n: usize) -> InnerIter<'a, T, DynLayout> ⓘ
Return an iterator over the inner n
dimensions of this tensor.
Sourcepub fn item(&self) -> Option<&'a T>
pub fn item(&self) -> Option<&'a T>
Return the scalar value in this tensor if it has one element.
Sourcepub fn iter(&self) -> Iter<'a, T> ⓘ
pub fn iter(&self) -> Iter<'a, T> ⓘ
Return an iterator over elements of this tensor in their logical order.
See AsView::iter
.
Sourcepub fn lanes(&self, dim: usize) -> Lanes<'a, T> ⓘ
pub fn lanes(&self, dim: usize) -> Lanes<'a, T> ⓘ
Return an iterator over 1D slices of this tensor along a given dimension.
See AsView::lanes
.
Sourcepub fn nd_view<const N: usize>(
&self,
) -> TensorBase<ViewData<'a, T>, NdLayout<N>>
pub fn nd_view<const N: usize>( &self, ) -> TensorBase<ViewData<'a, T>, NdLayout<N>>
Return a view of this tensor with a static dimension count.
Panics if self.ndim() != N
.
Sourcepub fn permuted(&self, order: L::Index<'_>) -> TensorBase<ViewData<'a, T>, L>
pub fn permuted(&self, order: L::Index<'_>) -> TensorBase<ViewData<'a, T>, L>
Permute the axes of this tensor according to order
.
See AsView::permuted
.
Sourcepub fn reshaped<S: Copy + IntoLayout>(
&self,
shape: S,
) -> TensorBase<CowData<'a, T>, S::Layout>where
T: Clone,
pub fn reshaped<S: Copy + IntoLayout>(
&self,
shape: S,
) -> TensorBase<CowData<'a, T>, S::Layout>where
T: Clone,
Return a view or owned tensor that has the given shape.
See AsView::reshaped
.
Sourcepub fn reshaped_in<A: Alloc, S: Copy + IntoLayout>(
&self,
alloc: A,
shape: S,
) -> TensorBase<CowData<'a, T>, S::Layout>where
T: Clone,
pub fn reshaped_in<A: Alloc, S: Copy + IntoLayout>(
&self,
alloc: A,
shape: S,
) -> TensorBase<CowData<'a, T>, S::Layout>where
T: Clone,
Variant of reshaped
that takes an allocator.
Sourcepub fn slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> TensorBase<ViewData<'a, T>, <L as SliceWith<R, R::Count>>::Layout>where
L: SliceWith<R, R::Count>,
pub fn slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> TensorBase<ViewData<'a, T>, <L as SliceWith<R, R::Count>>::Layout>where
L: SliceWith<R, R::Count>,
Slice this tensor and return a view. See AsView::slice
.
Sourcepub fn slice_axis(
&self,
axis: usize,
range: Range<usize>,
) -> TensorBase<ViewData<'a, T>, L>
pub fn slice_axis( &self, axis: usize, range: Range<usize>, ) -> TensorBase<ViewData<'a, T>, L>
Slice this tensor along a given axis.
Sourcepub fn try_slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> Result<TensorBase<ViewData<'a, T>, <L as SliceWith<R, R::Count>>::Layout>, SliceError>where
L: SliceWith<R, R::Count>,
pub fn try_slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> Result<TensorBase<ViewData<'a, T>, <L as SliceWith<R, R::Count>>::Layout>, SliceError>where
L: SliceWith<R, R::Count>,
A variant of slice
that returns a result
instead of panicking.
Sourcepub fn squeezed(&self) -> TensorView<'a, T>
pub fn squeezed(&self) -> TensorView<'a, T>
Remove all size-one dimensions from this tensor.
See AsView::squeezed
.
Sourcepub fn split_at(
&self,
axis: usize,
mid: usize,
) -> (TensorBase<ViewData<'a, T>, L>, TensorBase<ViewData<'a, T>, L>)
pub fn split_at( &self, axis: usize, mid: usize, ) -> (TensorBase<ViewData<'a, T>, L>, TensorBase<ViewData<'a, T>, L>)
Divide this tensor into two views along a given axis.
Returns a (left, right)
tuple of views, where the left
view
contains the slice from [0, mid)
along axis
and the right
view contains the slice from [mid, end)
along axis
.
Sourcepub fn to_contiguous(&self) -> TensorBase<CowData<'a, T>, L>where
T: Clone,
pub fn to_contiguous(&self) -> TensorBase<CowData<'a, T>, L>where
T: Clone,
Return a view of this tensor with elements stored in contiguous order.
If the data is already contiguous, no copy is made, otherwise the elements are copied into a new buffer in contiguous order.
Sourcepub fn to_contiguous_in<A: Alloc>(
&self,
alloc: A,
) -> TensorBase<CowData<'a, T>, L>where
T: Clone,
pub fn to_contiguous_in<A: Alloc>(
&self,
alloc: A,
) -> TensorBase<CowData<'a, T>, L>where
T: Clone,
Variant of to_contiguous
which takes
an allocator.
Sourcepub fn to_slice(&self) -> Cow<'a, [T]>where
T: Clone,
pub fn to_slice(&self) -> Cow<'a, [T]>where
T: Clone,
Return the underlying data as a flat slice if the tensor is contiguous, or a copy of the data as a flat slice otherwise.
See AsView::to_slice
.
Sourcepub fn transposed(&self) -> TensorBase<ViewData<'a, T>, L>
pub fn transposed(&self) -> TensorBase<ViewData<'a, T>, L>
Reverse the order of dimensions in this tensor. See AsView::transposed
.
pub fn try_slice_dyn<R: IntoSliceItems>( &self, range: R, ) -> Result<TensorView<'a, T>, SliceError>
Sourcepub fn view(&self) -> TensorBase<ViewData<'a, T>, L>
pub fn view(&self) -> TensorBase<ViewData<'a, T>, L>
Return a read-only view of this tensor. See AsView::view
.
pub fn weakly_checked_view(&self) -> WeaklyCheckedView<ViewData<'a, T>, L>
Source§impl<T, S: Storage<Elem = T>, const N: usize> TensorBase<S, NdLayout<N>>
impl<T, S: Storage<Elem = T>, const N: usize> TensorBase<S, NdLayout<N>>
Sourcepub fn get_array<const M: usize>(&self, base: [usize; N], dim: usize) -> [T; M]
pub fn get_array<const M: usize>(&self, base: [usize; N], dim: usize) -> [T; M]
Load an array of M
elements from successive entries of a tensor along
the dim
axis.
eg. If base
is [0, 1, 2]
, dim=0 and M
= 4 this will return an
array with values from indices [0, 1, 2]
, [1, 1, 2]
… [3, 1, 2]
.
Panics if any of the array indices are out of bounds.
Source§impl<T> TensorBase<Vec<T>, DynLayout>
impl<T> TensorBase<Vec<T>, DynLayout>
Source§impl<'a, T, L: MutLayout> TensorBase<ViewMutData<'a, T>, L>
impl<'a, T, L: MutLayout> TensorBase<ViewMutData<'a, T>, L>
Sourcepub fn split_at_mut(
self,
axis: usize,
mid: usize,
) -> (TensorBase<ViewMutData<'a, T>, L>, TensorBase<ViewMutData<'a, T>, L>)
pub fn split_at_mut( self, axis: usize, mid: usize, ) -> (TensorBase<ViewMutData<'a, T>, L>, TensorBase<ViewMutData<'a, T>, L>)
Divide this tensor into two mutable views along a given axis.
Returns a (left, right)
tuple of views, where the left
view
contains the slice from [0, mid)
along axis
and the right
view contains the slice from [mid, end)
along axis
.
Sourcepub fn into_slice_mut(self) -> Option<&'a mut [T]>
pub fn into_slice_mut(self) -> Option<&'a mut [T]>
Consume this view and return a mutable slice, if the tensor is contiguous.
Source§impl<T, S: StorageMut<Elem = T>, const N: usize> TensorBase<S, NdLayout<N>>
impl<T, S: StorageMut<Elem = T>, const N: usize> TensorBase<S, NdLayout<N>>
Source§impl<T, S: Storage<Elem = T>> TensorBase<S, NdLayout<1>>
impl<T, S: Storage<Elem = T>> TensorBase<S, NdLayout<1>>
Source§impl<T, S: StorageMut<Elem = T>> TensorBase<S, NdLayout<1>>
impl<T, S: StorageMut<Elem = T>> TensorBase<S, NdLayout<1>>
Trait Implementations§
Source§impl<T, S: Storage<Elem = T>, L: MutLayout + Clone> AsView for TensorBase<S, L>
impl<T, S: Storage<Elem = T>, L: MutLayout + Clone> AsView for TensorBase<S, L>
Source§type Layout = L
type Layout = L
[usize; N]
or &[usize]
) as this view.Source§fn iter(&self) -> Iter<'_, T> ⓘ
fn iter(&self) -> Iter<'_, T> ⓘ
Source§fn copy_into_slice<'a>(&self, dest: &'a mut [MaybeUninit<T>]) -> &'a [T]where
T: Copy,
fn copy_into_slice<'a>(&self, dest: &'a mut [MaybeUninit<T>]) -> &'a [T]where
T: Copy,
dest
in logical order. Read moreSource§fn data(&self) -> Option<&[Self::Elem]>
fn data(&self) -> Option<&[Self::Elem]>
Source§fn insert_axis(&mut self, index: usize)where
L: ResizeLayout,
fn insert_axis(&mut self, index: usize)where
L: ResizeLayout,
Source§fn remove_axis(&mut self, index: usize)where
L: ResizeLayout,
fn remove_axis(&mut self, index: usize)where
L: ResizeLayout,
Source§fn merge_axes(&mut self)where
L: ResizeLayout,
fn merge_axes(&mut self)where
L: ResizeLayout,
Source§fn map<F, U>(&self, f: F) -> TensorBase<Vec<U>, L>
fn map<F, U>(&self, f: F) -> TensorBase<Vec<U>, L>
f
to each
element in this tensor.Source§fn map_in<A: Alloc, F, U>(&self, alloc: A, f: F) -> TensorBase<Vec<U>, L>
fn map_in<A: Alloc, F, U>(&self, alloc: A, f: F) -> TensorBase<Vec<U>, L>
map
which takes an allocator.Source§fn view(&self) -> TensorBase<ViewData<'_, T>, L>
fn view(&self) -> TensorBase<ViewData<'_, T>, L>
Source§fn get<I: AsIndex<L>>(&self, index: I) -> Option<&Self::Elem>
fn get<I: AsIndex<L>>(&self, index: I) -> Option<&Self::Elem>
None
if the
index is invalid.Source§unsafe fn get_unchecked<I: AsIndex<L>>(&self, index: I) -> &T
unsafe fn get_unchecked<I: AsIndex<L>>(&self, index: I) -> &T
Source§fn to_vec(&self) -> Vec<T>where
T: Clone,
fn to_vec(&self) -> Vec<T>where
T: Clone,
Source§fn to_vec_in<A: Alloc>(&self, alloc: A) -> Vec<T>where
T: Clone,
fn to_vec_in<A: Alloc>(&self, alloc: A) -> Vec<T>where
T: Clone,
to_vec
which takes an allocator.Source§fn to_shape<SH: IntoLayout>(
&self,
shape: SH,
) -> TensorBase<Vec<Self::Elem>, SH::Layout>where
T: Clone,
fn to_shape<SH: IntoLayout>(
&self,
shape: SH,
) -> TensorBase<Vec<Self::Elem>, SH::Layout>where
T: Clone,
Source§fn as_dyn(&self) -> TensorBase<ViewData<'_, Self::Elem>, DynLayout>
fn as_dyn(&self) -> TensorBase<ViewData<'_, Self::Elem>, DynLayout>
Source§fn axis_chunks(
&self,
dim: usize,
chunk_size: usize,
) -> AxisChunks<'_, Self::Elem, Self::Layout> ⓘ
fn axis_chunks( &self, dim: usize, chunk_size: usize, ) -> AxisChunks<'_, Self::Elem, Self::Layout> ⓘ
Source§fn axis_iter(&self, dim: usize) -> AxisIter<'_, Self::Elem, Self::Layout> ⓘwhere
Self::Layout: RemoveDim,
fn axis_iter(&self, dim: usize) -> AxisIter<'_, Self::Elem, Self::Layout> ⓘwhere
Self::Layout: RemoveDim,
Source§fn broadcast<S: IntoLayout>(
&self,
shape: S,
) -> TensorBase<ViewData<'_, Self::Elem>, S::Layout>
fn broadcast<S: IntoLayout>( &self, shape: S, ) -> TensorBase<ViewData<'_, Self::Elem>, S::Layout>
Source§fn try_broadcast<S: IntoLayout>(
&self,
shape: S,
) -> Result<TensorBase<ViewData<'_, Self::Elem>, S::Layout>, ExpandError>
fn try_broadcast<S: IntoLayout>( &self, shape: S, ) -> Result<TensorBase<ViewData<'_, Self::Elem>, S::Layout>, ExpandError>
broadcast
.Source§fn index_axis(
&self,
axis: usize,
index: usize,
) -> TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as RemoveDim>::Output>where
Self::Layout: RemoveDim,
fn index_axis(
&self,
axis: usize,
index: usize,
) -> TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as RemoveDim>::Output>where
Self::Layout: RemoveDim,
Source§fn inner_iter<const N: usize>(&self) -> InnerIter<'_, Self::Elem, NdLayout<N>> ⓘ
fn inner_iter<const N: usize>(&self) -> InnerIter<'_, Self::Elem, NdLayout<N>> ⓘ
Source§fn inner_iter_dyn(&self, n: usize) -> InnerIter<'_, Self::Elem, DynLayout> ⓘ
fn inner_iter_dyn(&self, n: usize) -> InnerIter<'_, Self::Elem, DynLayout> ⓘ
n
dimensions. Read moreSource§fn item(&self) -> Option<&Self::Elem>
fn item(&self) -> Option<&Self::Elem>
Source§fn lanes(&self, dim: usize) -> Lanes<'_, Self::Elem> ⓘ
fn lanes(&self, dim: usize) -> Lanes<'_, Self::Elem> ⓘ
Source§fn nd_view<const N: usize>(
&self,
) -> TensorBase<ViewData<'_, Self::Elem>, NdLayout<N>>
fn nd_view<const N: usize>( &self, ) -> TensorBase<ViewData<'_, Self::Elem>, NdLayout<N>>
Source§fn permuted(
&self,
order: Self::Index<'_>,
) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
fn permuted( &self, order: Self::Index<'_>, ) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
dims
.Source§fn reshaped<S: Copy + IntoLayout>(
&self,
shape: S,
) -> TensorBase<CowData<'_, Self::Elem>, S::Layout>
fn reshaped<S: Copy + IntoLayout>( &self, shape: S, ) -> TensorBase<CowData<'_, Self::Elem>, S::Layout>
self
with the given shape. Read moreSource§fn reshaped_in<A: Alloc, S: Copy + IntoLayout>(
&self,
alloc: A,
shape: S,
) -> TensorBase<CowData<'_, Self::Elem>, S::Layout>
fn reshaped_in<A: Alloc, S: Copy + IntoLayout>( &self, alloc: A, shape: S, ) -> TensorBase<CowData<'_, Self::Elem>, S::Layout>
reshaped
that allows specifying the
allocator to use if a copy is needed.Source§fn transposed(&self) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
fn transposed(&self) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
Source§fn slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
fn slice<R: IntoSliceItems + IndexCount>( &self, range: R, ) -> TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
Source§fn slice_axis(
&self,
axis: usize,
range: Range<usize>,
) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
fn slice_axis( &self, axis: usize, range: Range<usize>, ) -> TensorBase<ViewData<'_, Self::Elem>, Self::Layout>
Source§fn try_slice<R: IntoSliceItems + IndexCount>(
&self,
range: R,
) -> Result<TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>, SliceError>
fn try_slice<R: IntoSliceItems + IndexCount>( &self, range: R, ) -> Result<TensorBase<ViewData<'_, Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>, SliceError>
slice
that returns a result
instead of panicking.Source§fn slice_copy<R: Clone + IntoSliceItems + IndexCount>(
&self,
range: R,
) -> TensorBase<Vec<Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
fn slice_copy<R: Clone + IntoSliceItems + IndexCount>( &self, range: R, ) -> TensorBase<Vec<Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
Source§fn slice_copy_in<A: Alloc, R: Clone + IntoSliceItems + IndexCount>(
&self,
pool: A,
range: R,
) -> TensorBase<Vec<Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
fn slice_copy_in<A: Alloc, R: Clone + IntoSliceItems + IndexCount>( &self, pool: A, range: R, ) -> TensorBase<Vec<Self::Elem>, <Self::Layout as SliceWith<R, R::Count>>::Layout>
slice_copy
which takes an allocator.Source§fn squeezed(&self) -> TensorView<'_, Self::Elem>
fn squeezed(&self) -> TensorView<'_, Self::Elem>
Source§fn to_contiguous(&self) -> TensorBase<CowData<'_, Self::Elem>, Self::Layout>
fn to_contiguous(&self) -> TensorBase<CowData<'_, Self::Elem>, Self::Layout>
iter
). Read moreSource§fn to_contiguous_in<A: Alloc>(
&self,
alloc: A,
) -> TensorBase<CowData<'_, Self::Elem>, Self::Layout>
fn to_contiguous_in<A: Alloc>( &self, alloc: A, ) -> TensorBase<CowData<'_, Self::Elem>, Self::Layout>
to_contiguous
which takes an
allocator.Source§fn to_slice(&self) -> Cow<'_, [Self::Elem]>
fn to_slice(&self) -> Cow<'_, [Self::Elem]>
Source§fn to_tensor(&self) -> TensorBase<Vec<Self::Elem>, Self::Layout>
fn to_tensor(&self) -> TensorBase<Vec<Self::Elem>, Self::Layout>
Source§fn to_tensor_in<A: Alloc>(
&self,
alloc: A,
) -> TensorBase<Vec<Self::Elem>, Self::Layout>
fn to_tensor_in<A: Alloc>( &self, alloc: A, ) -> TensorBase<Vec<Self::Elem>, Self::Layout>
to_tensor
which takes an allocator.Source§fn weakly_checked_view(
&self,
) -> WeaklyCheckedView<ViewData<'_, Self::Elem>, Self::Layout>
fn weakly_checked_view( &self, ) -> WeaklyCheckedView<ViewData<'_, Self::Elem>, Self::Layout>
view[<index>]
. See WeaklyCheckedView
for an explanation.Source§impl<T, S: Storage<Elem = T> + Clone, L: MutLayout + Clone> Clone for TensorBase<S, L>
impl<T, S: Storage<Elem = T> + Clone, L: MutLayout + Clone> Clone for TensorBase<S, L>
Source§fn clone(&self) -> TensorBase<S, L>
fn clone(&self) -> TensorBase<S, L>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a, T, L: Clone + MutLayout, const N: usize> From<&'a [T; N]> for TensorBase<ViewData<'a, T>, L>
impl<'a, T, L: Clone + MutLayout, const N: usize> From<&'a [T; N]> for TensorBase<ViewData<'a, T>, L>
Source§impl<T: Clone + Scalar, L: MutLayout, const D0: usize, const D1: usize, const D2: usize> From<[[[T; D2]; D1]; D0]> for TensorBase<Vec<T>, L>
impl<T: Clone + Scalar, L: MutLayout, const D0: usize, const D1: usize, const D2: usize> From<[[[T; D2]; D1]; D0]> for TensorBase<Vec<T>, L>
Source§impl<T: Clone + Scalar, L: MutLayout, const D0: usize, const D1: usize> From<[[T; D1]; D0]> for TensorBase<Vec<T>, L>
impl<T: Clone + Scalar, L: MutLayout, const D0: usize, const D1: usize> From<[[T; D1]; D0]> for TensorBase<Vec<T>, L>
Source§impl<T: Clone + Scalar, L: MutLayout, const D0: usize> From<[T; D0]> for TensorBase<Vec<T>, L>
impl<T: Clone + Scalar, L: MutLayout, const D0: usize> From<[T; D0]> for TensorBase<Vec<T>, L>
Source§impl<T, S: Storage<Elem = T>, const N: usize> From<TensorBase<S, NdLayout<N>>> for TensorBase<S, DynLayout>
impl<T, S: Storage<Elem = T>, const N: usize> From<TensorBase<S, NdLayout<N>>> for TensorBase<S, DynLayout>
Source§fn from(tensor: TensorBase<S, NdLayout<N>>) -> Self
fn from(tensor: TensorBase<S, NdLayout<N>>) -> Self
Source§impl<T, L: Clone + MutLayout> FromIterator<T> for TensorBase<Vec<T>, L>
impl<T, L: Clone + MutLayout> FromIterator<T> for TensorBase<Vec<T>, L>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> TensorBase<Vec<T>, L>
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> TensorBase<Vec<T>, L>
Create a new 1D tensor filled with an arithmetic sequence of values
in the range [start, end)
separated by step
. If step
is omitted,
it defaults to 1.
Source§impl<T, S: StorageMut<Elem = T>, L: MutLayout, I: AsIndex<L>> IndexMut<I> for TensorBase<S, L>
impl<T, S: StorageMut<Elem = T>, L: MutLayout, I: AsIndex<L>> IndexMut<I> for TensorBase<S, L>
Source§impl<S: Storage, L: MutLayout> Layout for TensorBase<S, L>
impl<S: Storage, L: MutLayout> Layout for TensorBase<S, L>
Source§fn stride(&self, dim: usize) -> usize
fn stride(&self, dim: usize) -> usize
dim
.Source§fn try_offset(&self, index: Self::Index<'_>) -> Option<usize>
fn try_offset(&self, index: Self::Index<'_>) -> Option<usize>
None
if the index is out
of bounds along any dimension.Source§fn offset_unchecked(&self, index: Self::Index<'_>) -> usize
fn offset_unchecked(&self, index: Self::Index<'_>) -> usize
Source§fn is_contiguous(&self) -> bool
fn is_contiguous(&self) -> bool
Source§fn is_broadcast(&self) -> bool
fn is_broadcast(&self) -> bool
Source§fn can_broadcast_to(&self, target_shape: &[usize]) -> bool
fn can_broadcast_to(&self, target_shape: &[usize]) -> bool
Source§fn can_broadcast_with(&self, shape: &[usize]) -> bool
fn can_broadcast_with(&self, shape: &[usize]) -> bool
shape
as part of a binary operation. Read moreSource§fn min_data_len(&self) -> usize
fn min_data_len(&self) -> usize
Source§impl<S: Storage, L: MutLayout + MatrixLayout> MatrixLayout for TensorBase<S, L>
impl<S: Storage, L: MutLayout + MatrixLayout> MatrixLayout for TensorBase<S, L>
Source§impl<T: PartialEq, S: Storage<Elem = T>, L: MutLayout, V: AsView<Elem = T>> PartialEq<V> for TensorBase<S, L>
impl<T: PartialEq, S: Storage<Elem = T>, L: MutLayout, V: AsView<Elem = T>> PartialEq<V> for TensorBase<S, L>
Source§impl<T, S1, S2: Storage<Elem = T>, const N: usize> TryFrom<TensorBase<S1, DynLayout>> for TensorBase<S2, NdLayout<N>>
impl<T, S1, S2: Storage<Elem = T>, const N: usize> TryFrom<TensorBase<S1, DynLayout>> for TensorBase<S2, NdLayout<N>>
impl<T, S: Storage<Elem = T> + Copy, L: MutLayout + Copy> Copy for TensorBase<S, L>
Auto Trait Implementations§
impl<S, L> Freeze for TensorBase<S, L>
impl<S, L> RefUnwindSafe for TensorBase<S, L>where
S: RefUnwindSafe,
L: RefUnwindSafe,
impl<S, L> Send for TensorBase<S, L>
impl<S, L> Sync for TensorBase<S, L>
impl<S, L> Unpin for TensorBase<S, L>
impl<S, L> UnwindSafe for TensorBase<S, L>where
S: UnwindSafe,
L: UnwindSafe,
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> 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>
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