Commit Graph

3428 Commits

Author SHA1 Message Date
Umut
2515e9bf8a feat(script): replace '&' with 'and' within benchmark target names 2021-10-05 12:14:12 +03:00
Umut
b93e916b1c docs(user): create printing and drawing howto 2021-10-04 12:23:37 +03:00
Umut
003bad581a feat(fhe_circuit): create FHECircuit class to combine operation graph and compiler engine 2021-10-04 12:23:37 +03:00
Arthur Meyre
6fc6991839 chore: add __version__ and automated tools to update it
- also add a checker to verify that versions are in sync
2021-10-04 09:40:10 +02:00
Umut
edcbc0cffd fix: select correct parameters for dequantization after evaluation in logistic regression benchmark 2021-09-30 12:52:48 +03:00
Arthur Meyre
a9d44f4758 feat(float_fusing): restrict to scalars before supporting tensors 2021-09-30 10:57:00 +02:00
Benoit Chevallier-Mames
42d5b66b69 fix: better test. 2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
3d6baf4101 fix: fix the type 2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
7ea39fb77d fix: clear comments 2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
e67e19ab4f fix: comments. 2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
2b7fe094d2 feat: adding management of numpy.sign and numpy.signbit
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
406043575a feat: adding management of numpy.reciprocal
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
c52032c285 feat: adding management of numpy.positive
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
2638ba59ac feat: adding management of numpy.negative
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
4adb0eb18e feat: adding management of numpy.isfinite, numpy.isinf, numpy.isnan
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
ab7cf24285 fix: pylint. 2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
ddf08eb273 feat: adding management of numpy.square
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
2351730cee feat: adding management of numpy.absolute
refs #126
2021-09-30 10:47:27 +02:00
Benoit Chevallier-Mames
0a758ed672 test: change a bit the way we test
to prepare modifications for more ufunc
refs #126
2021-09-30 10:47:27 +02:00
Umut
bd95714c23 feat: add more metrics to linear regression benchmark 2021-09-29 17:56:19 +03:00
Umut
c47dac833b refactor: replace scalars with () shaped tensors, disable python list support in inputset 2021-09-29 17:55:58 +03:00
Arthur Meyre
f97682bd23 fix(build): convert string to boolean to avoid bug in workflow 2021-09-29 15:02:52 +02:00
Arthur Meyre
10be75f094 chore(build): manage latest tag push for releases
- no push for release candidates
- push as latest if version is the highest
2021-09-29 14:41:37 +02:00
Arthur Meyre
456df69f0b fix(build): change commit conformance check
- action fails if the even is not of a supported type, only check for PR
2021-09-29 14:04:56 +02:00
Mayeul@Zama
cb0e8b0e98 doc(compiler): update the instructions to build and test the compiler in the README 2021-09-29 11:16:05 +02:00
Umut
4ef0a13248 refactor: move measurement scripts to their own directory to avoid pcc errors 2021-09-29 11:51:22 +03:00
Umut
bc80f0de10 refactor: fix new pylint warnings 2021-09-29 11:51:08 +03:00
Umut
36d732b0ae refactor: rename 'data_type' field of 'BaseValue' to 'dtype' 2021-09-29 11:51:08 +03:00
Umut
77690fed84 fix: generalize error message for unsupported functions 2021-09-29 11:51:08 +03:00
Umut
c0fa302708 fix: remove double assignment on mlir converter 2021-09-29 11:51:08 +03:00
Umut
e6bdd52f4d fix: remove additional newline on exported graph descriptions 2021-09-29 11:51:08 +03:00
Arthur Meyre
13ccf7a046 chore(build): add commit format checks
- refactor the way conformance is done
- run all conformance checks and aggregate the results in a single step
2021-09-28 14:15:25 +02:00
Andi Drebes
2acfa63eb7 feat(compiler): Determine FHE circuit constraints instead of using default values
This replaces the default FHE circuit constrains (maximum encrypted
integer width of 7 bits and a Minimal Arithmetic Noise Padding of 10
with the results of the `MaxMANP` pass, which determines these values
automatically from the input program.

Since the maximum encrypted integer width and the maximum value for
the Minimal Arithmetic Noise Padding can only be derived from HLFHE
operations, the circuit constraints are determined automatically by
`zamacompiler` only if the option `--entry-dialect=hlfhe` was
specified.

For lower-level dialects, `zamacompiler` has been provided with the
options `--assume-max-eint-precision=...` and `--assume-max-manp=...`
that allow a user to specify the values for the maximum required
precision and maximum values for the Minimal Arithmetic Noise Padding.
2021-09-28 11:35:58 +02:00
Andi Drebes
2ed1720234 bugfix(compiler): Do not apply offset of -1 to 2-norm in getV0Parameter
A value of 1 is perfectly valid for the 2-norm of the constant vector
of a dot operation. Hence, the log2 of that value of 0 is also
perfectly valid. However, the offset of -1 in `getV0Parameter` applied
to that value yields an offset into a static lookup table of -1, which
triggers a segmentation fault.

This patch removes the offset of -1 for the log2 value of the 2-norm
in `getV0Parameter`.
2021-09-28 11:35:58 +02:00
Andi Drebes
5ce3fd5f43 refactor(compiler): Move ceilLog2 to separate header file 2021-09-28 11:35:58 +02:00
Andi Drebes
1200a46e49 feat(compiler): Add HLFHE pass selecting maximum MANP and encrypted integer width
This pass calculates the squared Minimal Arithmetic Noise Padding
(MANP) for each operation using the MANP pass and extracts the maximum
(non-squared) Minimal Arithmetic Noise Padding and the maximum
ecrypted integer width from.
2021-09-28 11:35:58 +02:00
Andi Drebes
6a6fae96f6 test(compiler): Add tests for the Minimal Arithmetic Noise Padding analysis pass
This adds tests for the Minimal Arithmetic Noise Padding analysis pass
that is invoked with --debug-manp, testing both elementary operations
and DAGs of computations on encrypted integers.
2021-09-28 11:35:58 +02:00
Andi Drebes
54661528a8 feat(compiler): Add action dump-hlfhe-manp
The new option --acion=dump-hlfhe-manp invokes the Minimal Arithmetic
Noise Padding Analysis pass based on the squared 2-norm metric from
`lib/Dialect/HLFHE/Analysis/MANP.cpp` and dumps the module afterwards
with an extra attribute `MANP` for each HLFHE operation.
2021-09-28 11:35:58 +02:00
Andi Drebes
ed762942c1 feat(compiler): Add pass for Minimal Arithmetic Noise Padding
This pass calculates the squared Minimal Arithmetic Noise Padding
(MANP) for each operation of a function and stores the result in an
integer attribute named "sqMANP". This metric is identical to the
squared 2-norm of the constant vector of an equivalent dot product
between a vector of encrypted integers resulting directly from an
encryption and a vector of plaintext constants.

The pass supports the following operations:

 - HLFHE.dot_eint_int
 - HLFHE.zero
 - HLFHE.add_eint_int
 - HLFHE.add_eint
 - HLFHE.sub_int_eint
 - HLFHE.mul_eint_int
 - HLFHE.apply_lookup_table

If any other operation is encountered, the pass conservatively
fails. The pass further makes the optimistic assumption that all
values passed to a function are either the direct result of an
encryption of a noise-refreshing operation.
2021-09-28 11:35:58 +02:00
Andi Drebes
30374ebb2c refactor(compiler): Introduce compilation pipeline with multiple entries / exits
This refactoring commit restructures the compilation pipeline of
`zamacompiler`, such that it is possible to enter and exit the
pipeline at different points, effectively defining the level of
abstraction at the input and the required level of abstraction for the
output.

The entry point is specified using the `--entry-dialect`
argument. Valid choices are:

  `--entry-dialect=hlfhe`:   Source contains HLFHE operations
  `--entry-dialect=midlfhe`: Source contains MidLFHE operations
  `--entry-dialect=lowlfhe`: Source contains LowLFHE operations
  `--entry-dialect=std`:     Source does not contain any FHE Operations
  `--entry-dialect=llvm`:    Source is in LLVM dialect

The exit point is defined by an action, specified using --action.

  `--action=roundtrip`:
     Parse the source file to in-memory representation and immediately
     dump as text without any processing

  `--action=dump-midlfhe`:
     Lower source to MidLFHE and dump result as text

  `--action=dump-lowlfhe`:
     Lower source to LowLFHE and dump result as text

  `--action=dump-std`:
     Lower source to only standard MLIR dialects (i.e., all FHE
     operations have already been lowered)

  `--action=dump-llvm-dialect`:
     Lower source to MLIR's LLVM dialect (i.e., the LLVM dialect, not
     LLVM IR)

  `--action=dump-llvm-ir`:
     Lower source to plain LLVM IR (i.e., not the LLVM dialect, but
     actual LLVM IR)

  `--action=dump-optimized-llvm-ir`:
     Lower source to plain LLVM IR (i.e., not the LLVM dialect, but
     actual LLVM IR), pass the result through the LLVM optimizer and
     print the result.

  `--action=dump-jit-invoke`:
     Execute the full lowering pipeline to optimized LLVM IR, JIT
     compile the result, invoke the function specified in
     `--jit-funcname` with the parameters from `--jit-args` and print
     the functions return value.
2021-09-28 11:35:58 +02:00
Andi Drebes
ddebedd1d6 refactor(compiler): Make function getV0Parameter return a pointer to a constant
The function `getV0Parameter()` returns a pointer to a static array,
which is not intended to be mutable. Reflect this in the return type
of the function.
2021-09-28 11:35:58 +02:00
Andi Drebes
6a76177a47 refactor(compiler): Move JIT functionality to separate source file 2021-09-28 11:35:58 +02:00
Andi Drebes
b9e2690823 refactor(compiler): Replace LOG_{VERBOSE,ERROR} macros with C++-style streams
Replace the macros `LOG_VERBOSE` and `LOG_ERROR` with C++-style
streams retrieved through `log_verbose()` and `log_error()`. This
aligns with the `MLIR` infrastructure and avoids pollution of the
global namespace through a common header file in subsequent
refactoring commits splitting the functionality of `src/main.cpp` into
multiple files.
2021-09-28 11:35:58 +02:00
Benoit Chevallier-Mames
95c6bcc6a3 test: add x * y in benchmark, does not compile
refs #471
2021-09-28 10:24:28 +02:00
Benoit Chevallier-Mames
b3ffb45a1d test: add x * 7 in benchmark, compiles
refs #471
2021-09-28 10:24:28 +02:00
Benoit Chevallier-Mames
312a30a4b5 test: add 124 - x in benchmark, compiles
refs #471
2021-09-28 10:24:28 +02:00
Benoit Chevallier-Mames
b94c0e7959 test: add x - y in benchmark, doesn't compile
refs #471
2021-09-28 10:24:28 +02:00
Benoit Chevallier-Mames
3a13c0b894 test: add x - 24 in benchmark, doesn't compile
refs #471
2021-09-28 10:24:28 +02:00
Umut
ad95aba053 chore: run extract_machine_info.py before running the benchmark target, fix missing MACHINE_NAME variable exception 2021-09-27 17:59:48 +03:00
Umut
3408bba1ed fix: properly ignore measurement scripts during benchmarks 2021-09-27 17:59:48 +03:00