mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Add glwe_normalize_tmp_bytes & update assertion error
This commit is contained in:
@@ -2,8 +2,8 @@ use poulpy_hal::{
|
|||||||
api::{
|
api::{
|
||||||
BivariateTensoring, ModuleN, ScratchTakeBasic, VecZnxAdd, VecZnxAddInplace, VecZnxBigNormalize, VecZnxCopy,
|
BivariateTensoring, ModuleN, ScratchTakeBasic, VecZnxAdd, VecZnxAddInplace, VecZnxBigNormalize, VecZnxCopy,
|
||||||
VecZnxIdftApplyConsume, VecZnxMulXpMinusOne, VecZnxMulXpMinusOneInplace, VecZnxNegate, VecZnxNormalize,
|
VecZnxIdftApplyConsume, VecZnxMulXpMinusOne, VecZnxMulXpMinusOneInplace, VecZnxNegate, VecZnxNormalize,
|
||||||
VecZnxNormalizeInplace, VecZnxRotate, VecZnxRotateInplace, VecZnxRshInplace, VecZnxSub, VecZnxSubInplace,
|
VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxRotate, VecZnxRotateInplace, VecZnxRshInplace, VecZnxSub,
|
||||||
VecZnxSubNegateInplace, VecZnxZero,
|
VecZnxSubInplace, VecZnxSubNegateInplace, VecZnxZero,
|
||||||
},
|
},
|
||||||
layouts::{Backend, Module, Scratch, VecZnx, VecZnxBig, ZnxInfos},
|
layouts::{Backend, Module, Scratch, VecZnx, VecZnxBig, ZnxInfos},
|
||||||
reference::vec_znx::vec_znx_rotate_inplace_tmp_bytes,
|
reference::vec_znx::vec_znx_rotate_inplace_tmp_bytes,
|
||||||
@@ -389,12 +389,19 @@ impl GLWE<Vec<u8>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BE: Backend> GLWENormalize<BE> for Module<BE> where Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> {}
|
impl<BE: Backend> GLWENormalize<BE> for Module<BE> where
|
||||||
|
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> + VecZnxNormalizeTmpBytes
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
pub trait GLWENormalize<BE: Backend>
|
pub trait GLWENormalize<BE: Backend>
|
||||||
where
|
where
|
||||||
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE>,
|
Self: ModuleN + VecZnxNormalize<BE> + VecZnxNormalizeInplace<BE> + VecZnxNormalizeTmpBytes,
|
||||||
{
|
{
|
||||||
|
fn glwe_normalize_tmp_bytes(&self) -> usize {
|
||||||
|
self.vec_znx_normalize_tmp_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
fn glwe_normalize<R, A>(&self, res: &mut R, a: &A, scratch: &mut Scratch<BE>)
|
fn glwe_normalize<R, A>(&self, res: &mut R, a: &A, scratch: &mut Scratch<BE>)
|
||||||
where
|
where
|
||||||
R: GLWEToMut,
|
R: GLWEToMut,
|
||||||
|
|||||||
@@ -331,7 +331,11 @@ where
|
|||||||
|
|
||||||
let scratch_thread_size = self.fhe_uint_prepare_tmp_bytes(cbt.block_size(), 1, res, bits, key);
|
let scratch_thread_size = self.fhe_uint_prepare_tmp_bytes(cbt.block_size(), 1, res, bits, key);
|
||||||
|
|
||||||
assert!(scratch.available() >= threads * scratch_thread_size);
|
assert!(
|
||||||
|
scratch.available() >= threads * scratch_thread_size,
|
||||||
|
"scratch.available():{} < threads:{threads} * scratch_thread_size:{scratch_thread_size}",
|
||||||
|
scratch.available()
|
||||||
|
);
|
||||||
|
|
||||||
let chunk_size: usize = bit_count.div_ceil(threads);
|
let chunk_size: usize = bit_count.div_ceil(threads);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user