Skip to main content
Log in

Mojo function

fma

fma(a: Int, b: Int, c: Int) -> Int

Performs fma (fused multiply-add) on the inputs.

The result is (a * b) + c.

Args:

  • a (Int): The first input.
  • b (Int): The second input.
  • c (Int): The third input.

Returns:

(a * b) + c.

fma(a: UInt, b: UInt, c: UInt) -> UInt

Performs fma (fused multiply-add) on the inputs.

The result is (a * b) + c.

Args:

  • a (UInt): The first input.
  • b (UInt): The second input.
  • c (UInt): The third input.

Returns:

(a * b) + c.

fma[dtype: DType, width: Int, //](a: SIMD[dtype, width], b: SIMD[dtype, width], c: SIMD[dtype, width]) -> SIMD[dtype, width]

Performs elementwise fma (fused multiply-add) on the inputs.

Each element in the result SIMD vector is (AiBi)+Ci(A_i * B_i) + C_i, where AiA_i, BiB_i and CiC_i are elements at index ii in a, b, and c respectively.

Parameters:

  • dtype (DType): The dtype of the input SIMD vector.
  • width (Int): The width of the input and output SIMD vector.

Args:

  • a (SIMD[dtype, width]): The first vector of inputs.
  • b (SIMD[dtype, width]): The second vector of inputs.
  • c (SIMD[dtype, width]): The third vector of inputs.

Returns:

Elementwise fma of a, b and c.