arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rs
backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rsRaw
 1use crate::{
 2    hal::{
 3        api::{ZnxInfos, ZnxSliceSize, ZnxView},
 4        layouts::{Data, DataRef, VecZnxDft, VecZnxDftBytesOf, VecZnxDftOwned},
 5        oep::{VecZnxDftAllocBytesImpl, VecZnxDftAllocImpl},
 6    },
 7    implementation::cpu_spqlios::module_ntt120::NTT120,
 8};
 9
10const VEC_ZNX_DFT_NTT120_WORDSIZE: usize = 4;
11
12impl<D: Data> ZnxSliceSize for VecZnxDft<D, NTT120> {
13    fn sl(&self) -> usize {
14        VEC_ZNX_DFT_NTT120_WORDSIZE * self.n() * self.cols()
15    }
16}
17
18impl<D: Data> VecZnxDftBytesOf for VecZnxDft<D, NTT120> {
19    fn bytes_of(n: usize, cols: usize, size: usize) -> usize {
20        VEC_ZNX_DFT_NTT120_WORDSIZE * n * cols * size * size_of::<i64>()
21    }
22}
23
24impl<D: DataRef> ZnxView for VecZnxDft<D, NTT120> {
25    type Scalar = i64;
26}
27
28unsafe impl VecZnxDftAllocBytesImpl<NTT120> for NTT120 {
29    fn vec_znx_dft_alloc_bytes_impl(n: usize, cols: usize, size: usize) -> usize {
30        VecZnxDft::<Vec<u8>, NTT120>::bytes_of(n, cols, size)
31    }
32}
33
34unsafe impl VecZnxDftAllocImpl<NTT120> for NTT120 {
35    fn vec_znx_dft_alloc_impl(n: usize, cols: usize, size: usize) -> VecZnxDftOwned<NTT120> {
36        VecZnxDftOwned::alloc(n, cols, size)
37    }
38}