Skip to content

replace polynomial.extract_slice with apply_coefficientwise + rns.extract_slice - #3586

Closed
j2kun wants to merge 1 commit into
google:mainfrom
j2kun:remove-extract-slice
Closed

j2kun wants to merge 1 commit into
google:mainfrom
j2kun:remove-extract-slice

Conversation

@j2kun

@j2kun j2kun commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2921

@j2kun j2kun changed the title [polynomial]: replace extract_slice with apply_coefficientwise + rns.extract_slice replace polynomial.extract_slice with apply_coefficientwise + rns.extract_slice Nov 2, 2026
%y = polynomial.apply_coefficientwise (%xsq : !poly_ty_2) {
^body(%coeff: !rns.rns<!Zq0, !Zq1>, %degree: index):
%reduced = rns.extract_slice %coeff <start = 0, size = 1> : !rns.rns<!Zq0, !Zq1> -> !rns.rns<!Zq0>
%reduced = rns.convert_basis %coeff <{targetBasis = !rns.rns<!Zq0>}> : !rns.rns<!Zq0, !Zq1> -> !rns.rns<!Zq0>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this PR makes polynomial extract_slice no longer require coefficient form, we needed a new op here that does require coefficient form to preserve the tested functionality.

@j2kun

j2kun commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Actually, I'm going to close this because polynomial.extract_slice is strictly more general than apply_coefficientwise + rns.extract_slice: apply_coefficientwise should force a coefficient form, but then that prevents one from slicing RNS limbs in eval form. This PR hacks around that my allowing apply_coefficientwise to work on eval form if and only if the body is an rns.extract_slice. But this is just sloppy.

@j2kun j2kun closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RNS::ExtractSliceOp is unused

1 participant