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>
impl<T: CubePrimitive> TensorMap<T>
Sourcepub fn coordinate<I: Index, D: Index>(&self, _index: I, _dim: D) -> u32
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.
Sourcepub fn len(&self) -> u32
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.
Sourcepub fn buffer_len(&self) -> u32
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.
Sourcepub fn try_cast_unchecked<E: CubePrimitive>(&self) -> TensorMap<E>
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.
pub fn __expand_stride<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>
pub fn __expand_shape<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>
pub fn __expand_coordinate<I: Index, D: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, index: ExpandElementTyped<u32>, dim: ExpandElementTyped<u32>, ) -> ExpandElementTyped<u32>
pub fn __expand_len<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, ) -> ExpandElementTyped<u32>
pub fn __expand_buffer_len<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, ) -> ExpandElementTyped<u32>
pub fn __expand_rank<C: Index>( scope: &mut Scope, expand: ExpandElementTyped<Tensor<T>>, ) -> ExpandElementTyped<u32>
Source§impl<E: CubePrimitive> TensorMap<E>
impl<E: CubePrimitive> TensorMap<E>
Sourcepub fn dummy() -> Self
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.