Commit Graph

143 Commits

Author SHA1 Message Date
Quentin Bourgerie
e0af1523bc cleanup(compiler/test): Formatting of mlir test string 2021-11-17 14:19:15 +01:00
Quentin Bourgerie
100862e484 feat(compiler): Add the support of linalg.tensor_expand_shape and linalg.tensor_collapse_shape on encrypted tensors 2021-11-17 14:19:15 +01:00
youben11
36413235c5 feat(compiler): lower HLFHELinalg.apply_multi_lut
Support broadcasting
2021-11-15 11:25:44 +01:00
youben11
ac7f1f5a6b feat(compiler): add HLFHELinalg.apply_multi_lut
Apply a lookup table on the different elements of the encrypted tensors,
but using different lookup tables.

MANP support as well as tests
2021-11-15 11:25:44 +01:00
Quentin Bourgerie
5df775a51b feat(compiler): MANP Analysis of HLFHELinalg.matmul (closes #178) 2021-11-12 16:50:29 +01:00
Quentin Bourgerie
af0819c403 feat(compiler): Lower HLFHELinalg.matmul_eint_int to linalg.generic (close #177) 2021-11-12 16:50:29 +01:00
Quentin Bourgerie
12b4771405 feat(compiler/linalg): Definition of HLFHELinalg.matmul_eint_int (closes #176) 2021-11-12 16:50:29 +01:00
youben11
7c83994c7f fix(compiler): don't try to broadcast when dims are equals with value 1 2021-11-12 15:07:08 +01:00
Andi Drebes
d1960a2a7f test(compiler): Add test for lambdas returning tensors of different integer types
Add tests with lambdas returning constant n-dimensional tensors
composed of different integer types (uint8_t, uint16_t, uint32_t, and
uint64_t).
2021-11-12 12:00:39 +01:00
youben11
6df9f09e48 feat(compiler): lower HLFHELinalg.neg_eint 2021-11-10 15:24:31 +01:00
youben11
99d6d11616 feat(compiler): support HLFHELinalg.neg_eint in MANP 2021-11-10 15:24:31 +01:00
youben11
d9adbab036 feat(compiler): add HLFHELinalg.neg_eint op 2021-11-10 15:24:31 +01:00
youben11
ba40f5582a test(compiler): test HLFHE.neg_eint execution 2021-11-10 15:24:31 +01:00
youben11
efacd7d8a1 feat(compiler): support HLFHE.neg_eint in MANP 2021-11-10 15:24:31 +01:00
youben11
08869bc998 chore: separate unittests into different executables
it's easier to run a specific set of tests if they are into separate
executable. We shouldn't have to run them all for testing a specific set
of tests
2021-11-10 15:24:21 +01:00
youben11
aee493392b feat(compiler): lower neg_eint from HLFHE to LowLFHE 2021-11-10 15:24:21 +01:00
youben11
c1cd6bb380 feat(compiler): add MidLFHE.neg_glwe op 2021-11-10 15:24:06 +01:00
youben11
cc4e403e7a feat(compiler): add HLFHE.neg_eint op 2021-11-10 14:52:35 +01:00
Andi Drebes
47cb4b0e70 fix(compiler): HLFHELinalg JIT tests: Use immutable ArrayRefs for tensor arguments
Fix compiler warnings related to the conversion from const pointers to
mutable pointers in `tests/unittest/end_to_end_jit_hlfhelinalg.cc`.
2021-11-10 11:25:35 +01:00
Andi Drebes
8cd893a7fd fix(compiler): JIT unit tests: Remove unused variables
Remove unused variable `pos` in `End2EndJit_ClearTensor_2D::extract`
and `End2EndJit_EncryptedTensor_2D::extract` to avoid warnings on
compilation.
2021-11-10 11:25:35 +01:00
Andi Drebes
5cc551dd4f fix(compiler): JIT unit tests: Don't compare expressions of different signedness
Fix compiler warnings in `end_to_end_jit_clear_tensor.cc` and
`end_to_end_jit_encrypted_tensor.cc` due to the comparison of integer
expressions of different signedness.
2021-11-10 11:25:35 +01:00
rudy
97389a3b06 Move HLFHE.dot_eint_int to HLFHELinalg.
Resolves #183
2021-11-09 11:39:08 +01:00
Andi Drebes
c401b5ae44 test(compiler): Add JIT test returning multi-dimensional TensorLambdaArgument 2021-11-08 12:00:20 +01:00
youben11
59e859177c refactor: replace ExecutionArg by TensorLambdaArg
This add support for tensor inputs from the python bindings
2021-11-08 11:55:02 +01:00
youben11
b501e3d6c0 feat(python): support functions returning tensors 2021-11-08 11:55:02 +01:00
youben11
badc8e44bf test(comiler): add tests for result tensor when calling Lambda::operator()
Lambda::operator()<unique_ptr<LambdaArgument>> was giving bad results
when using tensors due to bad references. Now it's fixed and we want to
spot that in the future.
2021-11-04 19:07:54 +01:00
Andi Drebes
3d6ad06f46 test(compiler): Add tests for JitCompilerEngine::Lambda with a generic result 2021-11-03 18:32:06 +01:00
youben11
97ee8134ed fix(python): register hlfhelinalg dialect 2021-11-03 15:37:43 +01:00
Andi Drebes
0cb5007c3c enhance(compiler): Python bindings: Forward llvm::Expected error messages in exceptions
The code in `lib/CAPI/Support/CompilerEngine.cpp` invokes several
functions returning an `llvm::Expected<T>`. When those fail, the error
message retrieved from the error object the `llvm::Expected<T>`
instance is written to the standard error stream via
`mlir::zamalang::log_error()` and an exception with a more generic
error message is thrown.

This causes errors to show up on the standard error stream in tests
generating errors on purpose and checking them, e.g.:

  ```
  tests/python/test_compiler_engine.py::test_compile_invalid[not
  @main] Compilation failed: cannot find the function for generate
  client parameters PASSED
  ```

This patch forwards the error message from an `llvm::Expected<T>`
instance in a runtime exception rather than writing it to the standard
error stream. Since exceptions are properly caught by the tests, no
errors show up during testing.
2021-11-02 16:34:42 +01:00
youben11
03c1588db4 chore: update to LLVM 8b7cc93e
major changes:
- https://llvm.discourse.group/t/psa-removed-arithmetic-ops-from-standard/4455
- use add_mlir_public_c_api_library helper to correctly add a CAPI library
2021-10-29 16:08:41 +01:00
Quentin Bourgerie
5bb58453aa feat(compiler): MANP Analysis of HLFHELinalg.apply_lookup_table (close #175) 2021-10-29 13:47:38 +02:00
Quentin Bourgerie
ccaf1bff15 feat(compiler): Lower HLFHELinalg.apply_lookup_table (close #174) 2021-10-29 13:47:38 +02:00
Quentin Bourgerie
2900c9a2a1 feat(compiler): Add support of HLFHELinalg binary operators in MANP pass (close #172) 2021-10-29 13:47:38 +02:00
Quentin Bourgerie
be92b4580d Merge branch 'master' into hlfhelinalg-binary-op-lowering 2021-10-29 13:47:35 +02:00
Quentin Bourgerie
e66fb20c4f test(compiler): Re introduce tests that was removed by a prior refacto 2021-10-29 13:44:34 +02:00
Quentin Bourgerie
85d102c9b2 refactor(compiler): Simplify the compiler flow and re enable --passes compiler option
No more need to compute the fhe context at high level
2021-10-29 13:44:34 +02:00
Andi Drebes
1187cfbd62 refactor(compiler): Refactor CompilerEngine and related classes
This commit contains several incremental improvements towards a clear
interface for lambdas:

  - Unification of static and JIT compilation by using the static
    compilation path of `CompilerEngine` within a new subclass
    `JitCompilerEngine`.

  - Clear ownership for compilation artefacts through
    `CompilationContext`, making it impossible to destroy objects used
    directly or indirectly before destruction of their users.

  - Clear interface for lambdas generated by the compiler through
    `JitCompilerEngine::Lambda` with a templated call operator,
    encapsulating otherwise manual orchestration of `CompilerEngine`,
    `JITLambda`, and `CompilerEngine::Argument`.

  - Improved error handling through `llvm::Expected<T>` and proper
    error checking following the conventions for `llvm::Expected<T>`
    and `llvm::Error`.

Co-authored-by: youben11 <ayoub.benaissa@zama.ai>
2021-10-29 13:44:34 +02:00
Andi Drebes
3ae924e174 enhance(compiler): Disable RTTI for unit tests
LLVM and MLIR are compiled without runtime type information
(RTTI). Use the same restrictions for unit tests to avoid linker
errors related to typeinfo when building the test executable.
2021-10-29 13:44:34 +02:00
Quentin Bourgerie
31d9f568fa refactor(test): Move HLFHELinalg e2e test 2021-10-29 12:18:30 +02:00
Quentin Bourgerie
a135d05e4d feat(compiler): Lowering of HLFHELinalg.mul_eint_int 2021-10-29 12:18:30 +02:00
Quentin Bourgerie
0b5ee3497a feat(compiler): Lowering of HLFHELinalg.sub_int_eint 2021-10-29 12:18:22 +02:00
Quentin Bourgerie
b81cb978d0 feat(compiler): Lowering of HLFHELinalg.add_eint_int 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
ba54560680 feat(compiler): Lower HLFHELinalg binary operators 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
dea1be9d52 feat(compiler): HLFHELinalg.apply_lookup_table definition 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
f72d51d98d feat(compiler): HLFHELinalg.mul_eint_int 2021-10-29 12:17:38 +02:00
Quentin Bourgerie
64e327209f feat(compiler): HLFHELinalg.sub_int_eint 2021-10-29 12:17:32 +02:00
Quentin Bourgerie
3b02a16f7b feat(compiler): HLFHELinalg.add_eint definition 2021-10-29 12:16:41 +02:00
Quentin Bourgerie
0d4e10169b feat(compiler): Introduce the HLFHELinalg dialect and a first operator HLFHELinalg.add_eint_int 2021-10-29 12:16:41 +02:00
Quentin Bourgerie
247cc489c5 refactor(compiler): Refactor JITLambda::Argument::setArg 2021-10-21 14:40:07 +02:00
Quentin Bourgerie
b5f68c20c7 fix(compiler): Remove the default constraint since tensor operators are supported 2021-10-20 16:21:52 +02:00