Commit Graph

113 Commits

Author SHA1 Message Date
Quentin Bourgerie
acbb5bf17a cleanup(compiler): Remove custom print and parse TFHE types 2022-06-24 11:00:08 +02:00
Quentin Bourgerie
9dd776533a cleanup(compiler): Remove useless concrete types, simplify print and parse, and remove BConcreteToBConcreteCAPI pass 2022-06-24 11:00:08 +02:00
Andi Drebes
3b8ea630a1 refactor(compiler): Rename SubIntGLWEOp to SubGLWEIntOp
Rename `SubIntGLWEOp` to `SubGLWEIntOp` for a consistent naming scheme
of all TFHE ops.
2022-06-14 14:36:28 +02:00
Andi Drebes
45577fb79e Rebase onto llvm-project f69328049e9e with local changes
This commit rebases the compiler onto commit f69328049e9e from
llvm-project.

Changes:

* Use of the one-shot bufferizer for improved memory management

* A new pass `OneShotBufferizeDPSWrapper` that converts functions
  returning tensors to destination-passing-style as required by the
  one-shot bufferizer

* A new pass `LinalgGenericOpWithTensorsToLoopsPass` that converts
  `linalg.generic` operations with value semantics to loop nests

* Rebase onto a fork of llvm-project at f69328049e9e with local
  modifications to enable bufferization of `linalg.generic` operations
  with value semantics

* Workaround for the absence of type propagation after type conversion
  via extra patterns in all dialect conversion passes

* Printer, parser and verifier definitions moved from inline
  declarations in ODS to the respective source files as required by
  upstream changes

* New tests for functions with a large number of inputs

* Increase the number of allowed task inputs as required by new tests

* Use upstream function `mlir_configure_python_dev_packages()` to
  locate Python development files for compatibility with various CMake
  versions

Co-authored-by: Quentin Bourgerie <quentin.bourgerie@zama.ai>
Co-authored-by: Ayoub Benaissa <ayoub.benaissa@zama.ai>
Co-authored-by: Antoniu Pop <antoniu.pop@zama.ai>
2022-06-14 14:35:25 +02:00
youben11
670af02112 fix: remove subinteint folder
it actually requires to negate the result which can't be done via
standard folder, so we remove it can cause erroneous computation
2022-06-14 10:00:01 +02:00
youben11
1354759884 chore: rename refs to main branch 2022-06-09 09:19:06 +01:00
youben11
8d0f20390c feat: optimize concrete mul with constant values 2022-06-01 14:35:12 +01:00
youben11
8d04c1e4af feat: fold tensor ops with constant values
add/sub with constant tensors of 0s
mul with constant tensors of 1s
2022-05-30 08:35:14 +01:00
youben11
8aa6f3e809 feat: fold add/sub/mul with specific constant values
Remove add/sub with constant zero values
Remove mul with constant one values
2022-05-30 08:35:14 +01:00
Quentin Bourgerie
ae9a04cd56 fix(compiler): Use the absolute value when computing the square of a constant in MANP analysis
The computation of the norm2 should take care of the sign of the constant to compute the square of this constant.
2022-05-24 14:12:28 +02:00
Quentin Bourgerie
35d8489b9c fix(compiler/TFHE): Introduce bootstrap and keyswitch at the TFHE level 2022-04-12 09:37:56 +02:00
Antoniu Pop
d40ae16273 fix(compiler): make task work functions unique even across separate translation units. 2022-04-11 15:05:22 +01:00
Mayeul@Zama
b76839b8c9 fix(cmake): fix cmake dependencies 2022-03-30 17:20:20 +02:00
Mayeul@Zama
9ccced7d93 fix(cmake): unify tablegen headers generation dependencies 2022-03-30 17:20:20 +02:00
Quentin Bourgerie
254b4dc530 enhance(compiler): Enable deallocation pass to free temporary buffers 2022-03-28 09:41:54 +02:00
youben11
4e64b9e12a feat: support FHELinalg.transpose in MANP 2022-03-24 16:04:57 +01:00
youben11
3a4723a0b8 feat: add FHELinalg.transpose operation 2022-03-24 16:04:57 +01:00
Quentin Bourgerie
8961be33d2 fix(compiler): Remove the 7bits restriction on compiler side, it's the optimizer that known the truth 2022-03-22 12:38:58 +01:00
Umut
d06e0c0a59 feat: enhance matmul operation to support 1-D and N-D inputs 2022-03-01 18:06:40 +03:00
youben11
6d2f853c07 feat: support Conv2d in MANP 2022-02-24 09:44:26 +01:00
youben11
3668b2d73a feat: add a Conv2d operation in FHELinalg 2022-02-24 09:44:26 +01:00
youben11
78596f899f feat: add generated linalg conv operation
This has been generated using linalg tools, then put in their
appropriate locations. This is intended as a workaround since linalg
doesn't support tensors of custom types yet. Any conversion using this
added operation should be able to use the default operation from linalg
when it starts supporting tensor of custom types.
2022-02-24 09:44:26 +01:00
Quentin Bourgerie
b3368027d0 refactor(compiler): Move FHELinalg.zero to FHE.zero_tensor and add zero and sero_tensor in TFHE and Concrete dialects 2022-02-17 15:53:23 +01:00
Quentin Bourgerie
1f3944047f feature(compiler): Introduce the BConcrete Dialect 2022-02-17 15:53:23 +01:00
Umut
20a89b7b42 feat: implement concat operation 2022-02-15 16:52:07 +03:00
Umut
a1818a3fd9 feat: implement advanced sum operation 2022-02-08 17:49:58 +03:00
Umut
4203e86998 feat: implement basic sum operation 2022-02-01 12:18:56 +03:00
Umut
8198a79deb feat: introduce maximum bit width constant, use it where appropriate, export it in python bindings 2022-01-24 17:26:37 +03:00
Andi Drebes
7062052ca6 fix(compiler): Remove unused variables in lib/Dialect/TFHE/IR/TFHEOps.cpp 2022-01-07 12:03:13 +01:00
Andi Drebes
ce9d86014d fix(compiler): Force same signedness of integers in _verifyGLWEIntegerOperator 2022-01-07 12:03:13 +01:00
Andi Drebes
d83a462e20 fix(compiler): Fix initialization order in constructor of MaxMANPPass 2022-01-07 12:03:13 +01:00
Andi Drebes
0b73586178 fix(compiler): Fix initialization order in constructor of MANPAnalysis 2022-01-07 12:03:13 +01:00
Andi Drebes
258480dab6 fix(compiler): Remove unused variable in lib/Dialect/FHE/Analysis/MANP.cpp 2022-01-07 12:03:13 +01:00
Andi Drebes
94f160eef1 fix(compiler): Remove unused variables in lib/Dialect/FHE/IR/FHEOps.cpp 2022-01-07 12:03:13 +01:00
Quentin Bourgerie
4ecae140ca doc(compiler): Enhance FHE Dialect documentation 2022-01-06 18:07:19 +01:00
youben11
2009ee1c94 chore: changing ref to repo after its renaming
also formatting and update the check_license script to match that
2022-01-06 12:40:10 +01:00
youben11
f1161f7f6d chore: formatting
Quick fix due to ordering of includes, had to add #include
<mlir/Transforms/DialectConversion.h> to include/concretelang/Conversion/Utils/GenericOpTypeConversionPattern.h
2022-01-03 09:29:19 +01:00
youben11
940cb96be4 chore: rename dialects
HLFHE to FHE
MidLFHE to TFHE
LowLFHE to Concrete
2021-12-29 15:13:34 +01:00
youben11
e73291abdc chore: rename compiler to concrete-compiler
zamalang => concretelang
zamacompiler => concretecompiler
2021-12-29 15:13:34 +01:00
youben11
971cb56182 chore: licensing 2021-12-29 15:13:34 +01:00
rudy
d8fee32cea feat(HLFHELinalg): add apply_mapped_table_lookup
Resolves #182
2021-12-27 15:34:33 +01:00
Antoniu Pop
cdca7ca6f7 feat(compiler): add Dataflow/RT dialect and code generation for dataflow auto parallelization. 2021-12-23 15:57:53 +00:00
Quentin Bourgerie
db683f4a0e feat(compiler/runtime): Introduce a RT dialect 2021-12-23 15:57:53 +00:00
rudy
5ed2dcb3c1 fix(compiler): MANP segfault bug in case of missing MANP value 2021-12-20 10:40:58 +01:00
Andi Drebes
f319ba37d2 feat(compiler): Integrate HLFHELinalg tiling passes into compilation pipeline 2021-12-17 16:09:59 +01:00
Andi Drebes
bc75831c86 feat(compiler): Add passes for tiling of HLFHELinalg.matmul_eint_int
Add two passes related to the tiling of `HLFHELinalg.matmul_eint_int`
operations.

The `HLFHELinalgTilingMarker` pass takes a vector of tile sizes and
adds an integer array attribute "tile-sizes" to each instance of
`HLFHELinalg.matmul_eint_int`, e.g.,

  "HLFHELinalg.matmul_eint_int"(%arg0, %arg1) {"tile-sizes" = [2, 2, 2]} :
    (tensor<4x2x!HLFHE.eint<6>>, tensor<2x2xi7>) -> tensor<4x2x!HLFHE.eint<6>>

The `HLFHELinalgTiling` performs the actual tiling of each
`HLFHELinalg.matmul_eint_int` operation marked with a "tile-sizes"
attribute. The tiling preserves the level of abstraction of
HLFHELinalg and is implemented as a perfect loop nest of SCF for loops
with a `HLFHELinalg.matmul_eint_int` in the body.

For example,

  func @main(%arg0: tensor<4x2x!HLFHE.eint<6>>, %arg1: tensor<2x2xi7>)
    -> tensor<4x2x!HLFHE.eint<6>>
  {
    %0 = "HLFHELinalg.matmul_eint_int"(%arg0, %arg1) {"tile-sizes" = [2, 2, 2]} :
           (tensor<4x2x!HLFHE.eint<6>>, tensor<2x2xi7>) -> tensor<4x2x!HLFHE.eint<6>>
    return %0 : tensor<4x2x!HLFHE.eint<6>>
  }

becomes:

  func @main(%arg0: tensor<4x2x!HLFHE.eint<6>>, %arg1: tensor<2x2xi7>)
    -> tensor<4x2x!HLFHE.eint<6>>
  {
    %c2 = arith.constant 2 : index
    %c0 = arith.constant 0 : index
    %c4 = arith.constant 4 : index

    %0 = "HLFHELinalg.zero"() : () -> tensor<4x2x!HLFHE.eint<6>>
    %1 = scf.for %arg2 = %c0 to %c4 step %c2 iter_args(%arg3 = %0)
           -> (tensor<4x2x!HLFHE.eint<6>>) {
      %2 = scf.for %arg4 = %c0 to %c2 step %c2 iter_args(%arg5 = %arg3)
             -> (tensor<4x2x!HLFHE.eint<6>>) {
        %3 = scf.for %arg6 = %c0 to %c2 step %c2 iter_args(%arg7 = %arg5)
	       -> (tensor<4x2x!HLFHE.eint<6>>) {
          %4 = tensor.extract_slice %arg0[%arg2, %arg4] [2, 2] [1, 1] :
	         tensor<4x2x!HLFHE.eint<6>> to tensor<2x2x!HLFHE.eint<6>>
          %5 = tensor.extract_slice %arg1[%arg4, %arg6] [2, 2] [1, 1] :
	         tensor<2x2xi7> to tensor<2x2xi7>
          %6 = tensor.extract_slice %arg7[%arg2, %arg6] [2, 2] [1, 1] :
	         tensor<4x2x!HLFHE.eint<6>> to tensor<2x2x!HLFHE.eint<6>>

          %7 = "HLFHELinalg.matmul_eint_int"(%4, %5) :
	         (tensor<2x2x!HLFHE.eint<6>>, tensor<2x2xi7>)
		 -> tensor<2x2x!HLFHE.eint<6>>

          %8 = "HLFHELinalg.add_eint"(%6, %7) :
	         (tensor<2x2x!HLFHE.eint<6>>, tensor<2x2x!HLFHE.eint<6>>)
		 -> tensor<2x2x!HLFHE.eint<6>>

          %9 = tensor.insert_slice %8 into %arg7[%arg2, %arg6] [2, 2] [1, 1] :
	         tensor<2x2x!HLFHE.eint<6>> into tensor<4x2x!HLFHE.eint<6>>

          scf.yield %9 : tensor<4x2x!HLFHE.eint<6>>
        }
        scf.yield %3 : tensor<4x2x!HLFHE.eint<6>>
      }
      scf.yield %2 : tensor<4x2x!HLFHE.eint<6>>
    }
    return %1 : tensor<4x2x!HLFHE.eint<6>>
  }

Only full tiles are supported, i.e., the size of the dimensions of the
operands must be a multiple of the respective tile sizes.
2021-12-17 16:09:59 +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
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
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
Quentin Bourgerie
ddbafd713d feat(compiler): Add the HLFHELinalg.matmul_int_eint operator 2021-11-24 09:19:25 +01:00