fma
이 페이지에서

fma()

함수, 내장 함수 분류

fma(a, b, c): fused multiply-add, a·b + c.

import { fma } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

const fma: <K extends FloatKey>(
a: ReadonlyNode<K>,
b: NoInfer<ArithArg<K>>,
c: NoInfer<ArithArg<K>>,
) => Node<K>

매개변수

a ReadonlyNode<K>
b NoInfer<ArithArg<K>>
c NoInfer<ArithArg<K>>

반환값

Node<K>

설명

WGSL emits the hardware fma, a single rounding that a driver’s fast-math cannot distribute or reassociate, unlike a.mul(b).add(c). GLSL ES 3.00 has no fma, so the GLSL output is the unfused (a * b + c). Use it only where the single rounding is the point, such as the error term fma(a, b, -a*b) of an exact product, which some GPU compilers fold away when it is built from separate operations.

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

fma(a, b, c).

GLSL ES 3.00 (WebGL2) 지원

((a) * (b) + (c)).

CPU 오라클 지원

Evaluated in f64 by the oracle.

소스

src/core/ir/node.ts, 1722행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고