Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add secret-to-bgv conversion for ciphertext arith ops
Adds parameter setting options. All secret inputs are required to be a uniform tensor shape that matches the ring dimension in the parameters specified. PiperOrigin-RevId: 615502361
- Loading branch information
Showing
18 changed files
with
433 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SecretToBGV tablegen and headers. | ||
|
||
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library") | ||
|
||
package( | ||
default_applicable_licenses = ["@heir//:license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files( | ||
[ | ||
"SecretToBGV.h", | ||
], | ||
) | ||
|
||
gentbl_cc_library( | ||
name = "pass_inc_gen", | ||
tbl_outs = [ | ||
( | ||
[ | ||
"-gen-pass-decls", | ||
"-name=SecretToBGV", | ||
], | ||
"SecretToBGV.h.inc", | ||
), | ||
( | ||
["-gen-pass-doc"], | ||
"SecretToBGV.md", | ||
), | ||
], | ||
tblgen = "@llvm-project//mlir:mlir-tblgen", | ||
td_file = "SecretToBGV.td", | ||
deps = [ | ||
"@llvm-project//mlir:OpBaseTdFiles", | ||
"@llvm-project//mlir:PassBaseTdFiles", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_H_ | ||
#define INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_H_ | ||
|
||
#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project | ||
|
||
namespace mlir::heir { | ||
|
||
#define GEN_PASS_DECL | ||
#include "include/Conversion/SecretToBGV/SecretToBGV.h.inc" | ||
|
||
#define GEN_PASS_REGISTRATION | ||
#include "include/Conversion/SecretToBGV/SecretToBGV.h.inc" | ||
|
||
} // namespace mlir::heir | ||
|
||
#endif // INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_TD_ | ||
#define INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_TD_ | ||
|
||
include "mlir/Pass/PassBase.td" | ||
|
||
def SecretToBGV : Pass<"secret-to-bgv"> { | ||
let summary = "Lower `secret` to `bgv` dialect."; | ||
|
||
let description = [{ | ||
This pass lowers an IR with `secret.generic` blocks containing arithmetic | ||
operations to operations on ciphertexts with the BGV dialect. | ||
|
||
The pass assumes that the `secret.generic` regions have been distributed | ||
through arithmetic operations so that only one ciphertext operation appears | ||
per generic block. It also requires that `canonicalize` was run so that | ||
non-secret values used are removed from the `secret.generic`'s block | ||
arguments. | ||
|
||
The pass requires that all types are tensors of a uniform shape matching the | ||
dimension of the ciphertext space specified my `poly-mod-degree`. | ||
}]; | ||
|
||
let dependentDialects = [ | ||
"mlir::heir::polynomial::PolynomialDialect", | ||
"mlir::heir::bgv::BGVDialect", | ||
"mlir::heir::lwe::LWEDialect", | ||
]; | ||
|
||
let options = [ | ||
Option<"polyModDegree", "poly-mod-degree", "int", | ||
/*default=*/"1024", "Default degree of the cyclotomic polynomial " | ||
"modulus to use for ciphertext space.">, | ||
Option<"coefficientModBits", "coefficient-mod-bits", "int", | ||
/*default=*/"29", "Default number of bits of the prime " | ||
"coefficient modulus to use " "for the ciphertext space."> | ||
]; | ||
} | ||
|
||
#endif // INCLUDE_CONVERSION_SECRETTOBGV_SECRETTOBGV_TD_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package( | ||
default_applicable_licenses = ["@heir//:license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "SecretToBGV", | ||
srcs = ["SecretToBGV.cpp"], | ||
hdrs = [ | ||
"@heir//include/Conversion/SecretToBGV:SecretToBGV.h", | ||
], | ||
deps = [ | ||
"@heir//include/Conversion/SecretToBGV:pass_inc_gen", | ||
"@heir//lib/Conversion:Utils", | ||
"@heir//lib/Dialect/BGV/IR:Dialect", | ||
"@heir//lib/Dialect/LWE/IR:Dialect", | ||
"@heir//lib/Dialect/Polynomial/IR:Dialect", | ||
"@heir//lib/Dialect/Polynomial/IR:Polynomial", | ||
"@heir//lib/Dialect/Polynomial/IR:PolynomialAttributes", | ||
"@heir//lib/Dialect/Secret/IR:Dialect", | ||
"@llvm-project//llvm:Support", | ||
"@llvm-project//mlir:ArithDialect", | ||
"@llvm-project//mlir:IR", | ||
"@llvm-project//mlir:Pass", | ||
"@llvm-project//mlir:Support", | ||
"@llvm-project//mlir:Transforms", | ||
], | ||
) |
Oops, something went wrong.