TensorMap

Struct TensorMap 

Source
pub struct TensorMap<E: CubePrimitive> { /* private fields */ }
Expand description

A CUDA CUtensorMap object. Represents a tensor encoded with a lot of metadata, and is an opaque packed object at runtime. Does not support retrieving any shapes or strides, nor does it give access to the pointer. So these need to be passed separately in an aliased Tensor if needed.

Also see [cubecl_common::tma].

Implementations§

Source§

impl<T: CubePrimitive> TensorMap<T>

Source

pub fn buffer(&self) -> Tensor<Line<T>>

Get a reference to the underlying buffer for the tensor map.

Source

pub fn stride<C: Index>(&self, _dim: C) -> u32

Obtain the stride of input at dimension dim

Source

pub fn shape<C: Index>(&self, _dim: C) -> u32

Obtain the shape of input at dimension dim

Source

pub fn coordinate<I: Index, D: Index>(&self, _index: I, _dim: D) -> u32

Obtain the coordinate corresponding to the given index of the tensor at dimension dim.

A coordinate is a list of indices corresponding to the multi-dimensional position of an element in the tensor. The dim element in a coordinate is the position along the dim dimension of the tensor.

Source

pub fn len(&self) -> u32

The number of vectorized elements in the tensor.

§Warning

The length will be affected by the vectorization factor. To obtain the number of elements, you should multiply the length by the vectorization factor.

Source

pub fn buffer_len(&self) -> u32

The length of the buffer representing the tensor in terms of vectorized elements.

§Warning

The buffer length will be affected by the vectorization factor. To obtain the number of elements, you should multiply the length by the vectorization factor.

Source

pub fn rank(&self) -> u32

Returns the rank of the tensor.

Source

pub fn try_cast_unchecked<E: CubePrimitive>(&self) -> TensorMap<E>

Try to cast the tensormap to the given type and panic if the type isn’t the same.

This function should only be used to satisfy the Rust type system, when two generic types are supposed to be the same.

Source

pub fn __expand_buffer( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, ) -> ExpandElementTyped<Tensor<Line<T>>>

Source

pub fn __expand_stride<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>

Source

pub fn __expand_shape<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>

Source

pub fn __expand_coordinate<I: Index, D: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, index: ExpandElementTyped<u32>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>

Source

pub fn __expand_len<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, ) -> ExpandElementTyped<u32>

Source

pub fn __expand_buffer_len<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, ) -> ExpandElementTyped<u32>

Source

pub fn __expand_rank<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<TensorMap<T>>, ) -> ExpandElementTyped<u32>

Trait Implementations§

Source§

impl<E: Clone + CubePrimitive> Clone for TensorMap<E>

Source§

fn clone(&self) -> TensorMap<E>

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> CubeType for TensorMap<E>

Source§

type ExpandType = ExpandElementTyped<TensorMap<E>>

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> ExpandElementIntoMut for TensorMap<E>

Source§

impl<E: CubePrimitive> LaunchArg for TensorMap<E>

Source§

type RuntimeArg<'a, R: Runtime> = TensorMapArg<'a, R>

The runtime argument for the kernel.
Source§

type CompilationArg = TensorMapCompilationArg

Compilation argument.
Source§

fn compilation_arg<R: Runtime>( _runtime_arg: &Self::RuntimeArg<'_, R>, ) -> Self::CompilationArg

Source§

fn expand( _arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> ExpandElementTyped<TensorMap<E>>

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

fn expand_output( _arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> ExpandElementTyped<TensorMap<E>>

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

impl<E: CubePrimitive> Lined for TensorMap<E>

Source§

fn line_size(&self) -> u32

Source§

fn __expand_line_size(_scope: &mut Scope, this: Self::ExpandType) -> u32

Source§

impl<E: CubePrimitive> Copy for TensorMap<E>

Auto Trait Implementations§

§

impl<E> Freeze for TensorMap<E>

§

impl<E> RefUnwindSafe for TensorMap<E>
where E: RefUnwindSafe,

§

impl<E> Send for TensorMap<E>

§

impl<E> Sync for TensorMap<E>

§

impl<E> Unpin for TensorMap<E>
where E: Unpin,

§

impl<E> UnwindSafe for TensorMap<E>
where E: 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