Skip to content

Commit ae4b18d

Browse files
committed
Update lwe types from NewLwe.. to Lwe.. and simplify LWE
1 parent ad7ff1a commit ae4b18d

51 files changed

Lines changed: 621 additions & 1360 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/Analysis/UnifiedLivenessAnalysis/UnifiedLivenessAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ UnifiedLivenessResults runUnifiedLivenessAnalysis(Operation *op) {
314314

315315
// Add new ciphertext results
316316
for (Value result : walkOp->getResults()) {
317-
if (isa<lwe::NewLWECiphertextType, lwe::LWECiphertextType>(
317+
if (isa<lwe::LWECiphertextType>(
318318
result.getType())) {
319319
liveCiphertexts.insert(result);
320320
}

lib/Dialect/BGV/Conversions/BGVToLWE/BGVToLWE.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ struct BGVToLWE : public impl::BGVToLWEBase<BGVToLWE> {
2323

2424
RewritePatternSet patterns(context);
2525
patterns.add<Convert<AddOp, lwe::RAddOp>, Convert<SubOp, lwe::RSubOp>,
26-
Convert<NegateOp, lwe::RNegateOp>, Convert<MulOp, lwe::RMulOp>,
27-
lwe::ConvertExtract<ExtractOp, MulPlainOp, RotateColumnsOp> >(
26+
Convert<NegateOp, lwe::RNegateOp>, Convert<MulOp, lwe::RMulOp> >(
2827
context);
2928
walkAndApplyPatterns(module, std::move(patterns));
3029
}

lib/Dialect/BGV/IR/BGVOps.td

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class BGV_Op<string mnemonic, list<Trait> traits = []> :
2323
class BGV_CiphertextPlaintextOp<string mnemonic, list<Trait> traits = []>
2424
: BGV_Op<mnemonic, traits # [IsCiphertextPlaintextOp, InferTypeOpAdaptor]> {
2525
let arguments = (ins
26-
NewLWEPlaintextOrCiphertext:$lhs,
27-
NewLWEPlaintextOrCiphertext:$rhs
26+
LWEPlaintextOrCiphertext:$lhs,
27+
LWEPlaintextOrCiphertext:$rhs
2828
);
2929

3030
let results = (outs
31-
NewLWECiphertext:$output
31+
LWECiphertext:$output
3232
);
3333
}
3434

@@ -37,12 +37,12 @@ def BGV_AddOp : BGV_Op<"add", [Commutative,
3737
let summary = "Addition operation between ciphertexts.";
3838

3939
let arguments = (ins
40-
NewLWECiphertext:$lhs,
41-
NewLWECiphertext:$rhs
40+
LWECiphertext:$lhs,
41+
LWECiphertext:$rhs
4242
);
4343

4444
let results = (outs
45-
NewLWECiphertext:$output
45+
LWECiphertext:$output
4646
);
4747
}
4848

@@ -57,12 +57,12 @@ def BGV_SubOp : BGV_Op<"sub", [SameOperandsAndResultRings,
5757
let summary = "Subtraction operation between ciphertexts.";
5858

5959
let arguments = (ins
60-
NewLWECiphertext:$lhs,
61-
NewLWECiphertext:$rhs
60+
LWECiphertext:$lhs,
61+
LWECiphertext:$rhs
6262
);
6363

6464
let results = (outs
65-
NewLWECiphertext:$output
65+
LWECiphertext:$output
6666
);
6767
}
6868

@@ -75,12 +75,12 @@ def BGV_MulOp : BGV_Op<"mul", [Commutative, SameOperandsAndResultRings, InferTyp
7575
let summary = "Multiplication operation between ciphertexts.";
7676

7777
let arguments = (ins
78-
NewLWECiphertext:$lhs,
79-
NewLWECiphertext:$rhs
78+
LWECiphertext:$lhs,
79+
LWECiphertext:$rhs
8080
);
8181

8282
let results = (outs
83-
NewLWECiphertext:$output
83+
LWECiphertext:$output
8484
);
8585

8686
let hasVerifier = 1;
@@ -106,12 +106,12 @@ def BGV_RotateColumnsOp : BGV_Op<"rotate_cols", [AllTypesMatch<["input", "output
106106
}];
107107

108108
let arguments = (ins
109-
NewLWECiphertext:$input,
109+
LWECiphertext:$input,
110110
Builtin_IntegerAttr:$offset
111111
);
112112

113113
let results = (outs
114-
NewLWECiphertext:$output
114+
LWECiphertext:$output
115115
);
116116

117117
let hasVerifier = 1;
@@ -132,12 +132,12 @@ def BGV_RotateRowsOp : BGV_Op<"rotate_rows", [AllTypesMatch<["input", "output"]>
132132
}];
133133

134134
let arguments = (ins
135-
NewLWECiphertext:$input,
135+
LWECiphertext:$input,
136136
Builtin_IntegerAttr:$offset
137137
);
138138

139139
let results = (outs
140-
NewLWECiphertext:$output
140+
LWECiphertext:$output
141141
);
142142

143143
let hasVerifier = 1;
@@ -161,12 +161,12 @@ def BGV_ExtractOp : BGV_Op<"extract", [SameOperandsAndResultRings]> {
161161
}];
162162

163163
let arguments = (ins
164-
NewLWECiphertext:$input,
164+
LWECiphertext:$input,
165165
AnySignlessIntegerOrIndex:$offset
166166
);
167167

168168
let results = (outs
169-
NewLWECiphertext:$output
169+
LWECiphertext:$output
170170
);
171171

172172
let hasVerifier = 1;
@@ -176,11 +176,11 @@ def BGV_NegateOp : BGV_Op<"negate", [Involution, SameOperandsAndResultType]> {
176176
let summary = "Negate the coefficients of the ciphertext.";
177177

178178
let arguments = (ins
179-
NewLWECiphertext:$input
179+
LWECiphertext:$input
180180
);
181181

182182
let results = (outs
183-
NewLWECiphertext:$output
183+
LWECiphertext:$output
184184
);
185185

186186
let assemblyFormat = "operands attr-dict `:` qualified(type($output))" ;
@@ -201,13 +201,13 @@ def BGV_RelinearizeOp : BGV_Op<"relinearize", [SameOperandsAndResultRings,
201201
}];
202202

203203
let arguments = (ins
204-
NewLWECiphertext:$input,
204+
LWECiphertext:$input,
205205
DenseI32ArrayAttr:$from_basis,
206206
DenseI32ArrayAttr:$to_basis
207207
);
208208

209209
let results = (outs
210-
NewLWECiphertext:$output
210+
LWECiphertext:$output
211211
);
212212

213213
let hasVerifier = 1;
@@ -218,12 +218,12 @@ def BGV_ModulusSwitchOp : BGV_Op<"modulus_switch"> {
218218
let summary = "Lower the modulus level of the ciphertext via modulus switching.";
219219

220220
let arguments = (ins
221-
NewLWECiphertext:$input,
221+
LWECiphertext:$input,
222222
Polynomial_RingAttr:$to_ring
223223
);
224224

225225
let results = (outs
226-
NewLWECiphertext:$output
226+
LWECiphertext:$output
227227
);
228228

229229
let hasVerifier = 1;
@@ -234,12 +234,12 @@ def BGV_LevelReduceOp : BGV_Op<"level_reduce", [SameOperandsAndResultPlaintextTy
234234
let summary = "Lower the modulus level of the ciphertext via dropping RNS limbs.";
235235

236236
let arguments = (ins
237-
NewLWECiphertext:$input,
237+
LWECiphertext:$input,
238238
DefaultValuedAttr<I64Attr, "1">:$levelToDrop
239239
);
240240

241241
let results = (outs
242-
NewLWECiphertext:$output
242+
LWECiphertext:$output
243243
);
244244

245245
let hasVerifier = 1;

lib/Dialect/CKKS/Conversions/CKKSToLWE/CKKSToLWE.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ struct CKKSToLWE : public impl::CKKSToLWEBase<CKKSToLWE> {
7171
patterns.add<ConvertWithAttrs<AddOp, lwe::RAddOp>,
7272
ConvertWithAttrs<SubOp, lwe::RSubOp>,
7373
ConvertUnaryWithAttrs<NegateOp, lwe::RNegateOp>,
74-
ConvertWithAttrs<MulOp, lwe::RMulOp>,
75-
lwe::ConvertExtract<ExtractOp, MulPlainOp, RotateOp> >(
76-
context);
74+
ConvertWithAttrs<MulOp, lwe::RMulOp> >(context);
7775
walkAndApplyPatterns(module, std::move(patterns));
7876
}
7977
};

lib/Dialect/CKKS/IR/CKKSOps.td

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class CKKS_Op<string mnemonic, list<Trait> traits = []> :
2222
class CKKS_CiphertextPlaintextOp<string mnemonic, list<Trait> traits = []>
2323
: CKKS_Op<mnemonic, !listconcat(traits, [IsCiphertextPlaintextOp])> {
2424
let arguments = (ins
25-
NewLWEPlaintextOrCiphertext:$lhs,
26-
NewLWEPlaintextOrCiphertext:$rhs
25+
LWEPlaintextOrCiphertext:$lhs,
26+
LWEPlaintextOrCiphertext:$rhs
2727
);
2828

2929
let results = (outs
30-
NewLWECiphertext:$output
30+
LWECiphertext:$output
3131
);
3232
}
3333

@@ -36,12 +36,12 @@ def CKKS_AddOp : CKKS_Op<"add", [Commutative, SameOperandsAndResultRings
3636
let summary = "Addition operation between ciphertexts.";
3737

3838
let arguments = (ins
39-
NewLWECiphertext:$lhs,
40-
NewLWECiphertext:$rhs
39+
LWECiphertext:$lhs,
40+
LWECiphertext:$rhs
4141
);
4242

4343
let results = (outs
44-
NewLWECiphertext:$output
44+
LWECiphertext:$output
4545
);
4646
}
4747

@@ -56,12 +56,12 @@ def CKKS_SubOp : CKKS_Op<"sub", [SameOperandsAndResultRings,
5656
let summary = "Subtraction operation between ciphertexts.";
5757

5858
let arguments = (ins
59-
NewLWECiphertext:$lhs,
60-
NewLWECiphertext:$rhs
59+
LWECiphertext:$lhs,
60+
LWECiphertext:$rhs
6161
);
6262

6363
let results = (outs
64-
NewLWECiphertext:$output
64+
LWECiphertext:$output
6565
);
6666
}
6767

@@ -74,12 +74,12 @@ def CKKS_MulOp : CKKS_Op<"mul", [Commutative, SameOperandsAndResultRings]> {
7474
let summary = "Multiplication operation between ciphertexts.";
7575

7676
let arguments = (ins
77-
NewLWECiphertext:$lhs,
78-
NewLWECiphertext:$rhs
77+
LWECiphertext:$lhs,
78+
LWECiphertext:$rhs
7979
);
8080

8181
let results = (outs
82-
NewLWECiphertext:$output
82+
LWECiphertext:$output
8383
);
8484

8585
// let hasVerifier = 1;
@@ -96,12 +96,12 @@ def CKKS_RotateOp : CKKS_Op<"rotate", [AllTypesMatch<["input", "output"]>]> {
9696
let summary = "Rotate the coefficients of the ciphertext using a Galois automorphism.";
9797

9898
let arguments = (ins
99-
NewLWECiphertext:$input,
99+
LWECiphertext:$input,
100100
Builtin_IntegerAttr:$offset
101101
);
102102

103103
let results = (outs
104-
NewLWECiphertext:$output
104+
LWECiphertext:$output
105105
);
106106

107107
// let hasVerifier = 1;
@@ -125,12 +125,12 @@ def CKKS_ExtractOp : CKKS_Op<"extract", [SameOperandsAndResultRings]> {
125125
}];
126126

127127
let arguments = (ins
128-
NewLWECiphertext:$input,
128+
LWECiphertext:$input,
129129
AnySignlessIntegerOrIndex:$offset
130130
);
131131

132132
let results = (outs
133-
NewLWECiphertext:$output
133+
LWECiphertext:$output
134134
);
135135

136136
// let hasVerifier = 1;
@@ -140,11 +140,11 @@ def CKKS_NegateOp : CKKS_Op<"negate", [SameOperandsAndResultType, Involution]> {
140140
let summary = "Negate the coefficients of the ciphertext.";
141141

142142
let arguments = (ins
143-
NewLWECiphertext:$input
143+
LWECiphertext:$input
144144
);
145145

146146
let results = (outs
147-
NewLWECiphertext:$output
147+
LWECiphertext:$output
148148
);
149149

150150
let assemblyFormat = "operands attr-dict `:` qualified(type($output))" ;
@@ -165,13 +165,13 @@ def CKKS_RelinearizeOp : CKKS_Op<"relinearize", [SameOperandsAndResultRings,
165165
}];
166166

167167
let arguments = (ins
168-
NewLWECiphertext:$input,
168+
LWECiphertext:$input,
169169
DenseI32ArrayAttr:$from_basis,
170170
DenseI32ArrayAttr:$to_basis
171171
);
172172

173173
let results = (outs
174-
NewLWECiphertext:$output
174+
LWECiphertext:$output
175175
);
176176

177177
// let hasVerifier = 1;
@@ -182,12 +182,12 @@ def CKKS_RescaleOp : CKKS_Op<"rescale"> {
182182
let summary = "Rescales the ciphertext, which is the CKKS version of modulus switching in BGV/BFV.";
183183

184184
let arguments = (ins
185-
NewLWECiphertext:$input,
185+
LWECiphertext:$input,
186186
Polynomial_RingAttr:$to_ring
187187
);
188188

189189
let results = (outs
190-
NewLWECiphertext:$output
190+
LWECiphertext:$output
191191
);
192192

193193
// let hasVerifier = 1;
@@ -198,12 +198,12 @@ def CKKS_LevelReduceOp : CKKS_Op<"level_reduce", [SameOperandsAndResultPlaintext
198198
let summary = "Lower the modulus level of the ciphertext via dropping RNS limbs.";
199199

200200
let arguments = (ins
201-
NewLWECiphertext:$input,
201+
LWECiphertext:$input,
202202
DefaultValuedAttr<I64Attr, "1">:$levelToDrop
203203
);
204204

205205
let results = (outs
206-
NewLWECiphertext:$output
206+
LWECiphertext:$output
207207
);
208208

209209
// let hasVerifier = 1;
@@ -219,11 +219,11 @@ def CKKS_BootstrapOp : CKKS_Op<"bootstrap"> {
219219
}];
220220

221221
let arguments = (ins
222-
NewLWECiphertext:$input
222+
LWECiphertext:$input
223223
);
224224

225225
let results = (outs
226-
NewLWECiphertext:$output
226+
LWECiphertext:$output
227227
);
228228

229229
let assemblyFormat = "operands attr-dict `:` qualified(type($input)) `->` qualified(type($output))" ;

0 commit comments

Comments
 (0)