pub struct ErasedTensor<E: Numeric, IO = ReadOnly> { /* private fields */ }Expand description
A tensor that has forgotten its line width. See the module docs.
Implementations§
Source§impl<E: Numeric, IO: ErasedIoRead> ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIoRead> ErasedTensor<E, IO>
Sourcepub fn read<N: Size>(&self, index: usize) -> Vector<E, N>
pub fn read<N: Size>(&self, index: usize) -> Vector<E, N>
Read one N-wide line at index, counted in lines.
§Panics
At expansion, when N is not the width the tensor was built for.
Sourcepub fn __expand_read<N: Size>(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
index: <usize as CubeType>::ExpandType,
) -> <Vector<E, N> as CubeType>::ExpandType
pub fn __expand_read<N: Size>( scope: &Scope, this: &<Self as CubeType>::ExpandType, index: <usize as CubeType>::ExpandType, ) -> <Vector<E, N> as CubeType>::ExpandType
Read one N-wide line at index, counted in lines.
§Panics
At expansion, when N is not the width the tensor was built for.
Source§impl<E: Numeric, IO: ErasedIoWrite> ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIoWrite> ErasedTensor<E, IO>
Sourcepub fn write<N: Size>(&mut self, index: usize, value: Vector<E, N>)
pub fn write<N: Size>(&mut self, index: usize, value: Vector<E, N>)
Write one N-wide line at index, counted in lines.
§Panics
At expansion, when N is not the width the tensor was built for.
Sourcepub fn __expand_write<N: Size>(
scope: &Scope,
this: &mut <Self as CubeType>::ExpandType,
index: <usize as CubeType>::ExpandType,
value: <Vector<E, N> as CubeType>::ExpandType,
)
pub fn __expand_write<N: Size>( scope: &Scope, this: &mut <Self as CubeType>::ExpandType, index: <usize as CubeType>::ExpandType, value: <Vector<E, N> as CubeType>::ExpandType, )
Write one N-wide line at index, counted in lines.
§Panics
At expansion, when N is not the width the tensor was built for.
Source§impl<E: Numeric, IO: ErasedIo> ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIo> ErasedTensor<E, IO>
Sourcepub fn __expand_len(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <usize as CubeType>::ExpandType
pub fn __expand_len( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <usize as CubeType>::ExpandType
How many lines the tensor holds.
Source§impl<E: Numeric, IO: ErasedIo> ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIo> ErasedTensor<E, IO>
Sourcepub fn of_view<V: CubeType, N: Size>(_view: V) -> Self
pub fn of_view<V: CubeType, N: Size>(_view: V) -> Self
The erased tensor over view, whose lines are N wide.
The width is named at this call and nowhere after it, which is the whole
point of the type: a caller that knows N hands it over here so the
engine holding the tensor never has to.
Sourcepub fn __expand_of_view<V: CubeType, N: Size>(
_scope: &Scope,
view: V::ExpandType,
) -> ErasedTensorExpand<E, IO>where
V::ExpandType: ViewOperationsExpand<Vector<E, N>, Coords1d> + 'static,
ErasedView<V::ExpandType, N>: ErasedBacking<E, IO>,
pub fn __expand_of_view<V: CubeType, N: Size>(
_scope: &Scope,
view: V::ExpandType,
) -> ErasedTensorExpand<E, IO>where
V::ExpandType: ViewOperationsExpand<Vector<E, N>, Coords1d> + 'static,
ErasedView<V::ExpandType, N>: ErasedBacking<E, IO>,
Expand function for of_view.
Sourcepub fn of_view_mut<V: CubeType, N: Size>(_view: V) -> Self
pub fn of_view_mut<V: CubeType, N: Size>(_view: V) -> Self
The erased tensor over the mutable view, whose lines are N wide.
Sourcepub fn __expand_of_view_mut<V: CubeType, N: Size>(
_scope: &Scope,
view: V::ExpandType,
) -> ErasedTensorExpand<E, IO>where
V::ExpandType: ViewOperationsMutExpand<Vector<E, N>, Coords1d> + 'static,
ErasedViewMut<V::ExpandType, N>: ErasedBacking<E, IO>,
pub fn __expand_of_view_mut<V: CubeType, N: Size>(
_scope: &Scope,
view: V::ExpandType,
) -> ErasedTensorExpand<E, IO>where
V::ExpandType: ViewOperationsMutExpand<Vector<E, N>, Coords1d> + 'static,
ErasedViewMut<V::ExpandType, N>: ErasedBacking<E, IO>,
Expand function for of_view_mut.
Sourcepub fn of_tensor<N: Size>(_tensor: &Tensor<Vector<E, N>>) -> Self
pub fn of_tensor<N: Size>(_tensor: &Tensor<Vector<E, N>>) -> Self
The erased tensor over tensor — memory, through the indirection.
Sourcepub fn __expand_of_tensor<N: Size>(
_scope: &Scope,
tensor: &TensorExpand<Vector<E, N>>,
) -> ErasedTensorExpand<E, IO>
pub fn __expand_of_tensor<N: Size>( _scope: &Scope, tensor: &TensorExpand<Vector<E, N>>, ) -> ErasedTensorExpand<E, IO>
Expand function for of_tensor.
Sourcepub fn of_tensor_mut<N: Size>(_tensor: &mut Tensor<Vector<E, N>>) -> Self
pub fn of_tensor_mut<N: Size>(_tensor: &mut Tensor<Vector<E, N>>) -> Self
The erased tensor over the mutable tensor.
Separate from of_tensor for the same reason
of_view_mut is separate from
of_view: a &mut operand expands to a &mut expand,
and the shared entry point cannot take one.
Sourcepub fn __expand_of_tensor_mut<N: Size>(
_scope: &Scope,
tensor: &mut TensorExpand<Vector<E, N>>,
) -> ErasedTensorExpand<E, IO>
pub fn __expand_of_tensor_mut<N: Size>( _scope: &Scope, tensor: &mut TensorExpand<Vector<E, N>>, ) -> ErasedTensorExpand<E, IO>
Expand function for of_tensor_mut.
Sourcepub fn of_virtual<N: Size, IO2: Clone>(
_tensor: VirtualTensor<E, N, IO2>,
) -> Self
pub fn of_virtual<N: Size, IO2: Clone>( _tensor: VirtualTensor<E, N, IO2>, ) -> Self
The erased tensor over tensor.
Sourcepub fn __expand_of_virtual<N: Size, IO2: Clone + 'static>(
_scope: &Scope,
tensor: VirtualTensorExpand<E, N, IO2>,
) -> ErasedTensorExpand<E, IO>where
VirtualTensorExpand<E, N, IO2>: ErasedBacking<E, IO>,
pub fn __expand_of_virtual<N: Size, IO2: Clone + 'static>(
_scope: &Scope,
tensor: VirtualTensorExpand<E, N, IO2>,
) -> ErasedTensorExpand<E, IO>where
VirtualTensorExpand<E, N, IO2>: ErasedBacking<E, IO>,
Expand function for of_virtual.
Trait Implementations§
Source§impl<E: Numeric, IO> Clone for ErasedTensor<E, IO>
impl<E: Numeric, IO> Clone for ErasedTensor<E, IO>
impl<E: Numeric, IO> Copy for ErasedTensor<E, IO>
Source§impl<E: Numeric, IO: ErasedIo> CubeType for ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIo> CubeType for ErasedTensor<E, IO>
type ExpandType = ErasedTensorExpand<E, IO>
Source§impl<E: Numeric, IO: ErasedIo> Vectorized for ErasedTensor<E, IO>
impl<E: Numeric, IO: ErasedIo> Vectorized for ErasedTensor<E, IO>
fn vector_size(&self) -> usize
fn __expand_vector_size(scope: &Scope, this: &Self::ExpandType) -> usize
Source§impl<E: Numeric, N: Size, IO: ErasedIo> ViewOperations<Vector<E, N>, usize> for ErasedTensor<E, IO>
impl<E: Numeric, N: Size, IO: ErasedIo> ViewOperations<Vector<E, N>, usize> for ErasedTensor<E, IO>
N is constrained by the trait rather than by the type, which is the whole
trick: the tensor stays width-free, and the width arrives with the view the
caller builds over it. Every access checks the two agree.
This is implemented for every visibility, including WriteOnly, because
ViewOperationsMut has ViewOperations as a supertrait — a write-only
destination backing a ViewMut still has to name the read
half. Its reads
reach the backing’s default and panic.
fn read(&self, pos: C) -> T
fn read_checked(&self, pos: C) -> T
fn read_masked(&self, pos: C, value: T) -> T
fn read_unchecked(&self, pos: C) -> T
Source§fn as_linear_slice(&self, pos: C, size: C) -> &[T]
fn as_linear_slice(&self, pos: C, size: C) -> &[T]
pos, with size.
The layout handles translation into concrete indices.Source§fn tensor_map_load(&self, barrier: &Barrier, shared_memory: &mut [T], pos: C)
fn tensor_map_load(&self, barrier: &Barrier, shared_memory: &mut [T], pos: C)
fn shape(&self) -> C
fn is_in_bounds(&self, pos: C) -> bool
fn __expand_read( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_read_checked( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_read_masked( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, value: <T as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_read_unchecked( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_as_linear_slice<'infer, 'scope>( scope: &'scope Scope, this: &'infer <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, size: <C as CubeType>::ExpandType, ) -> &'infer <[T] as CubeType>::ExpandType ⓘ
fn __expand_tensor_map_load( scope: &Scope, this: &<Self as CubeType>::ExpandType, barrier: &<Barrier as CubeType>::ExpandType, shared_memory: &mut <[T] as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, )
fn __expand_shape( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <C as CubeType>::ExpandType
fn __expand_is_in_bounds( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType
Source§impl<E: Numeric, N: Size, IO: ErasedIoWrite> ViewOperationsMut<Vector<E, N>, usize> for ErasedTensor<E, IO>
impl<E: Numeric, N: Size, IO: ErasedIoWrite> ViewOperationsMut<Vector<E, N>, usize> for ErasedTensor<E, IO>
fn write(&self, pos: C, value: T)
fn write_checked(&self, pos: C, value: T)
Source§fn as_linear_slice_mut(&self, pos: C, size: C) -> &mut [T]
fn as_linear_slice_mut(&self, pos: C, size: C) -> &mut [T]
pos, with size.
The layout handles translation into concrete indices.Source§fn tensor_map_store(&self, shared_memory: &[T], pos: C)
fn tensor_map_store(&self, shared_memory: &[T], pos: C)
fn __expand_write( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, value: <T as CubeType>::ExpandType, )
fn __expand_write_checked( scope: &Scope, this: &<Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, value: <T as CubeType>::ExpandType, )
fn __expand_as_linear_slice_mut<'infer, 'scope>( scope: &'scope Scope, this: &'infer <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, size: <C as CubeType>::ExpandType, ) -> &'infer mut <[T] as CubeType>::ExpandType ⓘ
fn __expand_tensor_map_store( scope: &Scope, this: &<Self as CubeType>::ExpandType, shared_memory: &<[T] as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, )
Auto Trait Implementations§
impl<E, IO> Freeze for ErasedTensor<E, IO>
impl<E, IO> RefUnwindSafe for ErasedTensor<E, IO>
impl<E, IO> Send for ErasedTensor<E, IO>
impl<E, IO> Sync for ErasedTensor<E, IO>
impl<E, IO> Unpin for ErasedTensor<E, IO>
impl<E, IO> UnsafeUnpin for ErasedTensor<E, IO>
impl<E, IO> UnwindSafe for ErasedTensor<E, IO>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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