Added PrepareScratchSpace trait

This commit is contained in:
Jean-Philippe Bossuat
2025-10-09 17:07:53 +02:00
parent 8eafcaff1f
commit 2884935a38
11 changed files with 114 additions and 16 deletions

View File

@@ -1,12 +1,12 @@
use poulpy_hal::{
api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare},
api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare, VmpPrepareTmpBytes},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat, VmpPMatToRef, ZnxInfos},
oep::VmpPMatAllocBytesImpl,
};
use crate::layouts::{
Base2K, BuildError, Degree, Dnum, Dsize, GGSWCiphertext, GGSWInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision,
prepared::{Prepare, PrepareAlloc},
prepared::{Prepare, PrepareAlloc, PrepareScratchSpace},
};
#[derive(PartialEq, Eq)]
@@ -258,6 +258,20 @@ impl<D: DataRef, B: Backend> GGSWCiphertextPrepared<D, B> {
}
}
impl<DR: DataRef, B: Backend, A: GGSWInfos> PrepareScratchSpace<B, A> for GGSWCiphertextPrepared<DR, B>
where
Module<B>: VmpPrepareTmpBytes,
{
fn prepare_scratch_space(&self, module: &Module<B>, infos: &A) -> usize {
module.vmp_prepare_tmp_bytes(
infos.dnum().into(),
(infos.rank() + 1).into(),
(infos.rank() + 1).into(),
infos.size(),
)
}
}
impl<D: DataMut, DR: DataRef, B: Backend> Prepare<B, GGSWCiphertext<DR>> for GGSWCiphertextPrepared<D, B>
where
Module<B>: VmpPrepare<B>,