Skip to main content

poulpy_ckks/delegates/
imag.rs

1use anyhow::Result;
2use poulpy_core::{
3    GLWECopy, GLWENegate, GLWERotate, GLWEShift,
4    layouts::{GLWEToBackendMut, GLWEToBackendRef},
5};
6use poulpy_hal::{
7    api::ModuleN,
8    layouts::{Backend, Module, ScratchArena},
9};
10
11use crate::{CKKSCtBounds, SetCKKSInfos, api::CKKSImagOps, oep::CKKSImagImpl};
12
13impl<BE: Backend + CKKSImagImpl<BE>> CKKSImagOps<BE> for Module<BE>
14where
15    Module<BE>: GLWECopy<BE> + GLWENegate<BE> + GLWERotate<BE> + GLWEShift<BE> + ModuleN,
16{
17    fn ckks_mul_i_tmp_bytes(&self) -> usize {
18        BE::ckks_mul_i_tmp_bytes(self)
19    }
20
21    fn ckks_mul_i_into<Dst, Src>(&self, dst: &mut Dst, src: &Src, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
22    where
23        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
24        Src: GLWEToBackendRef<BE> + CKKSCtBounds,
25    {
26        BE::ckks_mul_i_into(self, dst, src, scratch)
27    }
28
29    fn ckks_mul_i_assign<Dst>(&self, dst: &mut Dst, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
30    where
31        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
32    {
33        BE::ckks_mul_i_assign(self, dst, scratch)
34    }
35
36    fn ckks_div_i_tmp_bytes(&self) -> usize {
37        BE::ckks_div_i_tmp_bytes(self)
38    }
39
40    fn ckks_div_i_into<Dst, Src>(&self, dst: &mut Dst, src: &Src, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
41    where
42        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
43        Src: GLWEToBackendRef<BE> + CKKSCtBounds,
44    {
45        BE::ckks_div_i_into(self, dst, src, scratch)
46    }
47
48    fn ckks_div_i_assign<Dst>(&self, dst: &mut Dst, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
49    where
50        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
51    {
52        BE::ckks_div_i_assign(self, dst, scratch)
53    }
54}