pub struct View<E: CubePrimitive, C: Coordinates, IO: Clone = ReadOnly> { /* private fields */ }Expand description
A conceptual view of an underlying linear storage. Allows abstract indexing in multiple dimensions, without having to know the data layout or location.
Implementations§
Source§impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadOnly>
 
impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadOnly>
Sourcepub fn new<V: ViewOperations<E, S>, S: Coordinates>(
    view: &V,
    layout: impl Into<VirtualLayout<C, S>>,
) -> Self
 
pub fn new<V: ViewOperations<E, S>, S: Coordinates>( view: &V, layout: impl Into<VirtualLayout<C, S>>, ) -> Self
Create a new tensor view from an underlying concrete storage and a layout to map it into the target coordinate space
Sourcepub fn __expand_new<V: ViewOperations<E, S> + 'static, S: Coordinates + 'static>(
    scope: &mut Scope,
    view: V::ExpandType,
    layout: VirtualLayoutExpand<C, S>,
) -> ViewExpand<E, C, ReadOnly>
 
pub fn __expand_new<V: ViewOperations<E, S> + 'static, S: Coordinates + 'static>( scope: &mut Scope, view: V::ExpandType, layout: VirtualLayoutExpand<C, S>, ) -> ViewExpand<E, C, ReadOnly>
Expand function for [TensorView::new]
Source§impl<E: CubePrimitive, C: Coordinates + 'static, IO: Clone + 'static> View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates + 'static, IO: Clone + 'static> View<E, C, IO>
pub fn view<T: Coordinates>( &self, _layout: impl Into<VirtualLayout<T, C>>, ) -> View<E, T, ReadOnly>
pub fn __expand_view<T: Coordinates + 'static>( scope: &mut Scope, this: ViewExpand<E, C, IO>, layout: VirtualLayoutExpand<T, C>, ) -> ViewExpand<E, T, ReadOnly>
Source§impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
pub fn view_mut<T: Coordinates>( &self, _layout: impl Layout<Coordinates = T, SourceCoordinates = C>, ) -> View<E, T, ReadWrite>
pub fn __expand_view_mut<T: Coordinates + 'static>( scope: &mut Scope, this: ViewExpand<E, C, ReadWrite>, layout: VirtualLayoutExpand<T, C>, ) -> ViewExpand<E, T, ReadWrite>
Source§impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
Sourcepub fn new_mut<V: ViewOperationsMut<E, S>, S: Coordinates>(
    _view: &mut V,
    _layout: impl Into<VirtualLayout<C, S>>,
) -> View<E, C, ReadWrite>
 
pub fn new_mut<V: ViewOperationsMut<E, S>, S: Coordinates>( _view: &mut V, _layout: impl Into<VirtualLayout<C, S>>, ) -> View<E, C, ReadWrite>
Create a new mutable tensor view from an underlying concrete storage and a layout to map it into the target coordinate space
Sourcepub fn __expand_new_mut<V: ViewOperationsMut<E, S> + 'static, S: Coordinates + 'static>(
    scope: &mut Scope,
    view: V::ExpandType,
    layout: VirtualLayoutExpand<C, S>,
) -> ViewExpand<E, C, ReadWrite>
 
pub fn __expand_new_mut<V: ViewOperationsMut<E, S> + 'static, S: Coordinates + 'static>( scope: &mut Scope, view: V::ExpandType, layout: VirtualLayoutExpand<C, S>, ) -> ViewExpand<E, C, ReadWrite>
Expand function for [TensorView::new_mut]
Source§impl<E: CubePrimitive, C: Coordinates, IO: Clone> View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates, IO: Clone> View<E, C, IO>
Sourcepub fn shape(&self) -> C
 
pub fn shape(&self) -> C
Calls Layout::shape on the view’s layout
Sourcepub fn is_in_bounds(&self, _pos: C) -> bool
 
pub fn is_in_bounds(&self, _pos: C) -> bool
Calls Layout::is_in_bounds on the view’s layout
pub fn __expand_shape( scope: &mut Scope, this: ViewExpand<E, C, IO>, ) -> C::ExpandType
pub fn __expand_is_in_bounds( scope: &mut Scope, this: ViewExpand<E, C, IO>, pos: C::ExpandType, ) -> ExpandElementTyped<bool>
Source§impl<E: CubePrimitive, C: Coordinates, IO: Clone> View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates, IO: Clone> View<E, C, IO>
Sourcepub fn read(&self, pos: C) -> E
 
pub fn read(&self, pos: C) -> E
Read a line at pos. The layout handles translation into a concrete index.
Sourcepub fn read_unchecked(&self, pos: C) -> E
 
pub fn read_unchecked(&self, pos: C) -> E
Read a line at pos. The layout handles translation into a concrete index.
Reading is done unchecked
Sourcepub fn read_checked(&self, pos: C) -> E
 
pub fn read_checked(&self, pos: C) -> E
Read a line at pos if it’s in bounds. The layout handles translation into a concrete index.
Sourcepub fn read_masked(&self, pos: C, mask_value: E) -> E
 
pub fn read_masked(&self, pos: C, mask_value: E) -> E
Read a line at pos if it’s in bounds, returning mask_value otherwise. The layout handles translation into a concrete index.
Sourcepub fn to_linear_slice(&self) -> Slice<E, ReadOnly>
 
pub fn to_linear_slice(&self) -> Slice<E, ReadOnly>
Interpret this view as a linear slice encompassing the entire view.
§Safety
No checking is done on whether the slice is contiguous in memory.
pub fn line_size(&self) -> u32
Source§impl<E: CubePrimitive, C: Coordinates + 'static, IO: Clone + 'static> View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates + 'static, IO: Clone + 'static> View<E, C, IO>
Sourcepub fn slice(&self, _pos: C, _size: C) -> View<E, C, ReadOnly>
 
pub fn slice(&self, _pos: C, _size: C) -> View<E, C, ReadOnly>
Create a slice starting from pos, with size.
The layout handles translation into concrete indices.
Size will be clamped to the current layout size.
Sourcepub fn slice_unchecked(&self, _pos: C, _size: C) -> View<E, C, ReadOnly>
 
pub fn slice_unchecked(&self, _pos: C, _size: C) -> View<E, C, ReadOnly>
Create a slice starting from pos, with size.
The layout handles translation into concrete indices.
Size and pos will be clamped to the current layout size.
#Safety
Access is always unchecked
pub fn __expand_slice( scope: &mut Scope, this: ViewExpand<E, C, IO>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadOnly>
pub fn __expand_slice_unchecked( scope: &mut Scope, this: ViewExpand<E, C, IO>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadOnly>
Source§impl<E: CubePrimitive, C: Coordinates> View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates> View<E, C, ReadWrite>
Sourcepub fn write(&self, pos: C, value: E)
 
pub fn write(&self, pos: C, value: E)
Write a line to pos. The layout handles translation into a concrete index.
Sourcepub fn write_checked(&self, pos: C, value: E)
 
pub fn write_checked(&self, pos: C, value: E)
Write a line to pos if it’s in bounds. The layout handles translation into a concrete index.
Sourcepub fn to_linear_slice_mut(&self) -> Slice<E, ReadWrite>
 
pub fn to_linear_slice_mut(&self) -> Slice<E, ReadWrite>
Interpret this view as a mutable linear slice encompassing the entire view.
§Safety
No checking is done on whether the slice is contiguous in memory.
Source§impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates + 'static> View<E, C, ReadWrite>
Sourcepub fn slice_mut(&self, _pos: C, _size: C) -> View<E, C, ReadWrite>
 
pub fn slice_mut(&self, _pos: C, _size: C) -> View<E, C, ReadWrite>
Create a mutable slice starting from pos, with size.
The layout handles translation into concrete indices.
Size and pos will be clamped to the current layout size.
Sourcepub fn slice_mut_unchecked(&self, _pos: C, _size: C) -> View<E, C, ReadWrite>
 
pub fn slice_mut_unchecked(&self, _pos: C, _size: C) -> View<E, C, ReadWrite>
Create a mutable slice starting from pos, with size.
The layout handles translation into concrete indices.
Size and pos will be clamped to the current layout size.
§Safety
Access is always unchecked.
pub fn __expand_slice_mut( scope: &mut Scope, this: ViewExpand<E, C, ReadWrite>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadWrite>
pub fn __expand_slice_mut_unchecked( scope: &mut Scope, this: ViewExpand<E, C, ReadWrite>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadWrite>
Source§impl<E: CubePrimitive, C: Coordinates + 'static, IO: SliceVisibility> View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates + 'static, IO: SliceVisibility> View<E, C, IO>
Sourcepub fn tensor_map_load(
    &self,
    _barrier: &Barrier,
    _shared_memory: &mut Slice<E, ReadWrite>,
    _pos: C,
) -> View<E, C, ReadWrite>
 
pub fn tensor_map_load( &self, _barrier: &Barrier, _shared_memory: &mut Slice<E, ReadWrite>, _pos: C, ) -> View<E, C, ReadWrite>
.Execute a TMA load into shared memory, if the underlying storage supports it. Panics if it’s unsupported.
Sourcepub fn as_tensor_map(&self) -> CubeOption<TensorMap<E>>
 
pub fn as_tensor_map(&self) -> CubeOption<TensorMap<E>>
Fetches the underlying tensor map if present, to override the layout and apply a different base dimensionality.
Source§impl<E: CubePrimitive, C: Coordinates> View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates> View<E, C, ReadWrite>
Sourcepub fn tensor_map_store(
    &self,
    _shared_memory: &Slice<E>,
    _pos: C,
) -> View<E, C, ReadWrite>
 
pub fn tensor_map_store( &self, _shared_memory: &Slice<E>, _pos: C, ) -> View<E, C, ReadWrite>
.Execute a TMA store into global memory, if the underlying storage supports it. Panics if it’s unsupported.
Trait Implementations§
Source§impl<E: Clone + CubePrimitive, C: Clone + Coordinates, IO: Clone + Clone> Clone for View<E, C, IO>
 
impl<E: Clone + CubePrimitive, C: Clone + Coordinates, IO: Clone + Clone> Clone for View<E, C, IO>
Source§impl<E: CubePrimitive, C: Coordinates, IO: Clone> CubeIndex for View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates, IO: Clone> CubeIndex for View<E, C, IO>
type Output = E
type Idx = C
fn cube_idx(&self, _i: Self::Idx) -> &Self::Output
fn expand_index( scope: &mut Scope, array: Self::ExpandType, index: <Self::Idx as CubeType>::ExpandType, ) -> <Self::Output as CubeType>::ExpandType
fn expand_index_unchecked( scope: &mut Scope, array: Self::ExpandType, index: <Self::Idx as CubeType>::ExpandType, ) -> <Self::Output as CubeType>::ExpandType
Source§impl<E: CubePrimitive, C: Coordinates> CubeIndexMut for View<E, C, ReadWrite>
 
impl<E: CubePrimitive, C: Coordinates> CubeIndexMut for View<E, C, ReadWrite>
fn cube_idx_mut(&mut self, _i: Self::Idx) -> &mut Self::Output
fn expand_index_mut( scope: &mut Scope, array: Self::ExpandType, index: <Self::Idx as CubeType>::ExpandType, value: <Self::Output as CubeType>::ExpandType, )
Source§impl<E: CubePrimitive, C: Coordinates, IO: Clone> CubeType for View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates, IO: Clone> CubeType for View<E, C, IO>
type ExpandType = ViewExpand<E, C, IO>
Source§fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
 
fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
Source§impl<E: CubePrimitive, C: Coordinates + 'static, IO: SliceVisibility> LaunchArg for View<E, C, IO>
 
impl<E: CubePrimitive, C: Coordinates + 'static, IO: SliceVisibility> LaunchArg for View<E, C, IO>
Source§type RuntimeArg<'a, R: Runtime> = ViewArg<'a, C, R>
 
type RuntimeArg<'a, R: Runtime> = ViewArg<'a, C, R>
Source§type CompilationArg = ViewCompilationArg<C>
 
type CompilationArg = ViewCompilationArg<C>
fn compilation_arg<'a, R: Runtime>( runtime_arg: &Self::RuntimeArg<'a, R>, ) -> Self::CompilationArg
Source§fn expand(
    arg: &Self::CompilationArg,
    builder: &mut KernelBuilder,
) -> <Self as CubeType>::ExpandType
 
fn expand( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType
Source§fn expand_output(
    arg: &Self::CompilationArg,
    builder: &mut KernelBuilder,
) -> <Self as CubeType>::ExpandType
 
fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType
Source§impl<T: CubePrimitive, C: Coordinates, IO: Clone> Lined for View<T, C, IO>
 
impl<T: CubePrimitive, C: Coordinates, IO: Clone> Lined for View<T, C, IO>
fn line_size(&self) -> u32
fn __expand_line_size(_scope: &mut Scope, this: Self::ExpandType) -> u32
Source§impl<T: CubePrimitive, C: Coordinates, IO: Clone> ViewOperations<T, C> for View<T, C, IO>
 
impl<T: CubePrimitive, C: Coordinates, IO: Clone> ViewOperations<T, C> for View<T, C, IO>
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 to_linear_slice(&self, pos: C, size: C) -> Slice<T, ReadOnly>
 
fn to_linear_slice(&self, pos: C, size: C) -> Slice<T, ReadOnly>
pos, with size.
The layout handles translation into concrete indices.fn as_tensor_map(&self) -> CubeOption<TensorMap<T>>
Source§fn tensor_map_load(
    &self,
    barrier: &Barrier,
    shared_memory: &mut Slice<T, ReadWrite>,
    pos: C,
)
 
fn tensor_map_load( &self, barrier: &Barrier, shared_memory: &mut Slice<T, ReadWrite>, pos: C, )
fn shape(&self) -> C
fn is_in_bounds(&self, pos: C) -> bool
fn __expand_read( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_read_checked( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_read_masked( scope: &mut 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: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType
fn __expand_to_linear_slice( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, size: <C as CubeType>::ExpandType, ) -> <Slice<T, ReadOnly> as CubeType>::ExpandType
fn __expand_as_tensor_map( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <CubeOption<TensorMap<T>> as CubeType>::ExpandType
fn __expand_tensor_map_load( scope: &mut Scope, this: <Self as CubeType>::ExpandType, barrier: <Barrier as CubeType>::ExpandType, shared_memory: <Slice<T, ReadWrite> as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType
fn __expand_shape( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <C as CubeType>::ExpandType
fn __expand_is_in_bounds( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType
Source§impl<T: CubePrimitive, C: Coordinates> ViewOperationsMut<T, C> for View<T, C, ReadWrite>
 
impl<T: CubePrimitive, C: Coordinates> ViewOperationsMut<T, C> for View<T, C, ReadWrite>
fn write(&self, pos: C, value: T)
fn write_checked(&self, pos: C, value: T)
Source§fn to_linear_slice_mut(&self, pos: C, size: C) -> Slice<T, ReadWrite>
 
fn to_linear_slice_mut(&self, pos: C, size: C) -> Slice<T, ReadWrite>
pos, with size.
The layout handles translation into concrete indices.