1#[macro_export]
2macro_rules! hal_impl_convolution {
3 ($defaults:ident) => {
4 fn cnv_prepare_left_tmp_bytes(module: &Module<Self>, res_size: usize, a_size: usize) -> usize {
5 <Self as $defaults<Self>>::cnv_prepare_left_tmp_bytes_default(module, res_size, a_size)
6 }
7
8 fn cnv_prepare_left(
9 module: &Module<Self>,
10 res: &mut poulpy_hal::layouts::CnvPVecLBackendMut<'_, Self>,
11 a: &poulpy_hal::layouts::VecZnxBackendRef<'_, Self>,
12 mask: i64,
13 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
14 ) {
15 let mut scratch = scratch.borrow();
16 <Self as $defaults<Self>>::cnv_prepare_left_default(module, res, a, mask, &mut scratch);
17 }
18
19 fn cnv_prepare_right_tmp_bytes(module: &Module<Self>, res_size: usize, a_size: usize) -> usize {
20 <Self as $defaults<Self>>::cnv_prepare_right_tmp_bytes_default(module, res_size, a_size)
21 }
22
23 fn cnv_prepare_right(
24 module: &Module<Self>,
25 res: &mut poulpy_hal::layouts::CnvPVecRBackendMut<'_, Self>,
26 a: &poulpy_hal::layouts::VecZnxBackendRef<'_, Self>,
27 mask: i64,
28 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
29 ) {
30 let mut scratch = scratch.borrow();
31 <Self as $defaults<Self>>::cnv_prepare_right_default(module, res, a, mask, &mut scratch);
32 }
33
34 fn cnv_apply_dft_tmp_bytes(
35 module: &Module<Self>,
36 cnv_offset: usize,
37 res_size: usize,
38 a_size: usize,
39 b_size: usize,
40 ) -> usize {
41 <Self as $defaults<Self>>::cnv_apply_dft_tmp_bytes_default(module, cnv_offset, res_size, a_size, b_size)
42 }
43
44 fn cnv_by_const_apply_tmp_bytes(
45 module: &Module<Self>,
46 cnv_offset: usize,
47 res_size: usize,
48 a_size: usize,
49 b_size: usize,
50 ) -> usize {
51 <Self as $defaults<Self>>::cnv_by_const_apply_tmp_bytes_default(module, cnv_offset, res_size, a_size, b_size)
52 }
53
54 #[allow(clippy::too_many_arguments)]
55 fn cnv_by_const_apply(
56 module: &Module<Self>,
57 cnv_offset: usize,
58 mut res: &mut poulpy_hal::layouts::VecZnxBigBackendMut<'_, Self>,
59 res_col: usize,
60 a: &poulpy_hal::layouts::VecZnxBackendRef<'_, Self>,
61 a_col: usize,
62 b: &poulpy_hal::layouts::VecZnxBackendRef<'_, Self>,
63 b_col: usize,
64 b_coeff: usize,
65 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
66 ) {
67 let mut scratch = scratch.borrow();
68 <Self as $defaults<Self>>::cnv_by_const_apply_default(
69 module,
70 cnv_offset,
71 &mut res,
72 res_col,
73 a,
74 a_col,
75 b,
76 b_col,
77 b_coeff,
78 &mut scratch,
79 );
80 }
81
82 #[allow(clippy::too_many_arguments)]
83 fn cnv_apply_dft(
84 module: &Module<Self>,
85 cnv_offset: usize,
86 mut res: &mut poulpy_hal::layouts::VecZnxDftBackendMut<'_, Self>,
87 res_col: usize,
88 a: &poulpy_hal::layouts::CnvPVecLBackendRef<'_, Self>,
89 a_col: usize,
90 b: &poulpy_hal::layouts::CnvPVecRBackendRef<'_, Self>,
91 b_col: usize,
92 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
93 ) {
94 let mut scratch = scratch.borrow();
95 <Self as $defaults<Self>>::cnv_apply_dft_default(
96 module,
97 cnv_offset,
98 &mut res,
99 res_col,
100 a,
101 a_col,
102 b,
103 b_col,
104 &mut scratch,
105 );
106 }
107
108 fn cnv_pairwise_apply_dft_tmp_bytes(
109 module: &Module<Self>,
110 cnv_offset: usize,
111 res_size: usize,
112 a_size: usize,
113 b_size: usize,
114 ) -> usize {
115 <Self as $defaults<Self>>::cnv_pairwise_apply_dft_tmp_bytes_default(module, cnv_offset, res_size, a_size, b_size)
116 }
117
118 #[allow(clippy::too_many_arguments)]
119 fn cnv_pairwise_apply_dft(
120 module: &Module<Self>,
121 cnv_offset: usize,
122 mut res: &mut poulpy_hal::layouts::VecZnxDftBackendMut<'_, Self>,
123 res_col: usize,
124 a: &poulpy_hal::layouts::CnvPVecLBackendRef<'_, Self>,
125 b: &poulpy_hal::layouts::CnvPVecRBackendRef<'_, Self>,
126 i: usize,
127 j: usize,
128 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
129 ) {
130 let mut scratch = scratch.borrow();
131 <Self as $defaults<Self>>::cnv_pairwise_apply_dft_default(
132 module,
133 cnv_offset,
134 &mut res,
135 res_col,
136 a,
137 b,
138 i,
139 j,
140 &mut scratch,
141 );
142 }
143
144 fn cnv_prepare_self_tmp_bytes(module: &Module<Self>, res_size: usize, a_size: usize) -> usize {
145 <Self as $defaults<Self>>::cnv_prepare_self_tmp_bytes_default(module, res_size, a_size)
146 }
147
148 fn cnv_prepare_self(
149 module: &Module<Self>,
150 left: &mut poulpy_hal::layouts::CnvPVecLBackendMut<'_, Self>,
151 right: &mut poulpy_hal::layouts::CnvPVecRBackendMut<'_, Self>,
152 a: &poulpy_hal::layouts::VecZnxBackendRef<'_, Self>,
153 mask: i64,
154 scratch: &mut poulpy_hal::layouts::ScratchArena<'_, Self>,
155 ) {
156 let mut scratch = scratch.borrow();
157 <Self as $defaults<Self>>::cnv_prepare_self_default(module, left, right, a, mask, &mut scratch);
158 }
159 };
160}