Struct cubecl_core::frontend::Tensor

source ·
pub struct Tensor<T: CubeType> { /* private fields */ }
Expand description

The tensor type is similar to the array type, however it comes with more metadata such as stride and shape.

Implementations§

source§

impl<T: CubeType> Tensor<T>

source

pub fn new() -> Self

Constructs a new Tensor.

source§

impl<T: CubeType> Tensor<T>

source

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

Obtain the stride of input at dimension dim

source

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

Obtain the shape of input at dimension dim

source

pub fn len(&self) -> UInt

The length of the buffer representing 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 rank(&self) -> UInt

Returns the rank of the tensor.

Trait Implementations§

source§

impl<T: CubeType> CubeType for Tensor<T>

§

type ExpandType = ExpandElementTyped<Tensor<T>>

source§

fn init(context: &mut CubeContext, expand: Self::ExpandType) -> Self::ExpandType

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

impl<C: CubeType> ExpandElementBaseInit for Tensor<C>

source§

impl<E: CubeType, I: Into<UInt>> Index<I> for Tensor<E>

§

type Output = E

The returned type after indexing.
source§

fn index(&self, _index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<E: CubeType, I: Into<UInt>> IndexMut<I> for Tensor<E>

source§

fn index_mut(&mut self, _index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<C: CubePrimitive> LaunchArg for Tensor<C>

§

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

The runtime argument for the kernel.
source§

impl<C: CubePrimitive> LaunchArgExpand for Tensor<C>

source§

fn expand( builder: &mut KernelBuilder, vectorization: Vectorization, ) -> ExpandElementTyped<Tensor<C>>

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

fn expand_output( builder: &mut KernelBuilder, vectorization: Vectorization, ) -> ExpandElementTyped<Tensor<C>>

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

impl<E: CubePrimitive> SliceOperator<E> for Tensor<E>

§

type Expand = ExpandElementTyped<Tensor<E>>

source§

fn slice<Start: Index, End: Index>( &self, start: Start, end: End, ) -> &Slice<'_, E>

Return a read-only view of all elements comprise between the start and end index.
source§

fn __expand_slice<Start: Index, End: Index>( context: &mut CubeContext, expand: Self::Expand, start: Start, end: End, ) -> ExpandElementTyped<Slice<'static, E>>

Expand function of SliceOperator::slice.
source§

fn slice_mut<Start: Index, End: Index>( &mut self, start: Start, end: End, ) -> &mut SliceMut<'_, E>

Return a read-write view of all elements comprise between the start and end index.
source§

fn __expand_slice_mut<Start: Index, End: Index>( context: &mut CubeContext, expand: Self::Expand, start: Start, end: End, ) -> ExpandElementTyped<SliceMut<'static, E>>

Expand function of SliceOperator::slice_mut.
source§

fn slice_mut_unsafe<Start: Index, End: Index>( &self, start: Start, end: End, ) -> &mut SliceMut<'_, E>

Return a read-write view of all elements comprise between the start and end index. Read more
source§

fn __expand_slice_mut_unsafe<Start: Index, End: Index>( context: &mut CubeContext, expand: Self::Expand, start: Start, end: End, ) -> ExpandElementTyped<SliceMut<'static, E>>

source§

fn as_slice(&self) -> &Slice<'_, E>

Reinterprete the current type as a read-only slice.
source§

fn __expand_as_slice( context: &mut CubeContext, expand: Self::Expand, ) -> ExpandElementTyped<Slice<'static, E>>

Expand function of SliceOperator::as_slice.
source§

fn as_slice_mut(&mut self) -> &mut SliceMut<'_, E>

Reinterprete the current type as a read-write slice.
source§

fn __expand_as_slice_mut( context: &mut CubeContext, expand: Self::Expand, ) -> ExpandElementTyped<SliceMut<'static, E>>

Expand function of SliceOperator::as_slice_mut.
source§

fn as_slice_mut_unsafe(&self) -> &mut SliceMut<'_, E>

Reinterprete the current type as a read-write slice. Read more
source§

fn __expand_as_slice_mut_unsafe( context: &mut CubeContext, expand: Self::Expand, ) -> ExpandElementTyped<SliceMut<'static, E>>

source§

impl<T: Vectorized + CubeType> Vectorized for &Tensor<T>

source§

fn vectorization_factor(&self) -> UInt

source§

fn vectorize(self, _factor: UInt) -> Self

source§

impl<T: Vectorized + CubeType> Vectorized for &mut Tensor<T>

source§

fn vectorization_factor(&self) -> UInt

source§

fn vectorize(self, _factor: UInt) -> Self

source§

impl<T: Vectorized + CubeType> Vectorized for Tensor<T>

source§

fn vectorization_factor(&self) -> UInt

source§

fn vectorize(self, _factor: UInt) -> Self

Auto Trait Implementations§

§

impl<T> Freeze for Tensor<T>

§

impl<T> RefUnwindSafe for Tensor<T>
where T: RefUnwindSafe,

§

impl<T> Send for Tensor<T>
where T: Send,

§

impl<T> Sync for Tensor<T>
where T: Sync,

§

impl<T> Unpin for Tensor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Tensor<T>
where T: 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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