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 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_stride<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl<E: CubePrimitive> TensorMap<E>

Source

pub fn dummy() -> Self

Create a dummy tensor map to satisfy the type checker. Not actually valid, so the code should panic if this is ever reached.

Source

pub fn __expand_dummy(_scope: &mut Scope) -> ExpandElementTyped<Self>

Trait Implementations§

Source§

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

Source§

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

Returns a copy 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 init(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType

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

impl<E: CubePrimitive> ExpandElementBaseInit 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§

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

Source§

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

Source§

type CompilationArg = TensorMapCompilationArg

Compilation argument.
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> 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

Source§

impl<T> CubeLaunch for T