Skip to main content
The CuTe DSL provides high-level operations for matrix multiplication, memory transfers, and tensor manipulation.

GEMM Operations

gemm

Performs General Matrix Multiply-Accumulate (GEMM) operation: D = A * B + C.
MmaAtom
required
MMA atom defining the computation pattern (e.g., warp-level or warpgroup-level MMA)
Tensor
required
Destination tensor (output)
Union[Tensor, List[Tensor]]
required
First source tensor or [tensor, scale_factor] for block-scaled GEMM
Union[Tensor, List[Tensor]]
required
Second source tensor or [tensor, scale_factor] for block-scaled GEMM
Tensor
required
Accumulator tensor (can alias with d)
Dispatch Rules:
Example:

Copy Operations

copy

Performs atomic or tiled copy from source to destination tensor.
CopyAtom
required
Copy atom defining the copy pattern
Tensor
required
Source tensor
Tensor
required
Destination tensor
Example:

basic_copy

Performs basic element-wise copy without atoms (for simple cases).
Tensor
required
Source tensor
Tensor
required
Destination tensor (must have same size as src)
Example:

basic_copy_if

Performs predicated element-wise copy.
Tensor
required
Predicate tensor (boolean values)
Tensor
required
Source tensor
Tensor
required
Destination tensor
Example:

autovec_copy

Performs vectorized copy with automatic vectorization.
Automatically vectorizes the copy based on tensor alignment and element type.

prefetch

Prefetches data into cache.
Tensor
required
Tensor to prefetch
CacheEvictionPriority
default:"EVICT_FIRST"
Cache eviction priority

Tensor Operations

Prints tensor contents (for debugging).
Example:

printf

Prints formatted output from device code.
Example:

Reduction Operations

any_

Returns True if any element in the tensor is non-zero.

all_

Returns True if all elements in the tensor are non-zero.

Conditional Operations

where

Element-wise conditional selection.
Tensor
required
Boolean condition tensor
Tensor
required
Values to select when condition is True
Tensor
required
Values to select when condition is False
Example:

Control Flow

for_generate

Generates loop iterations in device code.

if_generate

Generates conditional branches in device code.

Complete GEMM Example

See Also