1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#[macro_use]
pub(crate) mod fuse;
#[macro_use]
pub(crate) mod kernel;
#[macro_use]
pub(crate) mod mmm;
mod scratch;
mod storage;
#[cfg(test)]
#[macro_use]
pub mod tests;

pub use fuse::*;
pub use kernel::*;
pub use mmm::*;
pub use scratch::*;
pub use storage::*;

#[cfg(test)]
pub use tests::*;

macro_rules! MMMKernel {
    ($typ:ident<$ti:ident>, $name:expr, $func:ident; $mr: expr, $nr: expr; $alignment_bytes_packed_a: expr, $alignment_bytes_packed_b: expr; $end_padding_packed_a: expr, $end_padding_packed_b: expr) => {
        #[derive(Copy, Clone, Debug, new)]
        pub struct $typ;

        impl MatMatMulKer<$ti> for $typ {
            #[inline(always)]
            fn name() -> &'static str {
                $name
            }
            #[inline(always)]
            fn mr() -> usize {
                $mr
            }
            #[inline(always)]
            fn nr() -> usize {
                $nr
            }
            fn alignment_bytes_packed_a() -> usize {
                $alignment_bytes_packed_a
            }
            fn alignment_bytes_packed_b() -> usize {
                $alignment_bytes_packed_b
            }
            fn end_padding_packed_a() -> usize {
                $end_padding_packed_a
            }
            fn end_padding_packed_b() -> usize {
                $end_padding_packed_b
            }
            #[inline(never)]
            fn kernel(spec: &MatMatMulKerSpec<$ti>) -> isize {
                unsafe { $func(spec) }
            }
        }
    }
}