tilelang.cuda.language.math¶

CUDA-specific floating-point arithmetic intrinsics.

Functions¶

fmul(x, y)

Multiply with CUDA round-to-nearest semantics.

fma(x, y, z)

Compute x * y + z as one CUDA fused multiply-add operation.

clamp_symmetric(x, limit)

Symmetric clipping using CUDA min.NaN.xorsign.abs (SM86+).

Module Contents¶

tilelang.cuda.language.math.fmul(x, y)¶

Multiply with CUDA round-to-nearest semantics.

Unlike the * operator, this intrinsic preserves an explicit multiply boundary during CUDA lowering. Vectorized loops may lower it to packed multiply instructions when the target supports them.

Parameters:
  • x (tvm.tirx.PrimExpr)

  • y (tvm.tirx.PrimExpr)

Return type:

tvm.tirx.PrimExpr

tilelang.cuda.language.math.fma(x, y, z)¶

Compute x * y + z as one CUDA fused multiply-add operation.

The result uses round-to-nearest semantics. Vectorized loops may lower the operation to packed FMA instructions when the target supports them.

Parameters:
  • x (tvm.tirx.PrimExpr)

  • y (tvm.tirx.PrimExpr)

  • z (tvm.tirx.PrimExpr)

Return type:

tvm.tirx.PrimExpr

tilelang.cuda.language.math.clamp_symmetric(x, limit)¶

Symmetric clipping using CUDA min.NaN.xorsign.abs (SM86+).

For non-NaN operands, requires limit > 0 and returns copysign(min(abs(x), limit), x), preserving the sign of zero. Supports float16, bfloat16, and float32 with matching operand dtypes. Python numeric limits are converted to the input’s element dtype; a scalar limit is broadcast to vector inputs. The caller supplies a positive limit for clipping semantics. No runtime check is emitted: scalar inputs lower to one PTX instruction. Even-width float16/bfloat16 vectors use packed x2 instructions, one per pair. Float32 vectors use one instruction per lane.

If either operand is NaN, the result is a canonical NaN; its original sign and payload are not preserved. Nonpositive numeric limits are outside this API’s contract. Subnormals are preserved. Each operand is evaluated once.

Parameters:
  • x (tvm.tirx.PrimExpr)

  • limit (tvm.tirx.PrimExpr)

Return type:

tvm.tirx.PrimExpr