Commit Graph

47 Commits

Author SHA1 Message Date
Ayoub Benaissa
ab53ef71c6 feat(compiler): Python bindings (#53)
- feat(compiler): python bindings
- build: update docker image for python bindings
- pin pybind11 to 2.6.2, 2.7 is not having correct include_dirs set (still
a question why?)
- using generated parser/printer
2021-07-28 15:58:51 +01:00
Ayoub Benaissa
812268000c CI: docker image workflow
build and push whenever the docker file has changed. Push with two tags, latest, and commit's hash
2021-07-22 15:32:44 +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
9d1cdc6a0c feat(compiler): Add lowering pass from HLFHE.dot_eint_int to linalg.generic
This pass transforms any instance of `HLFHE.dot_eint_int` to an
instance of `linalg.generic` with an appropriate region using
`HLFHE.mul_eint_int` and `HLFHE.add_eint` operations and an
appropriate specification for the iteration dimensions.

Example:

  "HLFHE.dot_eint_int"(%arg0, %arg1, %arg2) :
    (memref<?x!HLFHE.eint<0>>, memref<?xi32>, memref<!HLFHE.eint<0>>) -> ()

becomes:

  linalg.generic {
    indexing_maps = [affine_map<(d0) -> (d0)>,
                     affine_map<(d0) -> (d0)>,
		     affine_map<(d0) -> ()>],
    iterator_types = ["reduction"]
  } ins(%arg0, %arg1 : memref<?x!HLFHE.eint<0>>, memref<?xi32>) outs(%arg2 : memref<!HLFHE.eint<0>>) {
    ^bb0(%arg3: !HLFHE.eint<0>, %arg4: i32, %arg5: !HLFHE.eint<0>):  // no predecessors
      %0 = "HLFHE.mul_eint_int"(%arg3, %arg4) : (!HLFHE.eint<0>, i32) -> !HLFHE.eint<0>
      %1 = "HLFHE.add_eint"(%0, %arg5) : (!HLFHE.eint<0>, !HLFHE.eint<0>) -> !HLFHE.eint<0>
      linalg.yield %1 : !HLFHE.eint<0>
  }
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
27990a8302 feat(compiler): Add option --verify-diagnostics
The option `--verify-diagnostics` allows the user to interleave
invalid source code with diagnostic messages that should be produced
during parsing and checks if these messages are actually produced. The
expected diagnostic messages are specified using `// expected-error`
markers.
2021-07-16 18:03:49 +02:00
Andi Drebes
ee03a48447 feat(compiler): Add option --split-input-file
The new option `--split-input-file` allows the user to add `// -----`
markers to a source file, causing the file to be split into multiple
chunks that are treated as if they were specified in different files.
2021-07-16 18:03:49 +02:00
Andi Drebes
74671794e3 refactor(compiler): Use idiomatic approach for I/O management
Use a more idiomatic approach for I/O using `llvm::SourceManager` to
manage input files and `mlir::openOutputFile` to write to the
output. This commit prepares management of diagnostics in subsequent
changes.
2021-07-16 18:03:49 +02:00
Andi Drebes
cef0e569d4 fix(compiler): Generate and include autogenerated dialect definitions (#52)
* fix(compiler): Generate and include autogenerated dialect definitions

Since commit 485cc55edfb875628e19bb6d9de4706af2865d3e in llvm-project,
dialects are now required to include a file with autogenerated
definitions. This commit generates the definition files and includes
them in appropriate dialect source files for MidLFHE and HLFHE.

* CI: update docker image ref

Co-authored-by: Andi Drebes <andi.drebes@zama.ai>
Co-authored-by: Ayoub Benaissa <ayoub.benaissa@zama.ai>
2021-07-08 15:54:10 +01: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
c783d85a84 doc(compiler): comments on MidLFHE verifiers 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
Quentin Bourgerie
d489f91f7d chore(compiler/ci): Update mlir image 2021-06-23 10:07:16 +02:00
Quentin Bourgerie
af23854480 fix(compiler): Fixing some step to speedup the build of the container of the mlir-env 2021-06-16 14:31:21 +02:00
Quentin Bourgerie
b948c5c6a5 chore(compiler): Actions for build and test compiler 2021-06-16 14:31:21 +02:00
Andi Drebes
428ba24807 style(compiler): Use header guards conforming to style from .clang-tidy 2021-06-11 10:46:03 +02:00
Andi Drebes
5167781e44 ci(compiler): Add option --fix to lint_cpp.sh
Add an option `--fix` to `lint_cpp.sh` advising `clang-tidy` to apply
suggested fixes.
2021-06-11 10:45:00 +02:00
Andi Drebes
bf101e5147 ci(compiler): Add script for C++ linting
Add script `.github/workflows/scripts/lint_cpp.sh` that runs
`clang-tidy` with the right parameters to limit checks to source files
not generated automatically.

The script must be run from within the build directory as it relies on
`compiler_commands.json` and `CMakeFiles/CMakeDirectoryInformation.cmake`.
2021-06-08 14:26:42 +02:00
Andi Drebes
5ef78f37f3 ci(compiler): Add clang-tidy configuration file
Add configuration file for `clang-tidy` with the same settings as
MLIR.
2021-06-08 14:26:42 +02:00
Andi Drebes
2c4748b414 refactor(compiler): Use LLVM command line parser instead of tclap
LLVM already provides a command line parser, covering the use of tclap
in the sources. This patch uses the LLVM command line parser instead
of tclap and thus reduces the number of external dependencies.
2021-06-08 14:05:15 +02:00
Ayoub Benaissa
eef82a4713 style(compiler): c++ formatting with github action (#22)
* style(compiler): c++ formatting with github action

* style(compiler): update format script
2021-06-04 09:18:14 +02:00
Andi Drebes
5164126447 style: Add .clang-format 2021-06-04 09:18:14 +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
183fe7f6fa chore: gitignore 2021-05-28 12:08:42 +02:00
Quentin Bourgerie
f0615da12a fix(compiler): segfault on parse error 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
f9c135dfa7 chore: .gitignore 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
Quentin Bourgerie
d4b7d61f99 chore(compiler): Add configuration of test and introduce command line options 2021-05-28 12:08:41 +02:00
youben11
0b86ed0c2c test(compiler): testing dialect's ops 2021-05-28 12:08:41 +02:00
Andi Drebes
788adcbbae feat(compiler): Let zamacompiler parse an MLIR source file and dump the in-memory representation 2021-05-28 12:02:18 +02:00
Quentin Bourgerie
32340d3ec0 feat(compiler): Introduce HLFHEDialect 2021-05-28 12:02:18 +02:00
Quentin Bourgerie
f7c11a0c4e chore(compiler): Empty MLIR structure 2021-05-18 10:57:48 +02:00
Quentin Bourgerie
c6a0a699f5 doc: Initial commit 2021-05-11 17:14:27 +02:00