cubecl_core/frontend/operation/
fma.rs

1use crate::{
2    ir::{Arithmetic, ExpandElement, FmaOperator, Instruction, Scope},
3    prelude::CubePrimitive,
4    unexpanded,
5};
6
7/// Fused multiply-add `A*B+C`.
8#[allow(unused_variables)]
9pub fn fma<C: CubePrimitive>(a: C, b: C, c: C) -> C {
10    unexpanded!()
11}
12
13/// Expand method of [fma].
14#[allow(unused_variables)]
15pub fn fma_expand<C: CubePrimitive>(
16    scope: &mut Scope,
17    a: ExpandElement,
18    b: ExpandElement,
19    c: ExpandElement,
20) -> ExpandElement {
21    let output = scope.create_local(a.item);
22
23    let out = *output;
24    let a = *a;
25    let b = *b;
26    let c = *c;
27
28    scope.register(Instruction::new(
29        Arithmetic::Fma(FmaOperator { a, b, c }),
30        out,
31    ));
32
33    output
34}