diff --git a/.gitignore b/.gitignore index 646942e3..989fd784 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ ## Misc .DS_Store .idea +.cache ## Documentation docs/* diff --git a/.gitmodules b/.gitmodules index bf995958..d89b9582 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,6 @@ [submodule "dependencies/llvm-project"] path = dependencies/llvm-project url = https://github.com/llvm/llvm-project.git - shallow = true [submodule "dependencies/SEAL"] path = dependencies/SEAL url = https://github.com/microsoft/SEAL.git diff --git a/README.md b/README.md index c5245138..efd64b29 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Welcome to the Artifact Evaluation version of HECO! HECO is an end-to-end compiler for FHE that takes high-level imperative programs and emits efficient and secure FHE implementations. -Currently, it supports Ring-LWE based schemes [B](https://eprint.iacr.org/2012/078)/[FV](https://eprint.iacr.org/2012/144), [BFV](https://eprint.iacr.org/2011/277) and [CKKS](https://eprint.iacr.org/2016/421) which offer powerful SIMD-like operations and can _batch_ many thousands of values into a single vector-like ciphertext. +Currently, it supports Ring-LWE based schemes [B](https://eprint.iacr.org/2012/078)/[FV](https://eprint.iacr.org/2012/144), [BGV](https://eprint.iacr.org/2011/277) and [CKKS](https://eprint.iacr.org/2016/421) which offer powerful SIMD-like operations and can _batch_ many thousands of values into a single vector-like ciphertext. - [About HECO](#about-heco) - [Using HECO](#using-heco) @@ -262,4 +262,4 @@ Useful command line options for `mlir-opt`/`heco` (see also [MLIR Debugging Tips * `--mlir-print-ir-before-all` - Prints the IR before each pass * `--debug-only=dialect-conversion` - Prints some very useful information on passes and rules being applied * `--verify-each=0` - Turns off the verifier, allowing one to see what the (invalid) IR looks like - * `--allow-unregistered-dialect` - Makes parser accept unknown operations (only works if they are in generic form!) \ No newline at end of file + * `--allow-unregistered-dialect` - Makes parser accept unknown operations (only works if they are in generic form!) diff --git a/evaluation/README.MD b/evaluation/README.MD index fdce4f67..f2fdab24 100644 --- a/evaluation/README.MD +++ b/evaluation/README.MD @@ -7,7 +7,7 @@ The files in this folder can be used to reproduce (the runtime component of) Fig In order to compile the programs from the high-level intermediate representation (HIR) form given here to *.cpp, run the following (assuming your current working directory is the repositoy root): ```sh -./build/bin/heco --full-pass < evaluation/benchmark/heco_input/hammingdistance_4.mlir > evaluation/heco_output/hammingdist_4.mlir +./build/bin/heco --full-pass < evaluation/benchmark/heco_input/hammingdistance_4.mlir > evaluation/benchmark/heco_output/hammingdist_4.mlir ./build/bin/emitc-translate --mlir-to-cpp < evaluation/benchmark/heco_output/hammingdistance_4.mlir > evaluation/heco_output/hammingdist_4.cpp ``` @@ -34,7 +34,7 @@ The files in this folder can be used to reproduce Figure 6 ("Runtime [...] compa In order to compile the programs from the high-level intermediate representation (HIR) form given here to *.cpp, run the following (assuming your current working directory is the repositoy root): ```sh -./build/bin/heco --full-pass < evaluation/comparison/heco_input/hammingdistance_4.mlir > evaluation/heco_output/hammingdist_4.mlir +./build/bin/heco --full-pass < evaluation/comparison/heco_input/hammingdistance_4.mlir > evaluation/comparison/heco_output/hammingdist_4.mlir ./build/bin/emitc-translate --mlir-to-cpp < evaluation/comparison/heco_output/hammingdistance_4.mlir > evaluation/heco_output/hammingdist_4.cpp ``` @@ -68,7 +68,7 @@ The files in this folder can be used to reproduce Table 1 ("Compile time") from MLIR includes utilities for detailed compile time reports, which can be used by passing `-mlir-timing -mlir-timing-display=list` to the compiler. Specifically, to evaluate, e.g., `hammingdist_4.mlir`, you should run the following (assuming your current working directory is the repositoy root): ```sh -./build/bin/heco --full-pass -mlir-timing -mlir-timing-display=list < test/evaluation/hammingdistance_4.mlir +./build/bin/heco --full-pass -mlir-timing -mlir-timing-display=list < evaluation/compile_time/heco_input/hammingdistance_4.mlir ``` In order to avoid needing to compile each HECO input individually, you can instead use a helper script that does this for all files in the heco_input folder (assuming your current working directory is the repositoy root): ```sh diff --git a/evaluation/benchmark/heco_input/robertscross_16x16.mlir b/evaluation/benchmark/heco_input/robertscross_16x16.mlir index 8b74b18b..0187b330 100644 --- a/evaluation/benchmark/heco_input/robertscross_16x16.mlir +++ b/evaluation/benchmark/heco_input/robertscross_16x16.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c16 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c256 : index %20 = tensor.extract %img[%19] : tensor<256x!fhe.secret> diff --git a/evaluation/benchmark/heco_input/robertscross_2x2.mlir b/evaluation/benchmark/heco_input/robertscross_2x2.mlir index dffdfa5e..8cec8ff0 100644 --- a/evaluation/benchmark/heco_input/robertscross_2x2.mlir +++ b/evaluation/benchmark/heco_input/robertscross_2x2.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c2 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c4 : index %20 = tensor.extract %img[%19] : tensor<4x!fhe.secret> diff --git a/evaluation/benchmark/heco_input/robertscross_32x32.mlir b/evaluation/benchmark/heco_input/robertscross_32x32.mlir index 1d158c9a..e3c0665c 100644 --- a/evaluation/benchmark/heco_input/robertscross_32x32.mlir +++ b/evaluation/benchmark/heco_input/robertscross_32x32.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c32 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c1024 : index %20 = tensor.extract %img[%19] : tensor<1024x!fhe.secret> diff --git a/evaluation/benchmark/heco_input/robertscross_4x4.mlir b/evaluation/benchmark/heco_input/robertscross_4x4.mlir index 2ff409f9..d20e0d6c 100644 --- a/evaluation/benchmark/heco_input/robertscross_4x4.mlir +++ b/evaluation/benchmark/heco_input/robertscross_4x4.mlir @@ -31,8 +31,7 @@ module{ // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c4 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c16 : index %20 = tensor.extract %img[%19] : tensor<16x!fhe.secret> diff --git a/evaluation/benchmark/heco_input/robertscross_64x64.mlir b/evaluation/benchmark/heco_input/robertscross_64x64.mlir index 4930b4a2..f20f10ba 100644 --- a/evaluation/benchmark/heco_input/robertscross_64x64.mlir +++ b/evaluation/benchmark/heco_input/robertscross_64x64.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c64 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c4096 : index %20 = tensor.extract %img[%19] : tensor<4096x!fhe.secret> diff --git a/evaluation/benchmark/heco_input/robertscross_8x8.mlir b/evaluation/benchmark/heco_input/robertscross_8x8.mlir index 95c566ec..fad6e10e 100644 --- a/evaluation/benchmark/heco_input/robertscross_8x8.mlir +++ b/evaluation/benchmark/heco_input/robertscross_8x8.mlir @@ -31,8 +31,7 @@ module{ // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c8 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c64 : index %20 = tensor.extract %img[%19] : tensor<64x!fhe.secret> diff --git a/evaluation/benchmark/heco_output/hammingdistance_1024.cpp b/evaluation/benchmark/heco_output/hammingdistance_1024.cpp index ba8ec13c..a4a06804 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_1024.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_1024.cpp @@ -1,7 +1,28 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_1024(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 512); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 256); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 128); + seal::Ciphertext v10 = evaluator_add(v8, v9); + seal::Ciphertext v11 = evaluator_rotate(v10, 64); + seal::Ciphertext v12 = evaluator_add(v10, v11); + seal::Ciphertext v13 = evaluator_rotate(v12, 32); + seal::Ciphertext v14 = evaluator_add(v12, v13); + seal::Ciphertext v15 = evaluator_rotate(v14, 16); + seal::Ciphertext v16 = evaluator_add(v14, v15); + seal::Ciphertext v17 = evaluator_rotate(v16, 8); + seal::Ciphertext v18 = evaluator_add(v16, v17); + seal::Ciphertext v19 = evaluator_rotate(v18, 4); + seal::Ciphertext v20 = evaluator_add(v18, v19); + seal::Ciphertext v21 = evaluator_rotate(v20, 2); + seal::Ciphertext v22 = evaluator_add(v20, v21); + seal::Ciphertext v23 = evaluator_rotate(v22, 1); + seal::Ciphertext v24 = evaluator_add(v22, v23); + seal::Ciphertext v25 = evaluator_rotate(v24, 1022); + return v25; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_1024(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/hammingdistance_16.cpp b/evaluation/benchmark/heco_output/hammingdistance_16.cpp index 40ca4c57..f80c0a69 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_16.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_16.cpp @@ -1,7 +1,16 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_16(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 8); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 4); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 2); + seal::Ciphertext v10 = evaluator_add(v8, v9); + seal::Ciphertext v11 = evaluator_rotate(v10, 1); + seal::Ciphertext v12 = evaluator_add(v10, v11); + seal::Ciphertext v13 = evaluator_rotate(v12, 14); + return v13; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_16(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/hammingdistance_256.cpp b/evaluation/benchmark/heco_output/hammingdistance_256.cpp index e72e01b9..107dcf65 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_256.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_256.cpp @@ -1,7 +1,24 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_256(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 128); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 64); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 32); + seal::Ciphertext v10 = evaluator_add(v8, v9); + seal::Ciphertext v11 = evaluator_rotate(v10, 16); + seal::Ciphertext v12 = evaluator_add(v10, v11); + seal::Ciphertext v13 = evaluator_rotate(v12, 8); + seal::Ciphertext v14 = evaluator_add(v12, v13); + seal::Ciphertext v15 = evaluator_rotate(v14, 4); + seal::Ciphertext v16 = evaluator_add(v14, v15); + seal::Ciphertext v17 = evaluator_rotate(v16, 2); + seal::Ciphertext v18 = evaluator_add(v16, v17); + seal::Ciphertext v19 = evaluator_rotate(v18, 1); + seal::Ciphertext v20 = evaluator_add(v18, v19); + seal::Ciphertext v21 = evaluator_rotate(v20, 254); + return v21; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_256(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/hammingdistance_4.cpp b/evaluation/benchmark/heco_output/hammingdistance_4.cpp index bea3fe82..cac31c08 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_4.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_4.cpp @@ -1,7 +1,12 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_4(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 2); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 1); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 2); + return v9; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_4(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/hammingdistance_4096.cpp b/evaluation/benchmark/heco_output/hammingdistance_4096.cpp index 7f7317bb..e3112ea9 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_4096.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_4096.cpp @@ -1,7 +1,32 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_4096(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 2048); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 1024); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 512); + seal::Ciphertext v10 = evaluator_add(v8, v9); + seal::Ciphertext v11 = evaluator_rotate(v10, 256); + seal::Ciphertext v12 = evaluator_add(v10, v11); + seal::Ciphertext v13 = evaluator_rotate(v12, 128); + seal::Ciphertext v14 = evaluator_add(v12, v13); + seal::Ciphertext v15 = evaluator_rotate(v14, 64); + seal::Ciphertext v16 = evaluator_add(v14, v15); + seal::Ciphertext v17 = evaluator_rotate(v16, 32); + seal::Ciphertext v18 = evaluator_add(v16, v17); + seal::Ciphertext v19 = evaluator_rotate(v18, 16); + seal::Ciphertext v20 = evaluator_add(v18, v19); + seal::Ciphertext v21 = evaluator_rotate(v20, 8); + seal::Ciphertext v22 = evaluator_add(v20, v21); + seal::Ciphertext v23 = evaluator_rotate(v22, 4); + seal::Ciphertext v24 = evaluator_add(v22, v23); + seal::Ciphertext v25 = evaluator_rotate(v24, 2); + seal::Ciphertext v26 = evaluator_add(v24, v25); + seal::Ciphertext v27 = evaluator_rotate(v26, 1); + seal::Ciphertext v28 = evaluator_add(v26, v27); + seal::Ciphertext v29 = evaluator_rotate(v28, 4094); + return v29; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_4096(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/hammingdistance_64.cpp b/evaluation/benchmark/heco_output/hammingdistance_64.cpp index 07177344..1e732f86 100644 --- a/evaluation/benchmark/heco_output/hammingdistance_64.cpp +++ b/evaluation/benchmark/heco_output/hammingdistance_64.cpp @@ -1,7 +1,20 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_64(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 32); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 16); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 8); + seal::Ciphertext v10 = evaluator_add(v8, v9); + seal::Ciphertext v11 = evaluator_rotate(v10, 4); + seal::Ciphertext v12 = evaluator_add(v10, v11); + seal::Ciphertext v13 = evaluator_rotate(v12, 2); + seal::Ciphertext v14 = evaluator_add(v12, v13); + seal::Ciphertext v15 = evaluator_rotate(v14, 1); + seal::Ciphertext v16 = evaluator_add(v14, v15); + seal::Ciphertext v17 = evaluator_rotate(v16, 62); + return v17; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_64(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_16x16.cpp b/evaluation/benchmark/heco_output/robertscross_16x16.cpp index ce4487c4..7d5bd0fd 100644 --- a/evaluation/benchmark/heco_output/robertscross_16x16.cpp +++ b/evaluation/benchmark/heco_output/robertscross_16x16.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_16x16(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 239); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 241); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 17); + seal::Ciphertext v9 = evaluator_rotate(v7, 16); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_16x16(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_16x16.mlir b/evaluation/benchmark/heco_output/robertscross_16x16.mlir index 81b1258d..587f9c00 100644 --- a/evaluation/benchmark/heco_output/robertscross_16x16.mlir +++ b/evaluation/benchmark/heco_output/robertscross_16x16.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_16x16(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 239 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 240 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 241 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 17 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 17 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 16 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/benchmark/heco_output/robertscross_2x2.cpp b/evaluation/benchmark/heco_output/robertscross_2x2.cpp index 3449c2a5..4e3ffe4f 100644 --- a/evaluation/benchmark/heco_output/robertscross_2x2.cpp +++ b/evaluation/benchmark/heco_output/robertscross_2x2.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_2x2(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 1); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 3); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 3); + seal::Ciphertext v9 = evaluator_rotate(v7, 2); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_2x2(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_2x2.mlir b/evaluation/benchmark/heco_output/robertscross_2x2.mlir index 31d3ac5f..adc42746 100644 --- a/evaluation/benchmark/heco_output/robertscross_2x2.mlir +++ b/evaluation/benchmark/heco_output/robertscross_2x2.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_2x2(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 1 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 2 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 2 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/benchmark/heco_output/robertscross_32x32.cpp b/evaluation/benchmark/heco_output/robertscross_32x32.cpp index 818484ba..d63c3904 100644 --- a/evaluation/benchmark/heco_output/robertscross_32x32.cpp +++ b/evaluation/benchmark/heco_output/robertscross_32x32.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_32x32(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 991); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 993); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 33); + seal::Ciphertext v9 = evaluator_rotate(v7, 32); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_32x32(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_32x32.mlir b/evaluation/benchmark/heco_output/robertscross_32x32.mlir index 50a58d35..1002b0b1 100644 --- a/evaluation/benchmark/heco_output/robertscross_32x32.mlir +++ b/evaluation/benchmark/heco_output/robertscross_32x32.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_32x32(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 991 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 992 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 993 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 33 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 33 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 32 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/benchmark/heco_output/robertscross_4x4.cpp b/evaluation/benchmark/heco_output/robertscross_4x4.cpp index 0305e725..fecd5c2b 100644 --- a/evaluation/benchmark/heco_output/robertscross_4x4.cpp +++ b/evaluation/benchmark/heco_output/robertscross_4x4.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_4x4(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 11); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 13); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 5); + seal::Ciphertext v9 = evaluator_rotate(v7, 4); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_4x4(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_4x4.mlir b/evaluation/benchmark/heco_output/robertscross_4x4.mlir index 3367444a..c1e2fd73 100644 --- a/evaluation/benchmark/heco_output/robertscross_4x4.mlir +++ b/evaluation/benchmark/heco_output/robertscross_4x4.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_4x4(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 11 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 12 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 13 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 5 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 5 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 4 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/benchmark/heco_output/robertscross_64x64.cpp b/evaluation/benchmark/heco_output/robertscross_64x64.cpp index 29313256..84c34b85 100644 --- a/evaluation/benchmark/heco_output/robertscross_64x64.cpp +++ b/evaluation/benchmark/heco_output/robertscross_64x64.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_64x64(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 4031); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 4033); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 65); + seal::Ciphertext v9 = evaluator_rotate(v7, 64); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_64x64(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_64x64.mlir b/evaluation/benchmark/heco_output/robertscross_64x64.mlir index a77dfa8d..533d42a6 100644 --- a/evaluation/benchmark/heco_output/robertscross_64x64.mlir +++ b/evaluation/benchmark/heco_output/robertscross_64x64.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_64x64(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4031 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4032 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4033 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 65 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 65 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 64 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/benchmark/heco_output/robertscross_8x8.cpp b/evaluation/benchmark/heco_output/robertscross_8x8.cpp index 300bb879..30ae1271 100644 --- a/evaluation/benchmark/heco_output/robertscross_8x8.cpp +++ b/evaluation/benchmark/heco_output/robertscross_8x8.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_8x8(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 55); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 57); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 9); + seal::Ciphertext v9 = evaluator_rotate(v7, 8); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_8x8(seal::Ciphertext img) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/benchmark/heco_output/robertscross_8x8.mlir b/evaluation/benchmark/heco_output/robertscross_8x8.mlir index b28894f0..89433020 100644 --- a/evaluation/benchmark/heco_output/robertscross_8x8.mlir +++ b/evaluation/benchmark/heco_output/robertscross_8x8.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_8x8(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 55 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 56 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 57 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 9 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 9 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 8 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/comparison/heco_output/boxblur_64x64.cpp b/evaluation/comparison/heco_output/boxblur_64x64.cpp index 6f4b9d04..2d7b5408 100644 --- a/evaluation/comparison/heco_output/boxblur_64x64.cpp +++ b/evaluation/comparison/heco_output/boxblur_64x64.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedBoxBlur_64x64(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 64); + seal::Ciphertext v3 = evaluator_rotate(v1, 65); + seal::Ciphertext v4 = evaluator_rotate(v1, 1); + std::vector v5 = std::vector(); + insert(v5, v1); + insert(v5, v2); + insert(v5, v3); + insert(v5, v4); + seal::Ciphertext v6 = evaluator_add_many(v5); + return v6; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedBoxBlur_64x64(seal::Ciphertext v1) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/dotproduct_8.cpp b/evaluation/comparison/heco_output/dotproduct_8.cpp index fae3e1ca..64494ee6 100644 --- a/evaluation/comparison/heco_output/dotproduct_8.cpp +++ b/evaluation/comparison/heco_output/dotproduct_8.cpp @@ -1,7 +1,11 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedDotProduct_8(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_multiply(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v3, 2); + seal::Ciphertext v5 = evaluator_add(v3, v4); + seal::Ciphertext v6 = evaluator_rotate(v5, 1); + seal::Ciphertext v7 = evaluator_add(v5, v6); + seal::Ciphertext v8 = evaluator_rotate(v7, 3); + return v8; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedDotProduct_8(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/gxkernel_64x64.cpp b/evaluation/comparison/heco_output/gxkernel_64x64.cpp index 1496953c..9fed3e75 100644 --- a/evaluation/comparison/heco_output/gxkernel_64x64.cpp +++ b/evaluation/comparison/heco_output/gxkernel_64x64.cpp @@ -1,7 +1,27 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedGxKernel_64x64(seal::Ciphertext v1) { + int16_t v2 = -2; + int16_t v3 = 2; + int16_t v4 = -1; + seal::Plaintext v5 = evaluator_encode(v2); + seal::Ciphertext v6 = evaluator_multiply_plain(v1, v5); + seal::Plaintext v7 = evaluator_encode(v4); + seal::Ciphertext v8 = evaluator_multiply_plain(v1, v7); + seal::Plaintext v9 = evaluator_encode(v3); + seal::Ciphertext v10 = evaluator_multiply_plain(v1, v9); + seal::Ciphertext v11 = evaluator_rotate(v8, 4095); + seal::Ciphertext v12 = evaluator_rotate(v10, 63); + seal::Ciphertext v13 = evaluator_rotate(v8, 64); + seal::Ciphertext v14 = evaluator_rotate(v1, 65); + seal::Ciphertext v15 = evaluator_rotate(v6, 1); + std::vector v16 = std::vector(); + insert(v16, v11); + insert(v16, v12); + insert(v16, v1); + insert(v16, v13); + insert(v16, v14); + insert(v16, v15); + seal::Ciphertext v17 = evaluator_add_many(v16); + return v17; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedGxKernel_64x64(seal::Ciphertext v1) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/hammingdistance_4.cpp b/evaluation/comparison/heco_output/hammingdistance_4.cpp index bea3fe82..cac31c08 100644 --- a/evaluation/comparison/heco_output/hammingdistance_4.cpp +++ b/evaluation/comparison/heco_output/hammingdistance_4.cpp @@ -1,7 +1,12 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedHammingDistance_4(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 2); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 1); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 2); + return v9; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedHammingDistance_4(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/l2distance_4.cpp b/evaluation/comparison/heco_output/l2distance_4.cpp index 95ac5c77..7c43f6c7 100644 --- a/evaluation/comparison/heco_output/l2distance_4.cpp +++ b/evaluation/comparison/heco_output/l2distance_4.cpp @@ -1,7 +1,12 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedL2Distance_4(seal::Ciphertext v1, seal::Ciphertext v2) { + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_multiply(v3, v3); + seal::Ciphertext v5 = evaluator_rotate(v4, 2); + seal::Ciphertext v6 = evaluator_add(v4, v5); + seal::Ciphertext v7 = evaluator_rotate(v6, 1); + seal::Ciphertext v8 = evaluator_add(v6, v7); + seal::Ciphertext v9 = evaluator_rotate(v8, 2); + return v9; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedL2Distance_4(seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/linearpolynomial_64.cpp b/evaluation/comparison/heco_output/linearpolynomial_64.cpp index 492d3799..02bdcee6 100644 --- a/evaluation/comparison/heco_output/linearpolynomial_64.cpp +++ b/evaluation/comparison/heco_output/linearpolynomial_64.cpp @@ -1,8 +1,8 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedLinearPolynomial_64(seal::Ciphertext v1, seal::Ciphertext v2, seal::Ciphertext v3, seal::Ciphertext v4) { + seal::Ciphertext v5 = evaluator_multiply(v1, v3); + seal::Ciphertext v6 = evaluator_sub(v4, v5); + seal::Ciphertext v7 = evaluator_sub(v6, v2); + return v7; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedLinearPolynomial_64( - seal::Ciphertext a, seal::Ciphertext b, seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/quadraticpolynomial_64.cpp b/evaluation/comparison/heco_output/quadraticpolynomial_64.cpp index 1a3d386e..4241eb32 100644 --- a/evaluation/comparison/heco_output/quadraticpolynomial_64.cpp +++ b/evaluation/comparison/heco_output/quadraticpolynomial_64.cpp @@ -1,8 +1,10 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedQuadraticPolynomial_64(seal::Ciphertext v1, seal::Ciphertext v2, seal::Ciphertext v3, seal::Ciphertext v4, seal::Ciphertext v5) { + seal::Ciphertext v6 = evaluator_multiply(v1, v4); + seal::Ciphertext v7 = evaluator_add(v6, v2); + seal::Ciphertext v8 = evaluator_multiply(v4, v7); + seal::Ciphertext v9 = evaluator_add(v8, v3); + seal::Ciphertext v10 = evaluator_sub(v5, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedQuadraticPolynomial_64( - seal::Ciphertext a, seal::Ciphertext b, seal::Ciphertext c, seal::Ciphertext x, seal::Ciphertext y) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/comparison/heco_output/robertscross_64x64.cpp b/evaluation/comparison/heco_output/robertscross_64x64.cpp index cc7e11d8..5c710958 100644 --- a/evaluation/comparison/heco_output/robertscross_64x64.cpp +++ b/evaluation/comparison/heco_output/robertscross_64x64.cpp @@ -1,7 +1,14 @@ -#include "emitc_helper.h" +seal::Ciphertext encryptedRobertsCross_64x64(seal::Ciphertext v1) { + seal::Ciphertext v2 = evaluator_rotate(v1, 4031); + seal::Ciphertext v3 = evaluator_sub(v1, v2); + seal::Ciphertext v4 = evaluator_rotate(v1, 4032); + seal::Ciphertext v5 = evaluator_sub(v1, v4); + seal::Ciphertext v6 = evaluator_multiply(v3, v3); + seal::Ciphertext v7 = evaluator_multiply(v5, v5); + seal::Ciphertext v8 = evaluator_rotate(v6, 65); + seal::Ciphertext v9 = evaluator_rotate(v7, 65); + seal::Ciphertext v10 = evaluator_add(v8, v9); + return v10; +} + -// Placeholder for compiled function, so that C++ compilation always goes through -seal::Ciphertext encryptedRobertsCross_64x64(seal::Ciphertext v1) -{ - assert(false && "Please compile the HECO inputs to replace this placeholder output."); -} \ No newline at end of file diff --git a/evaluation/compile_time/heco_input/robertscross_16x16.mlir b/evaluation/compile_time/heco_input/robertscross_16x16.mlir index 8b74b18b..0187b330 100644 --- a/evaluation/compile_time/heco_input/robertscross_16x16.mlir +++ b/evaluation/compile_time/heco_input/robertscross_16x16.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c16 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c256 : index %20 = tensor.extract %img[%19] : tensor<256x!fhe.secret> diff --git a/evaluation/compile_time/heco_input/robertscross_2x2.mlir b/evaluation/compile_time/heco_input/robertscross_2x2.mlir index dffdfa5e..8cec8ff0 100644 --- a/evaluation/compile_time/heco_input/robertscross_2x2.mlir +++ b/evaluation/compile_time/heco_input/robertscross_2x2.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c2 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c4 : index %20 = tensor.extract %img[%19] : tensor<4x!fhe.secret> diff --git a/evaluation/compile_time/heco_input/robertscross_32x32.mlir b/evaluation/compile_time/heco_input/robertscross_32x32.mlir index 1d158c9a..e3c0665c 100644 --- a/evaluation/compile_time/heco_input/robertscross_32x32.mlir +++ b/evaluation/compile_time/heco_input/robertscross_32x32.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c32 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c1024 : index %20 = tensor.extract %img[%19] : tensor<1024x!fhe.secret> diff --git a/evaluation/compile_time/heco_input/robertscross_4x4.mlir b/evaluation/compile_time/heco_input/robertscross_4x4.mlir index 2ff409f9..d20e0d6c 100644 --- a/evaluation/compile_time/heco_input/robertscross_4x4.mlir +++ b/evaluation/compile_time/heco_input/robertscross_4x4.mlir @@ -31,8 +31,7 @@ module{ // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c4 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c16 : index %20 = tensor.extract %img[%19] : tensor<16x!fhe.secret> diff --git a/evaluation/compile_time/heco_input/robertscross_64x64.mlir b/evaluation/compile_time/heco_input/robertscross_64x64.mlir index 4930b4a2..f20f10ba 100644 --- a/evaluation/compile_time/heco_input/robertscross_64x64.mlir +++ b/evaluation/compile_time/heco_input/robertscross_64x64.mlir @@ -31,8 +31,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c64 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c4096 : index %20 = tensor.extract %img[%19] : tensor<4096x!fhe.secret> diff --git a/evaluation/compile_time/heco_input/robertscross_8x8.mlir b/evaluation/compile_time/heco_input/robertscross_8x8.mlir index 95c566ec..fad6e10e 100644 --- a/evaluation/compile_time/heco_input/robertscross_8x8.mlir +++ b/evaluation/compile_time/heco_input/robertscross_8x8.mlir @@ -31,8 +31,7 @@ module{ // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c8 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c64 : index %20 = tensor.extract %img[%19] : tensor<64x!fhe.secret> diff --git a/evaluation/compile_time/heco_output/robertscross_16x16.mlir b/evaluation/compile_time/heco_output/robertscross_16x16.mlir index 81b1258d..587f9c00 100644 --- a/evaluation/compile_time/heco_output/robertscross_16x16.mlir +++ b/evaluation/compile_time/heco_output/robertscross_16x16.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_16x16(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 239 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 240 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 241 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 17 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 17 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 16 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/compile_time/heco_output/robertscross_2x2.mlir b/evaluation/compile_time/heco_output/robertscross_2x2.mlir index 31d3ac5f..adc42746 100644 --- a/evaluation/compile_time/heco_output/robertscross_2x2.mlir +++ b/evaluation/compile_time/heco_output/robertscross_2x2.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_2x2(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 1 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 2 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 3 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 2 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/compile_time/heco_output/robertscross_32x32.mlir b/evaluation/compile_time/heco_output/robertscross_32x32.mlir index 50a58d35..1002b0b1 100644 --- a/evaluation/compile_time/heco_output/robertscross_32x32.mlir +++ b/evaluation/compile_time/heco_output/robertscross_32x32.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_32x32(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 991 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 992 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 993 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 33 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 33 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 32 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/compile_time/heco_output/robertscross_4x4.mlir b/evaluation/compile_time/heco_output/robertscross_4x4.mlir index 3367444a..c1e2fd73 100644 --- a/evaluation/compile_time/heco_output/robertscross_4x4.mlir +++ b/evaluation/compile_time/heco_output/robertscross_4x4.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_4x4(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 11 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 12 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 13 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 5 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 5 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 4 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/compile_time/heco_output/robertscross_64x64.mlir b/evaluation/compile_time/heco_output/robertscross_64x64.mlir index a77dfa8d..533d42a6 100644 --- a/evaluation/compile_time/heco_output/robertscross_64x64.mlir +++ b/evaluation/compile_time/heco_output/robertscross_64x64.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_64x64(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4031 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4032 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 4033 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 65 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 65 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 64 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/evaluation/compile_time/heco_output/robertscross_8x8.mlir b/evaluation/compile_time/heco_output/robertscross_8x8.mlir index b28894f0..89433020 100644 --- a/evaluation/compile_time/heco_output/robertscross_8x8.mlir +++ b/evaluation/compile_time/heco_output/robertscross_8x8.mlir @@ -2,12 +2,12 @@ module { func.func private @encryptedRobertsCross_8x8(%arg0: !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> { %0 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 55 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %1 = emitc.call "evaluator_sub"(%arg0, %0) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 56 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %2 = emitc.call "evaluator_rotate"(%arg0) {args = [0 : index, 57 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %3 = emitc.call "evaluator_sub"(%arg0, %2) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %4 = emitc.call "evaluator_multiply"(%1, %1) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %5 = emitc.call "evaluator_multiply"(%3, %3) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %6 = emitc.call "evaluator_rotate"(%4) {args = [0 : index, 9 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> - %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 9 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> + %7 = emitc.call "evaluator_rotate"(%5) {args = [0 : index, 8 : si32]} : (!emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> %8 = emitc.call "evaluator_add"(%6, %7) : (!emitc.opaque<"seal::Ciphertext">, !emitc.opaque<"seal::Ciphertext">) -> !emitc.opaque<"seal::Ciphertext"> return %8 : !emitc.opaque<"seal::Ciphertext"> } diff --git a/test/filecheck/robertscross/robertscross_1_ssa.mlir b/test/filecheck/robertscross/robertscross_1_ssa.mlir index c204866e..3315d986 100644 --- a/test/filecheck/robertscross/robertscross_1_ssa.mlir +++ b/test/filecheck/robertscross/robertscross_1_ssa.mlir @@ -32,8 +32,7 @@ module { // fetch img[x-1][y] %15 = arith.addi %x, %c-1 : index %16 = arith.muli %15, %c8 : index - %17 = arith.addi %y, %c-1 : index - %18 = arith.addi %16, %17 : index + %18 = arith.addi %16, %y : index %19 = arith.remui %18, %c64 : index %20 = tensor.extract %img[%19] : tensor<64x!fhe.secret>