Skip to content

Commit 6415169

Browse files
Bug fix for standalone mod switch down for CKKS
* Bug fix for standalone mod switch for CKKS. Previous version of the code rescales after reducing the RNS, which is not required. Requires refactoring in the future. --------- Co-authored-by: Jose Rojas Chaves <jose.rojas.chaves@intel.com>
1 parent f75b1ba commit 6415169

File tree

1 file changed

+7
-0
lines changed
  • p-isa_tools/kerngen/pisa_generators

1 file changed

+7
-0
lines changed

p-isa_tools/kerngen/pisa_generators/mod.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from high_parser import KernelContext, Immediate, HighOp, Polys
1010

1111
from .basic import (
12+
Copy,
1213
Add,
1314
Sub,
1415
Muli,
@@ -53,6 +54,12 @@ def to_pisa(self) -> list[PIsaOp]:
5354
self.input0, self.context.current_rns
5455
)
5556

57+
# For CKKS and standalone mod switch down, we can reduce the RNS by one and copy to output, no need to rescale
58+
if self.context.scheme == "CKKS" and self.var_suffix == self.MOD_QLAST:
59+
return mixed_to_pisa_ops(
60+
[Copy(self.context, self.output, input_remaining_rns)]
61+
)
62+
5663
# Temp.
5764
temp_input_last_rns = duplicate_polys(input_last_rns, "y")
5865
temp_input_remaining_rns = duplicate_polys(input_remaining_rns, "x")

0 commit comments

Comments
 (0)