feat: parameterize KS operation

This commit is contained in:
youben11
2021-08-25 14:59:53 +01:00
committed by Quentin Bourgerie
parent 14f171bef9
commit 6e2ac3af4e
7 changed files with 46 additions and 24 deletions

View File

@@ -185,10 +185,23 @@ mlir::Value createPBS(mlir::PatternRewriter rewriter, mlir::Location loc,
// keyswitch
auto ct_type = ct.getType().cast<GLWECipherTextType>();
mlir::SmallVector<mlir::Value, 1> ksArgs{ct};
mlir::SmallVector<mlir::NamedAttribute, 6> ksAttrs{
mlir::NamedAttribute(
mlir::Identifier::get("inputLweSize", rewriter.getContext()), k),
// TODO: get the actual output size
mlir::NamedAttribute(
mlir::Identifier::get("outputLweSize", rewriter.getContext()), k),
mlir::NamedAttribute(
mlir::Identifier::get("level", rewriter.getContext()), levelKS),
mlir::NamedAttribute(
mlir::Identifier::get("baseLog", rewriter.getContext()), baseLogKS),
};
mlir::Value keyswitched =
rewriter
.create<mlir::zamalang::LowLFHE::KeySwitchLweOp>(
loc, convertTypeGLWEToLWE(rewriter.getContext(), ct_type), ct)
loc, convertTypeGLWEToLWE(rewriter.getContext(), ct_type), ksArgs,
ksAttrs)
.result();
// convert result type

View File

@@ -93,7 +93,11 @@ def SetPlaintextListElementOp : LowLFHE_Op<"set_plaintext_list_element">{
def KeySwitchLweOp : LowLFHE_Op<"keyswitch_lwe"> {
let arguments = (ins
// LweKeySwitchKeyType:$keyswitch_key,
LweCiphertextType:$ciphertext
LweCiphertextType:$ciphertext,
I32Attr:$inputLweSize,
I32Attr:$outputLweSize,
I32Attr:$level,
I32Attr:$baseLog
);
let results = (outs LweCiphertextType:$result);
}