View

Struct View 

Source
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>

Source

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

Source

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>

Source

pub fn view<T: Coordinates>( &self, _layout: impl Into<VirtualLayout<T, C>>, ) -> View<E, T, ReadOnly>

Source

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>

Source

pub fn view_mut<T: Coordinates>( &self, _layout: impl Layout<Coordinates = T, SourceCoordinates = C>, ) -> View<E, T, ReadWrite>

Source

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>

Source

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

Source

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>

Source

pub fn shape(&self) -> C

Calls Layout::shape on the view’s layout

Source

pub fn is_in_bounds(&self, _pos: C) -> bool

Calls Layout::is_in_bounds on the view’s layout

Source

pub fn __expand_shape( scope: &mut Scope, this: ViewExpand<E, C, IO>, ) -> C::ExpandType

Source

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>

Source

pub fn read(&self, pos: C) -> E

Read a line at pos. The layout handles translation into a concrete index.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn line_size(&self) -> u32

Source§

impl<E: CubePrimitive, C: Coordinates + 'static, IO: Clone + 'static> View<E, C, IO>

Source

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.

Source

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

Source

pub fn __expand_slice( scope: &mut Scope, this: ViewExpand<E, C, IO>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadOnly>

Source

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>

Source

pub fn write(&self, pos: C, value: E)

Write a line to pos. The layout handles translation into a concrete index.

Source

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.

Source

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>

Source

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.

Source

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.

Source

pub fn __expand_slice_mut( scope: &mut Scope, this: ViewExpand<E, C, ReadWrite>, pos: C::ExpandType, size: C::ExpandType, ) -> ViewExpand<E, C, ReadWrite>

Source

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>

Source

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.

Source

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>

Source

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>

Source§

fn clone(&self) -> View<E, C, IO>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: CubePrimitive, C: Coordinates, IO: Clone> CubeIndex for View<E, C, IO>

Source§

type Output = E

Source§

type Idx = C

Source§

fn cube_idx(&self, _i: Self::Idx) -> &Self::Output

Source§

fn expand_index( scope: &mut Scope, array: Self::ExpandType, index: <Self::Idx as CubeType>::ExpandType, ) -> <Self::Output as CubeType>::ExpandType

Source§

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>

Source§

fn cube_idx_mut(&mut self, _i: Self::Idx) -> &mut Self::Output

Source§

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>

Source§

type ExpandType = ViewExpand<E, C, IO>

Source§

fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType

Wrapper around the init method, necessary to type inference.
Source§

impl<E: CubePrimitive, C: Coordinates + 'static, IO: SliceVisibility> LaunchArg for View<E, C, IO>

Source§

type RuntimeArg<'a, R: Runtime> = ViewArg<'a, C, R>

The runtime argument for the kernel.
Source§

type CompilationArg = ViewCompilationArg<C>

Compilation argument.
Source§

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

Register an input variable during compilation that fill the KernelBuilder.
Source§

fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType

Register an output variable during compilation that fill the KernelBuilder.
Source§

impl<T: CubePrimitive, C: Coordinates, IO: Clone> Lined for View<T, C, IO>

Source§

fn line_size(&self) -> u32

Source§

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>

Source§

fn read(&self, pos: C) -> T

Source§

fn read_checked(&self, pos: C) -> T

Source§

fn read_masked(&self, pos: C, value: T) -> T

Source§

fn read_unchecked(&self, pos: C) -> T

Source§

fn to_linear_slice(&self, pos: C, size: C) -> Slice<T, ReadOnly>

Create a slice starting from pos, with size. The layout handles translation into concrete indices.
Source§

fn as_tensor_map(&self) -> CubeOption<TensorMap<T>>

Source§

fn tensor_map_load( &self, barrier: &Barrier, shared_memory: &mut Slice<T, ReadWrite>, pos: C, )

.Execute a TMA load into shared memory, if the underlying storage supports it. Panics if it’s unsupported.
Source§

fn shape(&self) -> C

Source§

fn is_in_bounds(&self, pos: C) -> bool

Source§

fn __expand_read( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType

Source§

fn __expand_read_checked( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType

Source§

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

Source§

fn __expand_read_unchecked( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <T as CubeType>::ExpandType

Source§

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

Source§

fn __expand_as_tensor_map( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <CubeOption<TensorMap<T>> as CubeType>::ExpandType

Source§

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

Source§

fn __expand_shape( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <C as CubeType>::ExpandType

Source§

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>

Source§

fn write(&self, pos: C, value: T)

Source§

fn write_checked(&self, pos: C, value: T)

Source§

fn to_linear_slice_mut(&self, pos: C, size: C) -> Slice<T, ReadWrite>

Create a mutable slice starting from pos, with size. The layout handles translation into concrete indices.
Source§

fn tensor_map_store(&self, shared_memory: &Slice<T>, pos: C)

.Execute a TMA store into global memory, if the underlying storage supports it. Panics if it’s unsupported.
Source§

fn __expand_write( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, value: <T as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

fn __expand_write_checked( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, value: <T as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

fn __expand_to_linear_slice_mut( scope: &mut Scope, this: <Self as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, size: <C as CubeType>::ExpandType, ) -> <Slice<T, ReadWrite> as CubeType>::ExpandType

Source§

fn __expand_tensor_map_store( scope: &mut Scope, this: <Self as CubeType>::ExpandType, shared_memory: <Slice<T> as CubeType>::ExpandType, pos: <C as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

impl<E: CubePrimitive, C: Coordinates, IO: Clone> Copy for View<E, C, IO>

Source§

impl<E: CubePrimitive, C: Coordinates, IO: Clone> Send for View<E, C, IO>

Source§

impl<E: CubePrimitive, C: Coordinates, IO: Clone> Sync for View<E, C, IO>

Auto Trait Implementations§

§

impl<E, C, IO> Freeze for View<E, C, IO>

§

impl<E, C, IO> RefUnwindSafe for View<E, C, IO>

§

impl<E, C, IO> Unpin for View<E, C, IO>
where C: Unpin, E: Unpin, IO: Unpin,

§

impl<E, C, IO> UnwindSafe for View<E, C, IO>
where C: UnwindSafe, E: UnwindSafe, IO: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V