Commit Graph

288 Commits

Author SHA1 Message Date
Andi Drebes
77b7aa2f7c fix(compiler): Fix warnings and naming in test for parametric slices
- Rename `extract_slice_parametric_2x2` to
  `extract_slice_parametric_2x2x2x2` to reflect the 4-dimensional
  structure of the tiles.

- Make the array with the specification of the dimensions in
  `extract_slice_parametric_2x2x2x2` a `constexpr` in order to prevent
  the array `A` from being treated as a variable-length array.

- Cast the expression for the expected size of the result to `size_t`
  and change the type of the induction variables of the loop nest
  producing the initial values for the array `A` to `int64_t` to avoid
  warnings about the comparison of integer expressions with different
  signedness.
2021-12-17 15:52:57 +01:00
Andi Drebes
27ca5122bc enhance(compiler): Use named constant for the default pattern rewriting benefit
This introduces a new header file `zamalang/Support/Constants.h` for
constants, currently only populated with a constant for the default
pattern rewriting benefit of 1.
2021-12-17 15:28:21 +01:00
youben11
319cc3fd28 fix(python): copy dynamic library into macos wheel 2021-12-16 09:15:25 +01:00
youben11
b812f6f7f2 feat(python): version python package from git tag
automatic detection of version from git tag and update of the python
version file
2021-12-16 09:15:25 +01:00
youben11
aa07d12910 fix(python): add PyYAML as deps 2021-12-15 16:24:35 +01:00
youben11
60b2cfd9b7 feat: support more dtype for scalars/tensors
dtype supported now: uint8, uint16, uint32, uint64
2021-12-13 17:40:28 +01:00
youben11
550318f67e feat: support different numpy object types as input
- Scalar types: int, np.uint8 (to extend with other types later), and np.ndarray with shape == ()
- Tensor types: np.ndarray
2021-12-13 17:40:28 +01:00
rudy
d34792c977 fix(compiler): remove 1 warning (usgined vs signed) 2021-12-13 16:43:35 +01:00
youben11
da8e6c3c0d refactor(python): customize python package build 2021-12-13 16:35:56 +01:00
Andi Drebes
16d0502f56 fix(compiler): Initialize strides of memref parameters when JIT-invoking a function
Upon invocation of a function with memref arguments, the strides for
all dimensions are currently set to 0. This causes dynamic offsets to
be calculated incorrectly in the function body.

This patch replaces the placeholder values with the actual strides for
each dimension and adds a test with parametric slice extraction from a
tensor that triggers dynamic indexing.
2021-12-13 15:20:54 +01:00
Antoniu Pop
bb44124999 feat(dfr): add the DFR (DataFlow Runtime). 2021-12-08 18:35:29 +00:00
youben11
0a7ac76b10 fix: move unique_ptr<T> to be converted to llvm::Expected
gcc 6.3 was complaining about not being able to wrap it in an
llvm::Expected
2021-12-08 17:59:53 +01:00
rudy
74d52cb649 fix(clang): remove an error reported by clang 2021-12-08 11:31:23 +01:00
youben11
58f385b11b fix: move CompilationResult in return
old toolchain (gcc 6.x) was complaining about not being able to convert
CompilationResult to Expected<CompilationResult>
2021-12-07 16:14:44 +01:00
rudy
cc58608589 chore(Lambda): simplify, extract, enhance message for bit width rounding
bit with rounding: 5bit element is widen to a standard 8bit word
2021-12-07 15:29:05 +01:00
rudy
209463be22 chore(Lambda): simplify and extract null parameter detection 2021-12-07 15:29:05 +01:00
rudy
2c56a26c75 fix(Lambda): missing superfluous check in setArg
[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (1513 ms total)
[  PASSED  ] 7 tests.

  YOU HAVE 2 DISABLED TESTS
2021-12-07 15:29:05 +01:00
rudy
47b4b667bb fix(Lambda): #253 fix the bug about Lambda parameter number verification
[----------] Global test environment tear-down
[==========] 6 tests from 1 test suite ran. (1513 ms total)
[  PASSED  ] 6 tests.

  YOU HAVE 3 DISABLED TESTS

Compared to previous commit, a fatal test is disabled
2021-12-07 15:29:05 +01:00
rudy
9a09afaa80 bug(Lambda): #253 reactivate the bug about Lambda parameter number verification
[----------] Global test environment tear-down
[==========] 6 tests from 1 test suite ran. (1327 ms total)
[  PASSED  ] 5 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] Lambda_check_param.scalar_tensor_to_tensor_good_number_param

 1 FAILED TEST
  YOU HAVE 3 DISABLED TESTS
2021-12-07 15:29:05 +01:00
rudy
cc9186d60d feat(tests): test lambda call with bad number of parameters or bad parameters
[----------] Global test environment tear-down
[==========] 6 tests from 1 test suite ran. (1402 ms total)
[  PASSED  ] 6 tests.

  YOU HAVE 3 DISABLED TESTS

2 tests are disabled because execution is fatal
2021-12-07 15:29:05 +01:00
Mayeul@Zama
dad4390518 feat(compiler): add a key cache 2021-12-07 12:11:56 +01:00
Mayeul@Zama
f193fd71a2 fix(compiler): fix mixed-up (g)lwe dimension/size
add dimension -> size conversion
rename k -> glweDimension, polynomialSize -> logPolynomialSize
remove (in/out)putLweSize from KeySwitchLweOp
remove GlweSizeType from LowLFHE
2021-12-07 12:11:56 +01:00
Mayeul@Zama
ec8614f2ea chore(compiler): use ccache if available 2021-12-07 11:35:33 +01:00
Quentin Bourgerie
bb1add2a6f enhance(compiler): Remove the restriction of analysis on the HLFHELinalg.dot
While the manp analysis wasn't handle tensor the dot operation restrict the operands to come from a block argument. Since the tensor are handled in the manp pass this restriction has no more meaning.
2021-12-07 11:17:33 +01:00
youben11
c54af9b550 fix(python): list numpy as a requirement 2021-12-07 09:05:54 +01:00
Andi Drebes
d2b2934f1f test(compiler): Add unit tests for the lowering of HLFHELinalg.zero to linalg 2021-12-02 11:38:44 +01:00
rudy
898e4157cf fix(compiler): --compile should not output IR on stdin 2021-12-02 11:33:42 +01:00
Mayeul@Zama
693a12dce4 fix(tests): use true instead of casted "true" 2021-12-02 11:19:19 +01:00
Quentin Bourgerie
fb58dcc59d enhance(compiler/lowlfhe): Give the runtime context as function argument instead of a global variable (close #195) 2021-12-02 10:56:47 +01:00
Andi Drebes
99fe188e66 fix(tests): Define defaultV0Constraints in a single place
The variable `defaultV0Constraints` is defined in multiple source
files for unit test, but missing in other tests. Put a single, extern
declaration in `globals.h` and the definition in `globals.cc`.
2021-12-02 10:10:53 +01:00
Andi Drebes
6fb907295d feat(compiler): Add lowering for HLFHELinalg.zero to linalg.generate
Add a rewrite pattern that transforms an instance of
`HLFHELinalg.zero` into an instance of `linalg.generate` with an
appropriate region yielding a zero value.

Example:

  %out = "HLFHELinalg.zero"() : () -> tensor<MxNx!HLFHE.eint<p>>

becomes:

  %0 = tensor.generate   {
    ^bb0(%arg2: index, %arg3: index):
       %zero = "HLFHE.zero"() : () -> !HLFHE.eint<p>
       tensor.yield %zero : !HLFHE.eint<p>
  } : tensor<MxNx!HLFHE.eint<p>>
2021-12-01 11:24:27 +01:00
Andi Drebes
bf9a831c3d test(compiler): Add unit tests for HLFHELinalg.zero
Add unit tests for `HLFHELinalg.zero`, including a test for the
integration into the MANP pass.
2021-12-01 11:24:27 +01:00
Andi Drebes
4883eebfa3 feat(compiler): Add HLFHELinalg.zero operation
Add a new operation `HLFHELinalg.zero`, broadcasting an encrypted,
zero-valued integer into a tensor of encrypted integers with static
shape.

Example creating a one-dimensional tensor with five elements all
initialized to an encrypted zero:

  %tensor = "HLFHELinalg.zero"() : () -> tensor<5x!HLFHE.eint<4>>
2021-12-01 11:24:27 +01:00
Andi Drebes
0b151724b8 enhance(compiler): Add support for tensor.generate in lowering pipeline
Operations with regions currently need explicit patterns for type
conversion throughout lowering. This change adds the required patterns
for `tensor.generate` to the lowering passes, such that the operation
can be used starting from the lowering from HLFHE to MidLFHE.
2021-12-01 11:24:24 +01:00
rudy
975ee86a5e feat(compiler): add --compile option
Resolves #196
2021-11-30 17:42:28 +01:00
Quentin Bourgerie
582328a35d cleanup(compiler/passes): Remove some warnings
Remove unused variables in LowLFHEToConcreteCAPI
2021-11-30 16:11:33 +01:00
Quentin Bourgerie
b1e7a66b09 cleanup(compiler/lowlfhe): Remove useless LowLFHE ops and types
Some of these operators/types could be usefull but they are not yet use on the compiler pipeline it's preferable to remove them, and reintroduce if needed.
2021-11-30 16:11:33 +01:00
rudy
ddca6840f1 fix(CompilerEngine): include mlir diagnostic in error message
Resolves #288

example
before:
Failed to lower to LLVM dialect

after:
Failed to lower to LLVM dialect
test.mlir:3:10: error: unexpected error: 'linalg.copy' op expected indexing_map #1 to have 2 dim(s) to match the number of loops
    %0 = tensor.extract_slice %arg0[0, 0] [3, 1] [1, 1] : tensor<3x2x!HLFHE.eint<3>> to tensor<3x!HLFHE.eint<3>>
         ^
2021-11-29 17:15:46 +01:00
Andi Drebes
8c06a5a1b2 enhance(compiler): Replace linalg type converter pattern with generic pattern
Replace `LinalgGenericTypeConverterPattern`, specialized for
`linalg.generic` with a generic type converter pattern
`RegionOpTypeConverterPattern` that can be instantiated for any
operation that has one or more regions.

Further enhancements:
- Supports multiple regions
- Uses more idiomatic instantiations of `llvm::for_each` instead of
  manual iterations using for loops
2021-11-26 17:05:21 +01:00
Mayeul@Zama
94b8070b3f tests(compiler): make FileCheck tests stricter 2021-11-24 14:18:38 +01:00
Quentin Bourgerie
fe6de8f0c5 style(compiler): Formatting 2021-11-24 09:19:25 +01:00
Quentin Bourgerie
ddbafd713d feat(compiler): Add the HLFHELinalg.matmul_int_eint operator 2021-11-24 09:19:25 +01:00
Andi Drebes
ffe32f5e90 fix(compiler): Suppress various warnings about expressions with different signedness 2021-11-19 16:23:15 +01:00
Quentin Bourgerie
ec8387843b cleanup(compiler/test): Fix warning in hlfhelinalg end to end tests about comparaison between signed and unsigned integers 2021-11-17 14:19:15 +01:00
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
c5e3d9add8 fix(compiler): reserve the right amount of memory 2021-11-15 11:25:44 +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
f2b5d3316f fix(compiler): don't try to broadcast when dims are equals with value 1 (7c8399)
Removed due of miss conflict resolution
2021-11-15 09:59:52 +01:00