Skip to main content

Overview

Epilogue operators perform element-wise transformations on GEMM output before writing to memory. They apply operations like linear combinations, activation functions, and element-wise operations on accumulator and source tensor fragments. Header: cutlass/epilogue/thread/linear_combination.h (and related headers)

LinearCombination

Applies a linear combination operator to arrays of elements: D = alpha * accumulator + beta * source.

Template Signature

Template Parameters

typename
Data type used to load and store tensors. Examples: float, half_t, int8_t
int
Number of elements computed per operation. Usually 128/sizeof_bits<ElementOutput_>, but can be 64 or 32 when there’s less data to store.
typename
default:"ElementOutput_"
Accumulator data type. Often higher precision than output, e.g., float accumulators for half_t output.
typename
default:"ElementOutput_"
Data type used to compute linear combination
ScaleType::Kind
default:"ScaleType::Default"
Controls alpha and beta scaling behavior. Options: Default, NoBetaScaling, OnlyAlphaScaling, Nothing
FloatRoundStyle
default:"FloatRoundStyle::round_to_nearest"
Rounding mode for numeric conversions
typename
default:"ElementOutput_"
Source tensor data type

Member Types

Parameters Structure

Constructors

Constructs the function object, possibly loading alpha/beta from pointers in device memory.

Member Functions

is_source_needed

Returns true if the source tensor is needed (i.e., beta != 0).

set_k_partition

Functionally required for serial reduction in the epilogue.

operator()

Computes linear scaling with source: D = alpha * accumulator + beta * source. Implementation (simplified):

Usage Example

From examples/00_basic_gemm/basic_gemm.cu:103-127:

LinearCombinationRelu

Linear combination followed by ReLU activation: D = ReLU(alpha * accumulator + beta * source). Header: cutlass/epilogue/thread/linear_combination_relu.h

Template Signature

Usage

LinearCombinationGelu

Linear combination followed by GELU activation. Header: cutlass/epilogue/thread/linear_combination_gelu.h

Template Signature

Template Parameters

bool
default:"true"
If true, uses fast approximation of GELU. If false, uses precise GELU calculation.

LinearCombinationClamp

Linear combination with clamping to specified range. Header: cutlass/epilogue/thread/linear_combination_clamp.h

Template Signature

Parameters Structure

Other Epilogue Operators

CUTLASS provides many specialized epilogue operators:

Activation Functions

  • LinearCombinationSigmoid - Sigmoid activation
  • LinearCombinationSilu - SiLU/Swish activation
  • LinearCombinationHardSwish - Hard Swish activation
  • LinearCombinationLeakyRelu - Leaky ReLU activation

Bias Operations

  • LinearCombinationBiasRelu - Add bias and apply ReLU
  • LinearCombinationBiasElementwise - Add bias with element-wise op

Specialized Operations

  • LinearCombinationResidualBlock - Residual connection fusion
  • LinearCombinationGeneric - Customizable generic epilogue
  • LinearCombinationPlanarComplex - Complex number operations

ScaleType Enumeration

Usage

Custom Epilogue Example

See Also

  • Gemm - Uses epilogue operators for output transformation
  • Array - Fragment type used by epilogue operators
  • TensorRef - Source and destination tensor references