Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions p-isa_tools/kerngen/pisa_generators/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from high_parser import KernelContext, Immediate, HighOp, Polys

from .basic import (
Copy,
Add,
Sub,
Muli,
Expand Down Expand Up @@ -53,6 +54,12 @@ def to_pisa(self) -> list[PIsaOp]:
self.input0, self.context.current_rns
)

# For CKKS and standalone mod switch down, we can reduce the RNS by one and copy to output, no need to rescale
if self.context.scheme == "CKKS" and self.var_suffix == self.MOD_QLAST:
return mixed_to_pisa_ops(
[Copy(self.context, self.output, input_remaining_rns)]
)

# Temp.
temp_input_last_rns = duplicate_polys(input_last_rns, "y")
temp_input_remaining_rns = duplicate_polys(input_remaining_rns, "x")
Expand Down