Skip to content

ModArith: Support RNS type in ops #1744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

znssong
Copy link
Contributor

@znssong znssong commented Apr 21, 2025

Support RNS type in ModArith operations. We start from supporting mod_arith.add operation.

@@ -9,6 +10,7 @@ include "mlir/IR/OpBase.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

def ModArithOrRNSLike: TypeOrValueSemanticsContainer<AnyTypeOf<[ModArith_ModArithType, RNS]>, "mod_arith_or_rns-like">;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works well with the verifier, but in the future it might be useful to add a type constraint to allow you to express RNS types for which all inner types match a given constraint. Then you could do something like RnsOf<ModArith_ModArithType>

@ZenithalHourlyRate
Copy link
Collaborator

Just a comment for future PR:

verifyModArithType could be type verifier by using let genVerifyDecl = 1; in ModArithType.td, instead of being called by each op verifier. By then we may get rid of all these modarith/rns verifier for ops and all these op type constraints are maintained in tablegen.

This is kind of legacy code when the ModArithType was introduced (a8eb769), and the verifyModArithType was verifyModArithOpMod, and it was not migrated.

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.

3 participants