From 7f31cec9907d7b9c81ea259231d7f00865468480 Mon Sep 17 00:00:00 2001 From: youben11 Date: Mon, 18 Jul 2022 11:28:59 +0100 Subject: [PATCH] refactor: prefix ops and types with dialect name --- .../Conversion/FHEToTFHE/Patterns.td | 12 +- .../Conversion/TFHEToConcrete/Patterns.td | 12 +- .../Dialect/BConcrete/IR/BConcreteOps.td | 14 +-- .../Dialect/Concrete/IR/ConcreteOps.td | 58 +++++----- .../Dialect/Concrete/IR/ConcreteTypes.td | 10 +- .../concretelang/Dialect/FHE/IR/FHEOps.td | 56 +++++----- .../concretelang/Dialect/FHE/IR/FHETypes.td | 2 +- .../Dialect/FHELinalg/IR/FHELinalgOps.td | 104 +++++++++--------- .../concretelang/Dialect/RT/IR/RTOps.td | 22 ++-- .../concretelang/Dialect/TFHE/IR/TFHEOps.td | 56 +++++----- .../concretelang/Dialect/TFHE/IR/TFHETypes.td | 2 +- 11 files changed, 174 insertions(+), 174 deletions(-) diff --git a/compiler/include/concretelang/Conversion/FHEToTFHE/Patterns.td b/compiler/include/concretelang/Conversion/FHEToTFHE/Patterns.td index d52eed426..8dcb8666c 100644 --- a/compiler/include/concretelang/Conversion/FHEToTFHE/Patterns.td +++ b/compiler/include/concretelang/Conversion/FHEToTFHE/Patterns.td @@ -9,37 +9,37 @@ include "concretelang/Dialect/TFHE/IR/TFHEOps.td" def createZeroGLWEOp : NativeCodeCall<"mlir::concretelang::createZeroGLWEOpFromFHE($_builder, $_loc, $0)">; def ZeroEintPattern : Pat< - (ZeroEintOp:$result), + (FHE_ZeroEintOp:$result), (createZeroGLWEOp $result)>; def createAddGLWEIntOp : NativeCodeCall<"mlir::concretelang::createGLWEOpFromFHE($_builder, $_loc, $0, $1, $2)">; def AddEintIntPattern : Pat< - (AddEintIntOp:$result $arg0, $arg1), + (FHE_AddEintIntOp:$result $arg0, $arg1), (createAddGLWEIntOp $arg0, $arg1, $result)>; def createAddGLWEOp : NativeCodeCall<"mlir::concretelang::createGLWEOpFromFHE($_builder, $_loc, $0, $1, $2)">; def AddEintPattern : Pat< - (AddEintOp:$result $arg0, $arg1), + (FHE_AddEintOp:$result $arg0, $arg1), (createAddGLWEOp $arg0, $arg1, $result)>; def createSubGLWEIntOp : NativeCodeCall<"mlir::concretelang::createGLWEOpFromFHE($_builder, $_loc, $0, $1, $2)">; def SubIntEintPattern : Pat< - (SubIntEintOp:$result $arg0, $arg1), + (FHE_SubIntEintOp:$result $arg0, $arg1), (createSubGLWEIntOp $arg0, $arg1, $result)>; def createNegGLWEOp : NativeCodeCall<"mlir::concretelang::createGLWEOpFromFHE($_builder, $_loc, $0, $1)">; def NegEintPattern : Pat< - (NegEintOp:$result $arg0), + (FHE_NegEintOp:$result $arg0), (createNegGLWEOp $arg0, $result)>; def createMulGLWEIntOp : NativeCodeCall<"mlir::concretelang::createGLWEOpFromFHE($_builder, $_loc, $0, $1, $2)">; def MulEintIntPattern : Pat< - (MulEintIntOp:$result $arg0, $arg1), + (FHE_MulEintIntOp:$result $arg0, $arg1), (createMulGLWEIntOp $arg0, $arg1, $result)>; #endif diff --git a/compiler/include/concretelang/Conversion/TFHEToConcrete/Patterns.td b/compiler/include/concretelang/Conversion/TFHEToConcrete/Patterns.td index 80778ebe3..e68c0feee 100644 --- a/compiler/include/concretelang/Conversion/TFHEToConcrete/Patterns.td +++ b/compiler/include/concretelang/Conversion/TFHEToConcrete/Patterns.td @@ -9,37 +9,37 @@ include "concretelang/Dialect/TFHE/IR/TFHEOps.td" def createZeroLWEOp : NativeCodeCall<"mlir::concretelang::createZeroLWEOpFromTFHE($_builder, $_loc, $0)">; def ZeroGLWEPattern : Pat< - (ZeroGLWEOp:$result), + (TFHE_ZeroGLWEOp:$result), (createZeroLWEOp $result)>; def createAddLWEOp : NativeCodeCall<"mlir::concretelang::createConcreteOpFromTFHE($_builder, $_loc, $0, $1, $2)">; def AddGLWEPattern : Pat< - (AddGLWEOp:$result $arg0, $arg1), + (TFHE_AddGLWEOp:$result $arg0, $arg1), (createAddLWEOp $arg0, $arg1, $result)>; def createAddPlainLweOp : NativeCodeCall<"mlir::concretelang::createAddPlainLweCiphertext($_builder, $_loc, $0, $1, $2)">; def AddGLWEIntPattern : Pat< - (AddGLWEIntOp:$result $arg0, $arg1), + (TFHE_AddGLWEIntOp:$result $arg0, $arg1), (createAddPlainLweOp $arg0, $arg1, $result)>; def createMulClearLweOp : NativeCodeCall<"mlir::concretelang::createMulClearLweCiphertext($_builder, $_loc, $0, $1, $2)">; def MulGLWEIntPattern : Pat< - (MulGLWEIntOp:$result $arg0, $arg1), + (TFHE_MulGLWEIntOp:$result $arg0, $arg1), (createMulClearLweOp $arg0, $arg1, $result)>; def createSubIntLweOp : NativeCodeCall<"mlir::concretelang::createSubIntLweCiphertext($_builder, $_loc, $0, $1, $2)">; def SubGLWEIntPattern : Pat< - (SubGLWEIntOp:$result $arg0, $arg1), + (TFHE_SubGLWEIntOp:$result $arg0, $arg1), (createSubIntLweOp $arg0, $arg1, $result)>; def createNegLweOp : NativeCodeCall<"mlir::concretelang::createNegLweCiphertext($_builder, $_loc, $0, $1)">; def NegGLWEPattern : Pat< - (NegGLWEOp:$result $arg0), + (TFHE_NegGLWEOp:$result $arg0), (createNegLweOp $arg0, $result)>; #endif diff --git a/compiler/include/concretelang/Dialect/BConcrete/IR/BConcreteOps.td b/compiler/include/concretelang/Dialect/BConcrete/IR/BConcreteOps.td index 33ace5125..73fabc8de 100644 --- a/compiler/include/concretelang/Dialect/BConcrete/IR/BConcreteOps.td +++ b/compiler/include/concretelang/Dialect/BConcrete/IR/BConcreteOps.td @@ -12,7 +12,7 @@ include "concretelang/Dialect/Concrete/IR/ConcreteTypes.td" class BConcrete_Op traits = []> : Op; -def AddLweBuffersOp : BConcrete_Op<"add_lwe_buffer"> { +def BConcrete_AddLweBuffersOp : BConcrete_Op<"add_lwe_buffer"> { let arguments = (ins 1DTensorOf<[I64]>:$lhs, 1DTensorOf<[I64]>:$rhs @@ -20,22 +20,22 @@ def AddLweBuffersOp : BConcrete_Op<"add_lwe_buffer"> { let results = (outs 1DTensorOf<[I64]>:$result); } -def AddPlaintextLweBufferOp : BConcrete_Op<"add_plaintext_lwe_buffer"> { +def BConcrete_AddPlaintextLweBufferOp : BConcrete_Op<"add_plaintext_lwe_buffer"> { let arguments = (ins 1DTensorOf<[I64]>:$lhs, I64:$rhs); let results = (outs 1DTensorOf<[I64]>:$result); } -def MulCleartextLweBufferOp : BConcrete_Op<"mul_cleartext_lwe_buffer"> { +def BConcrete_MulCleartextLweBufferOp : BConcrete_Op<"mul_cleartext_lwe_buffer"> { let arguments = (ins 1DTensorOf<[I64]>:$lhs, I64:$rhs); let results = (outs 1DTensorOf<[I64]>:$result); } -def NegateLweBufferOp : BConcrete_Op<"negate_lwe_buffer"> { +def BConcrete_NegateLweBufferOp : BConcrete_Op<"negate_lwe_buffer"> { let arguments = (ins 1DTensorOf<[I64]>:$ciphertext); let results = (outs 1DTensorOf<[I64]>:$result); } -def FillGlweFromTable : BConcrete_Op<"fill_glwe_from_table"> { +def BConcrete_FillGlweFromTable : BConcrete_Op<"fill_glwe_from_table"> { let arguments = (ins 1DTensorOf<[I64]>:$glwe, I32Attr:$glweDimension, @@ -46,7 +46,7 @@ def FillGlweFromTable : BConcrete_Op<"fill_glwe_from_table"> { let results = (outs); } -def KeySwitchLweBufferOp : BConcrete_Op<"keyswitch_lwe_buffer"> { +def BConcrete_KeySwitchLweBufferOp : BConcrete_Op<"keyswitch_lwe_buffer"> { let arguments = (ins // LweKeySwitchKeyType:$keyswitch_key, 1DTensorOf<[I64]>:$ciphertext, @@ -56,7 +56,7 @@ def KeySwitchLweBufferOp : BConcrete_Op<"keyswitch_lwe_buffer"> { let results = (outs 1DTensorOf<[I64]>:$result); } -def BootstrapLweBufferOp : BConcrete_Op<"bootstrap_lwe_buffer"> { +def BConcrete_BootstrapLweBufferOp : BConcrete_Op<"bootstrap_lwe_buffer"> { let arguments = (ins // LweBootstrapKeyType:$bootstrap_key, 1DTensorOf<[I64]>:$input_ciphertext, diff --git a/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteOps.td b/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteOps.td index 9a1d483e6..13dcb73c7 100644 --- a/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteOps.td +++ b/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteOps.td @@ -10,90 +10,90 @@ include "concretelang/Dialect/Concrete/IR/ConcreteTypes.td" class Concrete_Op traits = []> : Op; -def ZeroLWEOp : Concrete_Op<"zero"> { +def Concrete_ZeroLWEOp : Concrete_Op<"zero"> { let summary = "Returns a trivial encyption of 0"; let arguments = (ins); - let results = (outs LweCiphertextType:$out); + let results = (outs Concrete_LweCiphertextType:$out); } -def ZeroTensorLWEOp : Concrete_Op<"zero_tensor"> { +def Concrete_ZeroTensorLWEOp : Concrete_Op<"zero_tensor"> { let summary = "Returns a trivial encyption of 0"; let arguments = (ins); - let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); + let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); } -def AddLweCiphertextsOp : Concrete_Op<"add_lwe_ciphertexts"> { +def Concrete_AddLweCiphertextsOp : Concrete_Op<"add_lwe_ciphertexts"> { let summary = "Returns the sum of 2 lwe ciphertexts"; - let arguments = (ins LweCiphertextType:$lhs, LweCiphertextType:$rhs); - let results = (outs LweCiphertextType:$result); + let arguments = (ins Concrete_LweCiphertextType:$lhs, Concrete_LweCiphertextType:$rhs); + let results = (outs Concrete_LweCiphertextType:$result); } -def AddPlaintextLweCiphertextOp : Concrete_Op<"add_plaintext_lwe_ciphertext"> { +def Concrete_AddPlaintextLweCiphertextOp : Concrete_Op<"add_plaintext_lwe_ciphertext"> { let summary = "Returns the sum of a clear integer and a lwe ciphertext"; - let arguments = (ins LweCiphertextType:$lhs, PlaintextType:$rhs); - let results = (outs LweCiphertextType:$result); + let arguments = (ins Concrete_LweCiphertextType:$lhs, Concrete_PlaintextType:$rhs); + let results = (outs Concrete_LweCiphertextType:$result); } -def MulCleartextLweCiphertextOp : Concrete_Op<"mul_cleartext_lwe_ciphertext"> { +def Concrete_MulCleartextLweCiphertextOp : Concrete_Op<"mul_cleartext_lwe_ciphertext"> { let summary = "Returns the product of a clear integer and a lwe ciphertext"; - let arguments = (ins LweCiphertextType:$lhs, CleartextType:$rhs); - let results = (outs LweCiphertextType:$result); + let arguments = (ins Concrete_LweCiphertextType:$lhs, Concrete_CleartextType:$rhs); + let results = (outs Concrete_LweCiphertextType:$result); } -def NegateLweCiphertextOp : Concrete_Op<"negate_lwe_ciphertext"> { +def Concrete_NegateLweCiphertextOp : Concrete_Op<"negate_lwe_ciphertext"> { let summary = "Negates a lwe ciphertext"; - let arguments = (ins LweCiphertextType:$ciphertext); - let results = (outs LweCiphertextType:$result); + let arguments = (ins Concrete_LweCiphertextType:$ciphertext); + let results = (outs Concrete_LweCiphertextType:$result); } -def GlweFromTable : Concrete_Op<"glwe_from_table"> { +def Concrete_GlweFromTable : Concrete_Op<"glwe_from_table"> { let summary = "Creates a GLWE ciphertext which is the trivial encrytion of a the input table interpreted as a polynomial (to use later in a bootstrap)"; let arguments = (ins 1DTensorOf<[I64]>:$table); - let results = (outs GlweCiphertextType:$result); + let results = (outs Concrete_GlweCiphertextType:$result); } -def BootstrapLweOp : Concrete_Op<"bootstrap_lwe"> { +def Concrete_BootstrapLweOp : Concrete_Op<"bootstrap_lwe"> { let summary = "Bootstraps a LWE ciphertext with a GLWE trivial encryption of the lookup table"; let arguments = (ins - LweCiphertextType:$input_ciphertext, - GlweCiphertextType:$accumulator, + Concrete_LweCiphertextType:$input_ciphertext, + Concrete_GlweCiphertextType:$accumulator, I32Attr:$level, I32Attr:$baseLog ); - let results = (outs LweCiphertextType:$result); + let results = (outs Concrete_LweCiphertextType:$result); } -def KeySwitchLweOp : Concrete_Op<"keyswitch_lwe"> { +def Concrete_KeySwitchLweOp : Concrete_Op<"keyswitch_lwe"> { let summary = "Keyswitches a LWE ciphertext"; let arguments = (ins - LweCiphertextType:$ciphertext, + Concrete_LweCiphertextType:$ciphertext, I32Attr:$level, I32Attr:$baseLog ); - let results = (outs LweCiphertextType:$result); + let results = (outs Concrete_LweCiphertextType:$result); } -def EncodeIntOp : Concrete_Op<"encode_int"> { +def Concrete_EncodeIntOp : Concrete_Op<"encode_int"> { let summary = "Encodes an integer (for it to later be added to a LWE ciphertext)"; let arguments = (ins AnyInteger:$i); - let results = (outs PlaintextType:$plaintext); + let results = (outs Concrete_PlaintextType:$plaintext); } -def IntToCleartextOp : Concrete_Op<"int_to_cleartext", [NoSideEffect]> { +def Concrete_IntToCleartextOp : Concrete_Op<"int_to_cleartext", [NoSideEffect]> { let summary = "Keyswitches a LWE ciphertext"; let arguments = (ins AnyInteger:$i); - let results = (outs CleartextType:$cleartext); + let results = (outs Concrete_CleartextType:$cleartext); } #endif diff --git a/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteTypes.td b/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteTypes.td index b5930c30b..7f052f906 100644 --- a/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteTypes.td +++ b/compiler/include/concretelang/Dialect/Concrete/IR/ConcreteTypes.td @@ -7,7 +7,7 @@ include "concretelang/Dialect/Concrete/IR/ConcreteDialect.td" class Concrete_Type traits = []> : TypeDef { } -def GlweCiphertextType : Concrete_Type<"GlweCiphertext"> { +def Concrete_GlweCiphertextType : Concrete_Type<"GlweCiphertext"> { let mnemonic = "glwe_ciphertext"; let summary = "A GLWE ciphertext (encryption of a polynomial of fixed-precision integers)"; @@ -26,7 +26,7 @@ def GlweCiphertextType : Concrete_Type<"GlweCiphertext"> { ); } -def LweCiphertextType : Concrete_Type<"LweCiphertext", [MemRefElementTypeInterface]> { +def Concrete_LweCiphertextType : Concrete_Type<"LweCiphertext", [MemRefElementTypeInterface]> { let mnemonic = "lwe_ciphertext"; let summary = "A LWE ciphertext (encryption of a fixed-precision integer)"; @@ -46,7 +46,7 @@ def LweCiphertextType : Concrete_Type<"LweCiphertext", [MemRefElementTypeInterfa let hasCustomAssemblyFormat = 1; } -def CleartextType : Concrete_Type<"Cleartext"> { +def Concrete_CleartextType : Concrete_Type<"Cleartext"> { let mnemonic = "cleartext"; let summary = "A cleartext (a fixed-precision integer) ready to be multiplied to a LWE ciphertext"; @@ -63,7 +63,7 @@ def CleartextType : Concrete_Type<"Cleartext"> { let hasCustomAssemblyFormat = 1; } -def PlaintextType : Concrete_Type<"Plaintext"> { +def Concrete_PlaintextType : Concrete_Type<"Plaintext"> { let mnemonic = "plaintext"; let summary = "A Plaintext (a fixed-precision integer) ready to be added to a LWE ciphertext"; @@ -80,7 +80,7 @@ def PlaintextType : Concrete_Type<"Plaintext"> { let hasCustomAssemblyFormat = 1; } -def Context : Concrete_Type<"Context"> { +def Concrete_Context : Concrete_Type<"Context"> { let mnemonic = "context"; let summary = "A runtime context"; diff --git a/compiler/include/concretelang/Dialect/FHE/IR/FHEOps.td b/compiler/include/concretelang/Dialect/FHE/IR/FHEOps.td index 244b2f523..167bc5a67 100644 --- a/compiler/include/concretelang/Dialect/FHE/IR/FHEOps.td +++ b/compiler/include/concretelang/Dialect/FHE/IR/FHEOps.td @@ -18,7 +18,7 @@ include "concretelang/Dialect/FHE/IR/FHETypes.td" class FHE_Op traits = []> : Op; -def ZeroEintOp : FHE_Op<"zero", [NoSideEffect]> { +def FHE_ZeroEintOp : FHE_Op<"zero", [NoSideEffect]> { let summary = "Returns a trivial encrypted integer of 0"; let description = [{ @@ -31,11 +31,11 @@ def ZeroEintOp : FHE_Op<"zero", [NoSideEffect]> { }]; let arguments = (ins); - let results = (outs EncryptedIntegerType:$out); + let results = (outs FHE_EncryptedIntegerType:$out); } -def ZeroTensorOp : FHE_Op<"zero_tensor", []> { +def FHE_ZeroTensorOp : FHE_Op<"zero_tensor", []> { let summary = "Creates a new tensor with all elements initialized to an encrypted zero."; let description = [{ @@ -49,10 +49,10 @@ def ZeroTensorOp : FHE_Op<"zero_tensor", []> { let arguments = (ins); - let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); + let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); } -def AddEintIntOp : FHE_Op<"add_eint_int"> { +def FHE_AddEintIntOp : FHE_Op<"add_eint_int"> { let summary = "Adds an encrypted integer and a clear integer"; @@ -72,8 +72,8 @@ def AddEintIntOp : FHE_Op<"add_eint_int"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, AnyInteger:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a, AnyInteger:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -85,7 +85,7 @@ def AddEintIntOp : FHE_Op<"add_eint_int"> { let hasFolder = 1; } -def AddEintOp : FHE_Op<"add_eint"> { +def FHE_AddEintOp : FHE_Op<"add_eint"> { let summary = "Adds two encrypted integers"; @@ -104,8 +104,8 @@ def AddEintOp : FHE_Op<"add_eint"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, EncryptedIntegerType:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a, FHE_EncryptedIntegerType:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -116,7 +116,7 @@ def AddEintOp : FHE_Op<"add_eint"> { let hasVerifier = 1; } -def SubIntEintOp : FHE_Op<"sub_int_eint"> { +def FHE_SubIntEintOp : FHE_Op<"sub_int_eint"> { let summary = "Substract a clear integer and an encrypted integer"; @@ -136,8 +136,8 @@ def SubIntEintOp : FHE_Op<"sub_int_eint"> { ``` }]; - let arguments = (ins AnyInteger:$a, EncryptedIntegerType:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins AnyInteger:$a, FHE_EncryptedIntegerType:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -148,7 +148,7 @@ def SubIntEintOp : FHE_Op<"sub_int_eint"> { let hasVerifier = 1; } -def SubEintIntOp : FHE_Op<"sub_eint_int"> { +def FHE_SubEintIntOp : FHE_Op<"sub_eint_int"> { let summary = "Substract a clear integer from an encrypted integer"; @@ -168,8 +168,8 @@ def SubEintIntOp : FHE_Op<"sub_eint_int"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, AnyInteger:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a, AnyInteger:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -182,7 +182,7 @@ def SubEintIntOp : FHE_Op<"sub_eint_int"> { let hasFolder = 1; } -def SubEintOp : FHE_Op<"sub_eint"> { +def FHE_SubEintOp : FHE_Op<"sub_eint"> { let summary = "Subtracts two encrypted integers"; @@ -201,8 +201,8 @@ def SubEintOp : FHE_Op<"sub_eint"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, EncryptedIntegerType:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a, FHE_EncryptedIntegerType:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -213,7 +213,7 @@ def SubEintOp : FHE_Op<"sub_eint"> { let hasVerifier = 1; } -def NegEintOp : FHE_Op<"neg_eint"> { +def FHE_NegEintOp : FHE_Op<"neg_eint"> { let summary = "Negates an encrypted integer"; @@ -231,8 +231,8 @@ def NegEintOp : FHE_Op<"neg_eint"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a), [{ @@ -242,7 +242,7 @@ def NegEintOp : FHE_Op<"neg_eint"> { let hasVerifier = 1; } -def MulEintIntOp : FHE_Op<"mul_eint_int"> { +def FHE_MulEintIntOp : FHE_Op<"mul_eint_int"> { let summary = "Mulitplies an encrypted integer and a clear integer"; @@ -262,8 +262,8 @@ def MulEintIntOp : FHE_Op<"mul_eint_int"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, AnyInteger:$b); - let results = (outs EncryptedIntegerType); + let arguments = (ins FHE_EncryptedIntegerType:$a, AnyInteger:$b); + let results = (outs FHE_EncryptedIntegerType); let builders = [ OpBuilder<(ins "Value":$a, "Value":$b), [{ @@ -275,7 +275,7 @@ def MulEintIntOp : FHE_Op<"mul_eint_int"> { let hasFolder = 1; } -def ApplyLookupTableEintOp : FHE_Op<"apply_lookup_table"> { +def FHE_ApplyLookupTableEintOp : FHE_Op<"apply_lookup_table"> { let summary = "Applies a clear lookup table to an encrypted integer"; @@ -295,9 +295,9 @@ def ApplyLookupTableEintOp : FHE_Op<"apply_lookup_table"> { ``` }]; - let arguments = (ins EncryptedIntegerType:$a, + let arguments = (ins FHE_EncryptedIntegerType:$a, TensorOf<[AnyInteger]>:$lut); - let results = (outs EncryptedIntegerType); + let results = (outs FHE_EncryptedIntegerType); let hasVerifier = 1; } diff --git a/compiler/include/concretelang/Dialect/FHE/IR/FHETypes.td b/compiler/include/concretelang/Dialect/FHE/IR/FHETypes.td index c2c3c6c4e..2fa4d6993 100644 --- a/compiler/include/concretelang/Dialect/FHE/IR/FHETypes.td +++ b/compiler/include/concretelang/Dialect/FHE/IR/FHETypes.td @@ -7,7 +7,7 @@ include "mlir/IR/BuiltinTypes.td" class FHE_Type traits = []> : TypeDef { } -def EncryptedIntegerType : FHE_Type<"EncryptedInteger", +def FHE_EncryptedIntegerType : FHE_Type<"EncryptedInteger", [MemRefElementTypeInterface]> { let mnemonic = "eint"; diff --git a/compiler/include/concretelang/Dialect/FHELinalg/IR/FHELinalgOps.td b/compiler/include/concretelang/Dialect/FHELinalg/IR/FHELinalgOps.td index 8c64c080c..04875e46a 100644 --- a/compiler/include/concretelang/Dialect/FHELinalg/IR/FHELinalgOps.td +++ b/compiler/include/concretelang/Dialect/FHELinalg/IR/FHELinalgOps.td @@ -21,7 +21,7 @@ def TensorBinaryEint : NativeOpTrait<"TensorBinaryEint">; def TensorUnaryEint : NativeOpTrait<"TensorUnaryEint">; -def AddEintIntOp : FHELinalg_Op<"add_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { +def FHELinalg_AddEintIntOp : FHELinalg_Op<"add_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { let summary = "Returns a tensor that contains the addition of a tensor of encrypted integers and a tensor of clear integers."; let description = [{ @@ -61,11 +61,11 @@ def AddEintIntOp : FHELinalg_Op<"add_eint_int", [TensorBroadcastingRules, Tensor }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$lhs, Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$rhs, "Value":$lhs), [{ @@ -76,7 +76,7 @@ def AddEintIntOp : FHELinalg_Op<"add_eint_int", [TensorBroadcastingRules, Tensor let hasFolder = 1; } -def AddEintOp : FHELinalg_Op<"add_eint", [TensorBroadcastingRules, TensorBinaryEint]> { +def FHELinalg_AddEintOp : FHELinalg_Op<"add_eint", [TensorBroadcastingRules, TensorBinaryEint]> { let summary = "Returns a tensor that contains the addition of two tensor of encrypted integers."; let description = [{ @@ -115,11 +115,11 @@ def AddEintOp : FHELinalg_Op<"add_eint", [TensorBroadcastingRules, TensorBinaryE }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, - Type.predicate, HasStaticShapePred]>>:$rhs + Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$rhs, "Value":$lhs), [{ @@ -128,7 +128,7 @@ def AddEintOp : FHELinalg_Op<"add_eint", [TensorBroadcastingRules, TensorBinaryE ]; } -def SubIntEintOp : FHELinalg_Op<"sub_int_eint", [TensorBroadcastingRules, TensorBinaryIntEint]> { +def FHELinalg_SubIntEintOp : FHELinalg_Op<"sub_int_eint", [TensorBroadcastingRules, TensorBinaryIntEint]> { let summary = "Returns a tensor that contains the substraction of a tensor of clear integers and a tensor of encrypted integers."; let description = [{ @@ -169,10 +169,10 @@ def SubIntEintOp : FHELinalg_Op<"sub_int_eint", [TensorBroadcastingRules, Tensor let arguments = (ins Type.predicate, HasStaticShapePred]>>:$lhs, - Type.predicate, HasStaticShapePred]>>:$rhs + Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$rhs, "Value":$lhs), [{ @@ -181,7 +181,7 @@ def SubIntEintOp : FHELinalg_Op<"sub_int_eint", [TensorBroadcastingRules, Tensor ]; } -def SubEintIntOp : FHELinalg_Op<"sub_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { +def FHELinalg_SubEintIntOp : FHELinalg_Op<"sub_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { let summary = "Returns a tensor that contains the substraction of a tensor of clear integers from a tensor of encrypted integers."; let description = [{ @@ -221,11 +221,11 @@ def SubEintIntOp : FHELinalg_Op<"sub_eint_int", [TensorBroadcastingRules, Tensor }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$lhs, Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$lhs, "Value":$rhs), [{ @@ -237,7 +237,7 @@ def SubEintIntOp : FHELinalg_Op<"sub_eint_int", [TensorBroadcastingRules, Tensor let hasFolder = 1; } -def SubEintOp : FHELinalg_Op<"sub_eint", [TensorBroadcastingRules, TensorBinaryEint]> { +def FHELinalg_SubEintOp : FHELinalg_Op<"sub_eint", [TensorBroadcastingRules, TensorBinaryEint]> { let summary = "Returns a tensor that contains the subtraction of two tensor of encrypted integers."; let description = [{ @@ -276,11 +276,11 @@ def SubEintOp : FHELinalg_Op<"sub_eint", [TensorBroadcastingRules, TensorBinaryE }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, - Type.predicate, HasStaticShapePred]>>:$rhs + Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$lhs, "Value":$rhs), [{ @@ -289,7 +289,7 @@ def SubEintOp : FHELinalg_Op<"sub_eint", [TensorBroadcastingRules, TensorBinaryE ]; } -def NegEintOp : FHELinalg_Op<"neg_eint", [TensorUnaryEint]> { +def FHELinalg_NegEintOp : FHELinalg_Op<"neg_eint", [TensorUnaryEint]> { let summary = "Returns a tensor that contains the negation of a tensor of encrypted integers."; let description = [{ @@ -309,10 +309,10 @@ def NegEintOp : FHELinalg_Op<"neg_eint", [TensorUnaryEint]> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$tensor + Type.predicate, HasStaticShapePred]>>:$tensor ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let builders = [ OpBuilder<(ins "Value":$tensor), [{ @@ -321,7 +321,7 @@ def NegEintOp : FHELinalg_Op<"neg_eint", [TensorUnaryEint]> { ]; } -def MulEintIntOp : FHELinalg_Op<"mul_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { +def FHELinalg_MulEintIntOp : FHELinalg_Op<"mul_eint_int", [TensorBroadcastingRules, TensorBinaryEintInt]> { let summary = "Returns a tensor that contains the multiplication of a tensor of encrypted integers and a tensor of clear integers."; let description = [{ @@ -361,16 +361,16 @@ def MulEintIntOp : FHELinalg_Op<"mul_eint_int", [TensorBroadcastingRules, Tensor }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$lhs, Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasFolder = 1; } -def ApplyLookupTableEintOp : FHELinalg_Op<"apply_lookup_table", []> { +def FHELinalg_ApplyLookupTableEintOp : FHELinalg_Op<"apply_lookup_table", []> { let summary = "Returns a tensor that contains the result of the lookup on a table."; let description = [{ @@ -397,16 +397,16 @@ def ApplyLookupTableEintOp : FHELinalg_Op<"apply_lookup_table", []> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$t, + Type.predicate, HasStaticShapePred]>>:$t, Type.predicate, HasStaticShapePred]>>:$lut ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } -def ApplyMultiLookupTableEintOp : FHELinalg_Op<"apply_multi_lookup_table", []> { +def FHELinalg_ApplyMultiLookupTableEintOp : FHELinalg_Op<"apply_multi_lookup_table", []> { let summary = "Returns a tensor that contains the result of the lookup on a table, using a different lookup table for each element."; let description = [{ @@ -444,16 +444,16 @@ def ApplyMultiLookupTableEintOp : FHELinalg_Op<"apply_multi_lookup_table", []> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$t, + Type.predicate, HasStaticShapePred]>>:$t, Type.predicate, HasStaticShapePred]>>:$luts ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } -def ApplyMappedLookupTableEintOp : FHELinalg_Op<"apply_mapped_lookup_table", []> { +def FHELinalg_ApplyMappedLookupTableEintOp : FHELinalg_Op<"apply_mapped_lookup_table", []> { let summary = "Returns a tensor that contains the result of the lookup on a table, using a different lookup table for each element, specified by a map."; let description = [{ @@ -497,17 +497,17 @@ def ApplyMappedLookupTableEintOp : FHELinalg_Op<"apply_mapped_lookup_table", []> }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$t, + Type.predicate, HasStaticShapePred]>>:$t, Type.predicate, HasStaticShapePred]>>:$luts, Type.predicate, HasStaticShapePred]>>:$map ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } -def Dot : FHELinalg_Op<"dot_eint_int"> { +def FHELinalg_Dot : FHELinalg_Op<"dot_eint_int"> { let summary = "Returns the encrypted dot product between a vector of encrypted integers and a vector of clean integers."; let description = [{ @@ -522,15 +522,15 @@ def Dot : FHELinalg_Op<"dot_eint_int"> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred, HasAnyRankOfPred<[1]>]>>:$lhs, + Type.predicate, HasStaticShapePred, HasAnyRankOfPred<[1]>]>>:$lhs, Type.predicate, HasStaticShapePred, HasAnyRankOfPred<[1]>]>>:$rhs); - let results = (outs EncryptedIntegerType:$out); + let results = (outs FHE_EncryptedIntegerType:$out); let hasVerifier = 1; } -def MatMulEintIntOp : FHELinalg_Op<"matmul_eint_int", [TensorBinaryEintInt]> { +def FHELinalg_MatMulEintIntOp : FHELinalg_Op<"matmul_eint_int", [TensorBinaryEintInt]> { let summary = "Returns a tensor that contains the result of the matrix multiplication of a matrix of encrypted integers and a matrix of clear integers."; let description = [{ @@ -659,16 +659,16 @@ def MatMulEintIntOp : FHELinalg_Op<"matmul_eint_int", [TensorBinaryEintInt]> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$lhs, + Type.predicate, HasStaticShapePred]>>:$lhs, Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } -def MatMulIntEintOp : FHELinalg_Op<"matmul_int_eint", [TensorBinaryIntEint]> { +def FHELinalg_MatMulIntEintOp : FHELinalg_Op<"matmul_int_eint", [TensorBinaryIntEint]> { let summary = "Returns a tensor that contains the result of the matrix multiplication of a matrix of clear integers and a matrix of encrypted integers."; let description = [{ @@ -798,15 +798,15 @@ def MatMulIntEintOp : FHELinalg_Op<"matmul_int_eint", [TensorBinaryIntEint]> { let arguments = (ins Type.predicate, HasStaticShapePred]>>:$lhs, - Type.predicate, HasStaticShapePred]>>:$rhs + Type.predicate, HasStaticShapePred]>>:$rhs ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } -def SumOp : FHELinalg_Op<"sum", [TensorUnaryEint]> { +def FHELinalg_SumOp : FHELinalg_Op<"sum", [TensorUnaryEint]> { let summary = "Returns the sum of elements of a tensor of encrypted integers along specified axes."; let description = [{ @@ -874,22 +874,22 @@ def SumOp : FHELinalg_Op<"sum", [TensorUnaryEint]> { }]; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$tensor, + Type.predicate, HasStaticShapePred]>>:$tensor, DefaultValuedAttr:$axes, DefaultValuedAttr:$keep_dims ); let results = (outs TypeConstraint.predicate, HasStaticShapePred]> + FHE_EncryptedIntegerType.predicate, + And<[TensorOf<[FHE_EncryptedIntegerType]>.predicate, HasStaticShapePred]> ]>>:$out ); let hasVerifier = 1; } -def ConcatOp : FHELinalg_Op<"concat"> { +def FHELinalg_ConcatOp : FHELinalg_Op<"concat"> { let summary = "Concatenates a sequence of tensors along an existing axis."; let description = [{ @@ -920,12 +920,12 @@ def ConcatOp : FHELinalg_Op<"concat"> { }]; let arguments = (ins - Variadic.predicate, HasStaticShapePred]>>>:$ins, + Variadic.predicate, HasStaticShapePred]>>>:$ins, DefaultValuedAttr:$axis ); let results = (outs - Type.predicate, HasStaticShapePred]>>:$out + Type.predicate, HasStaticShapePred]>>:$out ); let hasVerifier = 1; @@ -934,7 +934,7 @@ def ConcatOp : FHELinalg_Op<"concat"> { def FHELinalg_Conv2dOp : FHELinalg_Op<"conv2d", []> { let summary = "Returns the 2D convolution of a tensor in the form NCHW with weights in the form FCHW"; let arguments = (ins - Type.predicate, HasStaticShapePred]>>:$input, + Type.predicate, HasStaticShapePred]>>:$input, Type.predicate, HasStaticShapePred]>>:$weight, Optional.predicate, HasStaticShapePred]>>>:$bias, // Since there is no U64ElementsAttr, we use I64 and make sure there is no neg values during verification @@ -942,7 +942,7 @@ def FHELinalg_Conv2dOp : FHELinalg_Op<"conv2d", []> { OptionalAttr:$strides, OptionalAttr:$dilations ); - let results = (outs Type.predicate, HasStaticShapePred]>>); + let results = (outs Type.predicate, HasStaticShapePred]>>); let hasVerifier = 1; } @@ -1091,7 +1091,7 @@ $_state.addAttribute("dilations", dilations); }]; } -def TransposeOp : FHELinalg_Op<"transpose", []> { +def FHELinalg_TransposeOp : FHELinalg_Op<"transpose", []> { let summary = "Returns a tensor that contains the transposition of the input tensor."; let description = [{ @@ -1119,7 +1119,7 @@ def TransposeOp : FHELinalg_Op<"transpose", []> { let hasVerifier = 1; } -def FromElementOp : FHELinalg_Op<"from_element", []> { +def FHELinalg_FromElementOp : FHELinalg_Op<"from_element", []> { let summary = "Creates a tensor with a single element."; let description = [{ diff --git a/compiler/include/concretelang/Dialect/RT/IR/RTOps.td b/compiler/include/concretelang/Dialect/RT/IR/RTOps.td index 16a846f57..84cdc50e1 100644 --- a/compiler/include/concretelang/Dialect/RT/IR/RTOps.td +++ b/compiler/include/concretelang/Dialect/RT/IR/RTOps.td @@ -13,7 +13,7 @@ include "concretelang/Dialect/RT/IR/RTTypes.td" class RT_Op traits = []> : Op; -def DataflowTaskOp : RT_Op<"dataflow_task", [ +def RT_DataflowTaskOp : RT_Op<"dataflow_task", [ DeclareOpInterfaceMethods, SingleBlockImplicitTerminator<"DataflowYieldOp">]> { let arguments = (ins Variadic: $inputs); @@ -67,7 +67,7 @@ func @test(%0 : i64): (i64, i64) { }]; } -def DataflowYieldOp : RT_Op<"dataflow_yield", [ReturnLike, Terminator]> { +def RT_DataflowYieldOp : RT_Op<"dataflow_yield", [ReturnLike, Terminator]> { let arguments = (ins Variadic: $values); let summary = "Dataflow yield operation"; @@ -85,7 +85,7 @@ Example: }]; } -def MakeReadyFutureOp : RT_Op<"make_ready_future"> { +def RT_MakeReadyFutureOp : RT_Op<"make_ready_future"> { let arguments = (ins AnyType: $input); let results = (outs RT_Future: $output); let summary = "Build a ready future."; @@ -96,7 +96,7 @@ using `RT.make_ready_future`. }]; } -def AwaitFutureOp : RT_Op<"await_future"> { +def RT_AwaitFutureOp : RT_Op<"await_future"> { let arguments = (ins RT_Future: $input); let results = (outs AnyType: $output); let summary = "Wait for a future and access its data."; @@ -108,39 +108,39 @@ be synchronized and its data accessed using `RT.await_future`. }]; } -def CreateAsyncTaskOp : RT_Op<"create_async_task"> { +def RT_CreateAsyncTaskOp : RT_Op<"create_async_task"> { let arguments = (ins SymbolRefAttr:$workfn, Variadic:$list); let results = (outs ); let summary = "Create a dataflow task."; } -def DeallocateFutureOp : RT_Op<"deallocate_future"> { +def RT_DeallocateFutureOp : RT_Op<"deallocate_future"> { let arguments = (ins RT_Future: $input); let results = (outs ); } -def DeallocateFutureDataOp : RT_Op<"deallocate_future_data"> { +def RT_DeallocateFutureDataOp : RT_Op<"deallocate_future_data"> { let arguments = (ins RT_Future: $input); let results = (outs ); } -def BuildReturnPtrPlaceholderOp : RT_Op<"build_return_ptr_placeholder"> { +def RT_BuildReturnPtrPlaceholderOp : RT_Op<"build_return_ptr_placeholder"> { let arguments = (ins ); let results = (outs RT_Pointer: $output); } -def DerefReturnPtrPlaceholderOp : RT_Op<"deref_return_ptr_placeholder"> { +def RT_DerefReturnPtrPlaceholderOp : RT_Op<"deref_return_ptr_placeholder"> { let arguments = (ins RT_Pointer: $input); let results = (outs RT_Future: $output); } -def DerefWorkFunctionArgumentPtrPlaceholderOp : RT_Op<"deref_work_function_argument_ptr_placeholder"> { +def RT_DerefWorkFunctionArgumentPtrPlaceholderOp : RT_Op<"deref_work_function_argument_ptr_placeholder"> { let arguments = (ins RT_Pointer: $input); let results = (outs AnyType: $output); } -def WorkFunctionReturnOp : RT_Op<"work_function_return"> { +def RT_WorkFunctionReturnOp : RT_Op<"work_function_return"> { let arguments = (ins AnyType:$in, AnyType:$out); let results = (outs ); } diff --git a/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td b/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td index bb22e1286..182f6e274 100644 --- a/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td +++ b/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td @@ -19,100 +19,100 @@ include "concretelang/Dialect/TFHE/IR/TFHETypes.td" class TFHE_Op traits = []> : Op; -def ZeroGLWEOp : TFHE_Op<"zero"> { +def TFHE_ZeroGLWEOp : TFHE_Op<"zero"> { let summary = "Returns a trivial encyption of 0"; let arguments = (ins); - let results = (outs GLWECipherTextType : $out); + let results = (outs TFHE_GLWECipherTextType : $out); } -def ZeroTensorGLWEOp : TFHE_Op<"zero_tensor"> { +def TFHE_ZeroTensorGLWEOp : TFHE_Op<"zero_tensor"> { let summary = "Returns a tensor of trivial encyption of 0"; let arguments = (ins); - let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); + let results = (outs Type.predicate, HasStaticShapePred]>>:$tensor); } -def AddGLWEIntOp : TFHE_Op<"add_glwe_int"> { +def TFHE_AddGLWEIntOp : TFHE_Op<"add_glwe_int"> { let summary = "Returns the sum of a clear integer and a lwe ciphertext"; - let arguments = (ins GLWECipherTextType : $a, AnyInteger : $b); - let results = (outs GLWECipherTextType); + let arguments = (ins TFHE_GLWECipherTextType : $a, AnyInteger : $b); + let results = (outs TFHE_GLWECipherTextType); let hasVerifier = 1; } -def AddGLWEOp : TFHE_Op<"add_glwe"> { +def TFHE_AddGLWEOp : TFHE_Op<"add_glwe"> { let summary = "Returns the sum of 2 lwe ciphertexts"; - let arguments = (ins GLWECipherTextType : $a, GLWECipherTextType : $b); - let results = (outs GLWECipherTextType); + let arguments = (ins TFHE_GLWECipherTextType : $a, TFHE_GLWECipherTextType : $b); + let results = (outs TFHE_GLWECipherTextType); let hasVerifier = 1; } -def SubGLWEIntOp : TFHE_Op<"sub_int_glwe"> { +def TFHE_SubGLWEIntOp : TFHE_Op<"sub_int_glwe"> { let summary = "Substracts an integer and a GLWE ciphertext"; - let arguments = (ins AnyInteger : $a, GLWECipherTextType : $b); - let results = (outs GLWECipherTextType); + let arguments = (ins AnyInteger : $a, TFHE_GLWECipherTextType : $b); + let results = (outs TFHE_GLWECipherTextType); let hasVerifier = 1; } -def NegGLWEOp : TFHE_Op<"neg_glwe"> { +def TFHE_NegGLWEOp : TFHE_Op<"neg_glwe"> { let summary = "Negates a glwe ciphertext"; - let arguments = (ins GLWECipherTextType : $a); - let results = (outs GLWECipherTextType); + let arguments = (ins TFHE_GLWECipherTextType : $a); + let results = (outs TFHE_GLWECipherTextType); let hasVerifier = 1; } -def MulGLWEIntOp : TFHE_Op<"mul_glwe_int"> { +def TFHE_MulGLWEIntOp : TFHE_Op<"mul_glwe_int"> { let summary = "Returns the product of a clear integer and a lwe ciphertext"; - let arguments = (ins GLWECipherTextType : $a, AnyInteger : $b); - let results = (outs GLWECipherTextType); + let arguments = (ins TFHE_GLWECipherTextType : $a, AnyInteger : $b); + let results = (outs TFHE_GLWECipherTextType); let hasVerifier = 1; } -def KeySwitchGLWEOp : TFHE_Op<"keyswitch_glwe"> { +def TFHE_KeySwitchGLWEOp : TFHE_Op<"keyswitch_glwe"> { let summary = "Change the encryption parameters of a glwe ciphertext by " "applying a keyswitch"; let arguments = (ins - GLWECipherTextType : $ciphertext, + TFHE_GLWECipherTextType : $ciphertext, I32Attr : $level, I32Attr : $baseLog ); - let results = (outs GLWECipherTextType : $result); + let results = (outs TFHE_GLWECipherTextType : $result); } -def GLWEFromTableOp : TFHE_Op<"glwe_from_table"> { +def TFHE_GLWEFromTableOp : TFHE_Op<"glwe_from_table"> { let summary = "Creates a GLWE ciphertext which is the trivial encrytion of a the input " "table interpreted as a polynomial (to use later in a bootstrap)"; let arguments = (ins 1DTensorOf < [I64] > : $table); - let results = (outs GLWECipherTextType : $result); + let results = (outs TFHE_GLWECipherTextType : $result); } -def BootstrapGLWEOp : TFHE_Op<"bootstrap_glwe"> { +def TFHE_BootstrapGLWEOp : TFHE_Op<"bootstrap_glwe"> { let summary = "Programmable bootstraping of a GLWE ciphertext with a lookup table"; let arguments = (ins - GLWECipherTextType : $ciphertext, - GLWECipherTextType : $lookup_table, + TFHE_GLWECipherTextType : $ciphertext, + TFHE_GLWECipherTextType : $lookup_table, I32Attr : $level, I32Attr : $baseLog ); - let results = (outs GLWECipherTextType : $result); + let results = (outs TFHE_GLWECipherTextType : $result); } #endif diff --git a/compiler/include/concretelang/Dialect/TFHE/IR/TFHETypes.td b/compiler/include/concretelang/Dialect/TFHE/IR/TFHETypes.td index a35725f96..582a2795d 100644 --- a/compiler/include/concretelang/Dialect/TFHE/IR/TFHETypes.td +++ b/compiler/include/concretelang/Dialect/TFHE/IR/TFHETypes.td @@ -8,7 +8,7 @@ include "mlir/IR/BuiltinTypes.td" class TFHE_Type traits = []> : TypeDef { } -def GLWECipherTextType : TFHE_Type<"GLWECipherText", [MemRefElementTypeInterface]> { +def TFHE_GLWECipherTextType : TFHE_Type<"GLWECipherText", [MemRefElementTypeInterface]> { let mnemonic = "glwe"; let summary = "A GLWE ciphertext";