cubecl_core/frontend/operation/
fma.rs

1use crate::{
2    ir::{FmaOperator, Instruction, Operator},
3    prelude::{CubeContext, CubePrimitive, ExpandElement},
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    context: &mut CubeContext,
17    a: ExpandElement,
18    b: ExpandElement,
19    c: ExpandElement,
20) -> ExpandElement {
21    let output = context.create_local(a.item);
22
23    let out = *output;
24    let a = *a;
25    let b = *b;
26    let c = *c;
27
28    context.register(Instruction::new(
29        Operator::Fma(FmaOperator { a, b, c }),
30        out,
31    ));
32
33    output
34}