Skip to main content

ruda_kernel/dsl/frontend/operation/
fma.rs

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