pub struct Tensor<D: Device, T: Scalar> { /* private fields */ }Expand description
A tensor on either CPU or GPU.
Implementations§
Source§impl<F: Float> Tensor<Cpu<F>, F>
impl<F: Float> Tensor<Cpu<F>, F>
pub fn statistics(&self) -> MatrixStatistics
Source§impl<T: Scalar, K: Kind> Tensor<Gpu<K>, T>
impl<T: Scalar, K: Kind> Tensor<Gpu<K>, T>
pub fn from_data_u8( context: &Context, shape: impl Into<Shape>, contents: &[u8], ) -> Result<Self, TensorError>
pub fn back_in_place(&self) -> TensorCpu<T>
pub async fn back(&self) -> TensorCpu<T>
Source§impl<T: Scalar> Tensor<Gpu<Uniform>, T>
impl<T: Scalar> Tensor<Gpu<Uniform>, T>
pub fn layout(&self, binding: u32) -> BindGroupLayoutEntry
Source§impl<T: Scalar> Tensor<Gpu<ReadWrite>, T>
impl<T: Scalar> Tensor<Gpu<ReadWrite>, T>
pub fn meta_layout(&self, binding: u32) -> BindGroupLayoutEntry
pub fn layout(&self, binding: u32, read_only: bool) -> BindGroupLayoutEntry
Source§impl<T: Scalar> Tensor<Cpu<T>, T>
impl<T: Scalar> Tensor<Cpu<T>, T>
Sourcepub fn map<U: Scalar>(self, f: impl FnMut(&T) -> U) -> TensorCpu<U>
pub fn map<U: Scalar>(self, f: impl FnMut(&T) -> U) -> TensorCpu<U>
Apply a map f to every element in the tensor.
Sourcepub fn pad(self, multiples: impl Into<Shape>) -> Self
pub fn pad(self, multiples: impl Into<Shape>) -> Self
Pad each dimension to multiples with zeros.
Sourcepub fn stack(batches: Vec<Self>, axis: usize) -> Result<Self, TensorError>
pub fn stack(batches: Vec<Self>, axis: usize) -> Result<Self, TensorError>
Concat a batch of tensors.
Sourcepub fn split(self, axis: usize) -> Result<Vec<Self>, TensorError>
pub fn split(self, axis: usize) -> Result<Vec<Self>, TensorError>
Split the tensor along the batch axis.
pub fn slice( &self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis, ) -> Result<Self, TensorError>
pub fn into_slice( self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis, ) -> Result<Self, TensorError>
Source§impl<T: Scalar> Tensor<Gpu<ReadWrite>, T>
impl<T: Scalar> Tensor<Gpu<ReadWrite>, T>
Sourcepub fn view(
&self,
x: impl TensorAxis,
y: impl TensorAxis,
z: impl TensorAxis,
w: impl TensorAxis,
) -> Result<TensorGpuView<'_, T>, TensorError>
pub fn view( &self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis, ) -> Result<TensorGpuView<'_, T>, TensorError>
Create a view for the tensor.
Trait Implementations§
Auto Trait Implementations§
impl<D, T> Freeze for Tensor<D, T>
impl<D, T> RefUnwindSafe for Tensor<D, T>
impl<D, T> Send for Tensor<D, T>
impl<D, T> Sync for Tensor<D, T>
impl<D, T> Unpin for Tensor<D, T>
impl<D, T> UnwindSafe for Tensor<D, T>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.