Commit Graph

41 Commits

Author SHA1 Message Date
youben11
1e07733257 fix(lower-LUT): keep output size of KS during lowering
output size of keyswiting wasn't set properly. As this information must
come from the selected parameters, it should goes down from the MidLFHE
to the appropriate call to ciphertext allocation
2021-09-09 20:35:28 +02:00
youben11
50d2ff82af chore(compiler): disable bitwidth check for table lookup 2021-09-09 20:35:28 +02:00
youben11
6e2ac3af4e feat: parameterize KS operation 2021-09-09 20:35:28 +02:00
youben11
14f171bef9 feat: parameterize bst operation
This is needed to have the right parameters when calling concrete
2021-09-09 20:35:28 +02:00
youben11
b6c3eceadd refactor: remove keys from BS and KS ops in LowLFHE 2021-09-09 20:35:28 +02:00
Quentin Bourgerie
ee9acf08e8 enhance(compiler/lowlfhe): Add p and size to lwe_ciphertext 2021-08-24 16:29:04 +02:00
Quentin Bourgerie
70fb5fcd8e fix(compiler/midlfhe): Change constraint on operators with integers (just too large integers are forbidden) 2021-08-24 16:21:31 +02:00
Quentin Bourgerie
fa62e1f0e5 refactor(compiler): Move memref HLFHE and MidLFHE operators to tensor 2021-08-18 11:15:30 +02:00
Quentin Bourgerie
7372cd3d0a fix(compiler/hlfhe): More verification on dot_eint_int 2021-08-17 16:53:32 +02:00
Andi Drebes
8b9c9f2da1 refactor(compiler): HLFHE.dot_eint_int: Switch from reference to value semantics
This changes the semantics of `HLFHE.dot_eint_int` from memref-based
reference semantics to tensor-based value semantics. The former:

  "HLFHE.dot_eint_int"(%arg0, %arg1, %arg2) :
     (memref<Nx!HLFHE.eint<0>>, memref<Nxi32>, memref<!HLFHE.eint<0>>) -> ()

becomes:

  "HLFHE.dot_eint_int"(%arg0, %arg1) :
     (tensor<Nx!HLFHE.eint<0>>, tensor<Nxi32>) -> !HLFHE.eint<0>

As a side effect, data-flow analyses become much easier. With the
previous memref type of the plaintext argument it is difficult to
check whether the plaintext values are statically defined constants or
originate from a memory region changed at execution time (e.g., for
analyses evaluating the impact on noise). Changing the plaintext type
from `memref` to `vector` makes such analyses significantly easier.
2021-08-17 16:53:32 +02:00
Andi Drebes
cb580f16d2 feat(compiler): Add operation HLFHE.zero generating an encrypted zero 2021-08-17 16:53:32 +02:00
youben11
e401d9fb69 feat(compiler): update LowLFHE for MidLFHE lowering
-Encoding Cleartext to Plaintext Op
-Encoding Int to Plaintext Op
-Cleartext/Plaintext should add a bits field as `p`
-Op to create a constant Cleartext
-IntToCleartextOp: kind of casting an int to be later encoded, I'm not
sure if there is a better mechanism for this (e.g. auto casting in Ops),
but we currently need a way to encode int into plaintext, and we need to
go through cleartexts
2021-08-12 13:48:51 +01:00
Ayoub Benaissa
7a2511b3d4 feat(compiler): LowLFHE dialect (#77)
* feat(compiler): low level fhe dialect

* feat(compiler): using generated printer/parser in LowLFHE

* feat(compiler): new types and ops for LowLFHE

* tests(compiler): LowLFHE types and ops

* feat(compiler): fill ops

* cleanup

* summary + description

* tests(compiler): use new CLI args

* formatting
2021-08-05 14:32:46 +01:00
Quentin Bourgerie
4e6579e019 feat/refactor(compiler): Add --passes options to activate only a subset of passes (#57) 2021-08-04 14:03:05 +02:00
Quentin Bourgerie
ed40b1ef91 feat(compiler): Add HLFHE.sub_int_eint (#54) 2021-08-03 09:23:11 +02:00
Quentin Bourgerie
143a2384fd enhance(compiler): Add verifier of HLFHE operators 2021-08-03 09:23:11 +02:00
Quentin Bourgerie
cb635f8a55 feat(compiler): HLFHE.apply_lookup_table (#54) 2021-08-03 09:23:11 +02:00
Quentin Bourgerie
ea77ee696a enhance(compiler): Add verify for HLFHE.eint, precision ]0;7] (#54) 2021-08-03 09:23:11 +02:00
Quentin Bourgerie
3c326c09d6 clean(compiler): Remove unecessary operators for compiler v0 (#54) 2021-08-03 09:23:11 +02:00
Quentin Bourgerie
be62755401 fix(compiler): Fixing MidLFHE Dialect for the compiler v0 2021-07-29 09:53:45 +02:00
Andi Drebes
4504f090c5 feat(compiler): Add option --convert-hlfhe-tensor-ops-to-linalg
This adds a new command line option
`--convert-hlfhe-tensor-ops-to-linalg` that invokes a conversion pass
replacing any HLFHE tensor operation with an appropriate instance of
`linalg.generic`.
2021-07-16 18:03:49 +02:00
Andi Drebes
b433627821 feat(compiler): Add Dot operation to HLFHE dialect
Add a simple dot product between a vector of encrypted integers and a
vector of plaintext integers to the HLFHE dialect.

The operation takes two input operands and one output operand, all
modeled as memrefs. Example:

  "HLFHE.dot_eint_int"(%lhs, %rhs, %out) :
    (memref<?x!HLFHE.eint<0>>, memref<?xi32>, memref<!HLFHE.eint<0>>) -> ()
2021-07-16 18:03:49 +02:00
Andi Drebes
3bfda58eb8 feat(compiler): Make HLFHE.EncryptedInteger usable as memref element type
Make `HLFHE.EncryptedInteger` implement the
`MemRefElementTypeInterface` trait to allow the type to be used for
elements of memrefs.

The invocation of the `add_mlir_dialect` macro in
`include/zamalang/Dialect/HLFHE/IR/CMakeLists.txt` had to be broken
into its parts in order to pass `-typedefs-dialect=HLFHE` to
`mlir-tablegen`. This is required due to the inclusion of
`mlir/IR/BuiltinTypes.td` in
`include/zamalang/Dialect/HLFHE/IR/HLFHETypes.td`, resulting in
definitions from multiple dialects.

Add a small test actually using `HLFE.EncryptedInteger` in a `memref`.
2021-06-23 10:15:35 +02:00
Quentin Bourgerie
3aa5457b84 fix(compiler): Fixing some typos 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
a760ade545 enhance(compiler): Better error message for glwe error 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
8f73863e00 fix(compiler): Fixing MidLFHE.h_add verifier and adding tests 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
4e41969f3e test(compiler): Add another test for mul_plain padding verification 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
aafc9e44e9 fix(compiler): Fixing test ref 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
bdcf7ece05 enhance(compiler): Add verifier of MidLFHE.GLWE parameters 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
efedf23e8d enhance(compiler): MidLFHE.add_plain introduce paddingBits verification 2021-06-23 10:10:31 +02:00
Quentin Bourgerie
38105b5f1c enhance(compiler): MidLFHE has now only one GLWE type that take all cryptographic parameters 2021-06-23 10:10:31 +02:00
youben11
4e663df5af enhance(compiler): Add a region to the HLFHE.apply_univariate for the expression of the univariate closure 2021-05-28 12:08:42 +02:00
youben11
efae2a79d7 feat(compiler): h_add and h_mul 2021-05-28 12:08:42 +02:00
youben11
8edf4a358e feat(compiler): keyswitching types and ops 2021-05-28 12:08:42 +02:00
youben11
7104e2600c feat(compiler): parameterize pbs ops via attr 2021-05-28 12:08:42 +02:00
youben11
55043c24f1 feat(compiler): introduce mul_plain 2021-05-28 12:08:41 +02:00
Quentin Bourgerie
ccae801e5a feat(compiler): Introduce MidLFHE.add_plain and MidLFHE.pbs 2021-05-28 12:08:41 +02:00
Quentin Bourgerie
0b41018ade feat(compiler): Add !HLFHE.ciphertext 2021-05-28 12:08:41 +02:00
Quentin Bourgerie
ce69aab756 feat(compiler): Add !MidLFHE.ggsw<size,N,level,base_log> 2021-05-28 12:08:41 +02:00
Quentin Bourgerie
122759eabf feat(compiler): Introduce MidLFHEDialect (!MidLFHE.lwe<size>, !MidLFHE.glwe<size,n>) 2021-05-28 12:08:41 +02:00
youben11
0b86ed0c2c test(compiler): testing dialect's ops 2021-05-28 12:08:41 +02:00