Skip to main content

poulpy_hal/delegates/
module.rs

1use crate::{
2    api::{MatZnxAlloc, ModuleN, ModuleNew, ScalarZnxAlloc, VecZnxAlloc},
3    layouts::{Backend, MatZnx, Module, ScalarZnx, VecZnx},
4    oep::HalModuleImpl,
5};
6
7impl<B> ModuleNew<B> for Module<B>
8where
9    B: Backend + HalModuleImpl<B>,
10{
11    type Config = <B as HalModuleImpl<B>>::Config;
12
13    fn new(n: u64) -> Self {
14        B::new(n)
15    }
16
17    fn new_with(n: u64, config: Self::Config) -> Self {
18        B::new_with(n, config)
19    }
20}
21
22impl<B> ModuleN for Module<B>
23where
24    B: Backend,
25{
26    fn n(&self) -> usize {
27        self.n()
28    }
29}
30
31impl<B: Backend> ScalarZnxAlloc<B> for Module<B> {
32    fn scalar_znx_alloc(&self, cols: usize) -> ScalarZnx<B::OwnedBuf, B::ZnxWord> {
33        Module::<B>::scalar_znx_alloc(self, cols)
34    }
35}
36
37impl<B: Backend> VecZnxAlloc<B> for Module<B> {
38    fn vec_znx_alloc(&self, cols: usize, size: usize) -> VecZnx<B::OwnedBuf, B::ZnxWord> {
39        Module::<B>::vec_znx_alloc(self, cols, size)
40    }
41}
42
43impl<B: Backend> MatZnxAlloc<B> for Module<B> {
44    fn mat_znx_alloc(&self, rows: usize, cols_in: usize, cols_out: usize, size: usize) -> MatZnx<B::OwnedBuf, B::ZnxWord> {
45        Module::<B>::mat_znx_alloc(self, rows, cols_in, cols_out, size)
46    }
47}