From f154d03d5f41bb1c9daf13bccc23ff6000bc2eb7 Mon Sep 17 00:00:00 2001 From: Umut Date: Tue, 30 Apr 2024 15:02:22 +0300 Subject: [PATCH] fix(compiler): use exact passes on check tests to avoid reordering when new passes are introduced --- .../Conversion/FHEToTFHECrt/add_eint.mlir | 2 +- .../Conversion/FHEToTFHECrt/add_eint_int.mlir | 2 +- .../Conversion/FHEToTFHECrt/conv2d.mlir | 99 ------------------- .../Conversion/FHEToTFHECrt/mul_eint_int.mlir | 2 +- .../Conversion/FHEToTFHECrt/neg_eint.mlir | 2 +- .../Conversion/FHEToTFHECrt/sub_int_eint.mlir | 2 +- .../FHEToTFHEScalar/add_eint_int.mlir | 2 +- .../Conversion/FHEToTFHEScalar/conv2d.mlir | 66 ------------- .../Conversion/FHEToTFHEScalar/lsb.mlir | 6 +- .../FHEToTFHEScalar/mul_eint_int.mlir | 2 +- .../FHEToTFHEScalar/sub_int_eint.mlir | 2 +- 11 files changed, 11 insertions(+), 176 deletions(-) delete mode 100644 compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/conv2d.mlir delete mode 100644 compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/conv2d.mlir diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint.mlir index 7669e7ac00..3683dd21a2 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s +// RUN: concretecompiler --optimize-tfhe=false --passes fhe-to-tfhe-crt --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s //CHECK: func.func @add_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe>, %[[Varg1:.*]]: tensor<5x!TFHE.glwe>) -> tensor<5x!TFHE.glwe> { //CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe> diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint_int.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint_int.mlir index 2730972614..599e735b7d 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint_int.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/add_eint_int.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s +// RUN: concretecompiler --optimize-tfhe=false --passes fhe-to-tfhe-crt --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s // CHECK: func.func @add_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe>) -> tensor<5x!TFHE.glwe> { // CHECK-NEXT: %[[Vc1_i8:.*]] = arith.constant 1 : i8 diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/conv2d.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/conv2d.mlir deleted file mode 100644 index 284ecc4bc1..0000000000 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/conv2d.mlir +++ /dev/null @@ -1,99 +0,0 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s - -//CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x5x!TFHE.glwe>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x5x!TFHE.glwe> { -//CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vc100:.*]] = arith.constant 100 : index -//CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index -//CHECK-NEXT: %[[Vc4:.*]] = arith.constant 4 : index -//CHECK-NEXT: %[[Vc15:.*]] = arith.constant 15 : index -//CHECK-NEXT: %[[Vc3:.*]] = arith.constant 3 : index -//CHECK-NEXT: %[[Vc14:.*]] = arith.constant 14 : index -//CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg2]]{{\[}}%[[Varg5]]{{\]}} : tensor<4xi3> -//CHECK-NEXT: %[[Vc0_0:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe> to tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[V6:.*]] = arith.extsi %[[Vextracted]] : i3 to i64 -//CHECK-NEXT: %[[V7:.*]] = "TFHE.encode_plaintext_with_crt"(%[[V6]]) {mods = {{\[2, 3, 5, 7, 11\], modsProd}} = 2310 : i64} : (i64) -> tensor<5xi64> -//CHECK-NEXT: %[[V8:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vc0_1:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vc1_2:.*]] = arith.constant 1 : index -//CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index -//CHECK-NEXT: %[[V9:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0_1]] to %[[Vc5]] step %[[Vc1_2]] iter_args(%[[Varg12:.*]] = %[[V8]]) -> (tensor<5x!TFHE.glwe>) { -//CHECK-NEXT: %[[Vextracted_4:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vextracted_5:.*]] = tensor.extract %[[V7]]{{\[}}%[[Varg11]]{{\]}} : tensor<5xi64> -//CHECK-NEXT: %[[V10:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_4]], %[[Vextracted_5]]) : (!TFHE.glwe, i64) -> !TFHE.glwe -//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V10]] into %[[Varg12]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: %[[Vc0_3:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V9]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_3]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe> into tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x5x!TFHE.glwe>) { -//CHECK-NEXT: %[[V9:.*]] = affine.apply #map(%[[Varg7]], %[[Varg13]]) -//CHECK-NEXT: %[[V10:.*]] = affine.apply #map(%[[Varg9]], %[[Varg15]]) -//CHECK-NEXT: %[[Vc0_0:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x3x28x28x5x!TFHE.glwe> to tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg1]]{{\[}}%[[Varg5]], %[[Varg11]], %[[Varg13]], %[[Varg15]]{{\]}} : tensor<4x3x14x14xi3> -//CHECK-NEXT: %[[Vc0_1:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vextracted_slice_2:.*]] = tensor.extract_slice %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_1]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe> to tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[V11:.*]] = arith.extsi %[[Vextracted]] : i3 to i64 -//CHECK-NEXT: %[[V12:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vc0_3:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vc1_4:.*]] = arith.constant 1 : index -//CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index -//CHECK-NEXT: %[[V13:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_3]] to %[[Vc5]] step %[[Vc1_4]] iter_args(%[[Varg18:.*]] = %[[V12]]) -> (tensor<5x!TFHE.glwe>) { -//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[V16:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted_9]], %[[V11]]) : (!TFHE.glwe, i64) -> !TFHE.glwe -//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: %[[V14:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vc0_5:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vc1_6:.*]] = arith.constant 1 : index -//CHECK-NEXT: %[[Vc5_7:.*]] = arith.constant 5 : index -//CHECK-NEXT: %[[V15:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_5]] to %[[Vc5_7]] step %[[Vc1_6]] iter_args(%[[Varg18:.*]] = %[[V14]]) -> (tensor<5x!TFHE.glwe>) { -//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice_2]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[Vextracted_10:.*]] = tensor.extract %[[V13]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: %[[V16:.*]] = "TFHE.add_glwe"(%[[Vextracted_9]], %[[Vextracted_10]]) : (!TFHE.glwe, !TFHE.glwe) -> !TFHE.glwe -//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe> -//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: %[[Vc0_8:.*]] = arith.constant 0 : index -//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V15]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_8]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe> into tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -//CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x5x!TFHE.glwe> -//CHECK-NEXT: } -func.func @conv2d(%input: tensor<100x3x28x28x!FHE.eint<2>>, %weight: tensor<4x3x14x14xi3>, %bias: tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> { - %1 = "FHELinalg.conv2d"(%input, %weight, %bias){strides = dense<[1,1]> : tensor<2xi64>, dilations = dense<[1,1]> : tensor<2xi64>, padding = dense<[0, 0, 0, 0]> : tensor<4xi64>}: (tensor<100x3x28x28x!FHE.eint<2>>, tensor<4x3x14x14xi3>, tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> - return %1 : tensor<100x4x15x15x!FHE.eint<2>> -} diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/mul_eint_int.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/mul_eint_int.mlir index 00662cc455..b92b351857 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/mul_eint_int.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/mul_eint_int.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s +// RUN: concretecompiler --optimize-tfhe=false --passes fhe-to-tfhe-crt --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s // CHECK: func.func @mul_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe>) -> tensor<5x!TFHE.glwe> { // CHECK-NEXT: %[[Vc2_i8:.*]] = arith.constant 2 : i8 diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/neg_eint.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/neg_eint.mlir index 6c7fc96fbf..d26f01ed88 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/neg_eint.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/neg_eint.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s +// RUN: concretecompiler --optimize-tfhe=false --passes fhe-to-tfhe-crt --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s // CHECK: func.func @neg_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe>) -> tensor<5x!TFHE.glwe> { // CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe> diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/sub_int_eint.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/sub_int_eint.mlir index ee8df1c326..561d355b65 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/sub_int_eint.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHECrt/sub_int_eint.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s +// RUN: concretecompiler --optimize-tfhe=false --passes fhe-to-tfhe-crt --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s // CHECK: func.func @sub_int_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe>) -> tensor<5x!TFHE.glwe> { // CHECK-NEXT: %[[Vc1_i8:.*]] = arith.constant 1 : i8 diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/add_eint_int.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/add_eint_int.mlir index 056f68c01e..ef791ff496 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/add_eint_int.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/add_eint_int.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler %s --optimize-tfhe=false --optimizer-strategy=dag-mono --action=dump-tfhe 2>&1| FileCheck %s +// RUN: concretecompiler %s --passes=fhe-to-tfhe-scalar --v0-parameter=2,10,693,4,9,7,2 --action=dump-tfhe 2>&1| FileCheck %s // CHECK-LABEL: func.func @add_eint_int(%arg0: !TFHE.glwe) -> !TFHE.glwe func.func @add_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> { diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/conv2d.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/conv2d.mlir deleted file mode 100644 index a517788f8b..0000000000 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/conv2d.mlir +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: concretecompiler %s --optimize-tfhe=false --optimizer-strategy=dag-mono --action=dump-tfhe 2>&1| FileCheck %s - -// CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x!TFHE.glwe>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x!TFHE.glwe> { -// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index -// CHECK-NEXT: %[[Vc100:.*]] = arith.constant 100 : index -// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index -// CHECK-NEXT: %[[Vc4:.*]] = arith.constant 4 : index -// CHECK-NEXT: %[[Vc15:.*]] = arith.constant 15 : index -// CHECK-NEXT: %[[Vc3:.*]] = arith.constant 3 : index -// CHECK-NEXT: %[[Vc14:.*]] = arith.constant 14 : index -// CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg2]]{{\[}}%[[Varg5]]{{\]}} : tensor<4xi3> -// CHECK-NEXT: %[[Vextracted_0:.*]] = tensor.extract %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: %[[V6:.*]] = arith.extsi %[[Vextracted]] : i3 to i64 -// CHECK-NEXT: %[[Vc61_i64:.*]] = arith.constant 61 : i64 -// CHECK-NEXT: %[[V7:.*]] = arith.shli %[[V6]], %[[Vc61_i64]] : i64 -// CHECK-NEXT: %[[V8:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_0]], %[[V7]]) : (!TFHE.glwe, i64) -> !TFHE.glwe -// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V8]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x!TFHE.glwe>) { -// CHECK-NEXT: %[[V9:.*]] = affine.apply #map(%[[Varg7]], %[[Varg13]]) -// CHECK-NEXT: %[[V10:.*]] = affine.apply #map(%[[Varg9]], %[[Varg15]]) -// CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]]{{\]}} : tensor<100x3x28x28x!TFHE.glwe> -// CHECK-NEXT: %[[Vextracted_0:.*]] = tensor.extract %[[Varg1]]{{\[}}%[[Varg5]], %[[Varg11]], %[[Varg13]], %[[Varg15]]{{\]}} : tensor<4x3x14x14xi3> -// CHECK-NEXT: %[[Vextracted_1:.*]] = tensor.extract %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: %[[V11:.*]] = arith.extsi %[[Vextracted_0]] : i3 to i64 -// CHECK-NEXT: %[[V12:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted]], %[[V11]]) : (!TFHE.glwe, i64) -> !TFHE.glwe -// CHECK-NEXT: %[[V13:.*]] = "TFHE.add_glwe"(%[[Vextracted_1]], %[[V12]]) : (!TFHE.glwe, !TFHE.glwe) -> !TFHE.glwe -// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V13]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -// CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x!TFHE.glwe> -// CHECK-NEXT: } -func.func @conv2d(%input: tensor<100x3x28x28x!FHE.eint<2>>, %weight: tensor<4x3x14x14xi3>, %bias: tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> { - %1 = "FHELinalg.conv2d"(%input, %weight, %bias){strides = dense<[1,1]> : tensor<2xi64>, dilations = dense<[1,1]> : tensor<2xi64>, padding = dense<[0, 0, 0, 0]> : tensor<4xi64>}: (tensor<100x3x28x28x!FHE.eint<2>>, tensor<4x3x14x14xi3>, tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> - return %1 : tensor<100x4x15x15x!FHE.eint<2>> -} diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/lsb.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/lsb.mlir index c98ab150c6..e6efd28912 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/lsb.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/lsb.mlir @@ -1,14 +1,14 @@ -// RUN: concretecompiler %s --optimize-tfhe=false --optimizer-strategy=dag-mono --action=dump-tfhe 2>&1| FileCheck %s +// RUN: concretecompiler %s --passes=fhe-to-tfhe-scalar --v0-parameter=2,10,693,4,9,7,2 --action=dump-tfhe 2>&1| FileCheck %s // CHECK-LABEL: func.func @lsb(%arg0: !TFHE.glwe) -> !TFHE.glwe func.func @lsb(%arg0: !FHE.eint<7>) -> !FHE.eint<7> { // CHECK-NEXT: %c128_i64 = arith.constant 128 : i64 // CHECK-NEXT: %0 = "TFHE.mul_glwe_int"(%arg0, %c128_i64) : (!TFHE.glwe, i64) -> !TFHE.glwe - // CHECK-NEXT: %cst = arith.constant dense<-36028797018963968> : tensor<256xi64> + // CHECK-NEXT: %cst = arith.constant dense<-36028797018963968> : tensor<1024xi64> // CHECK-NEXT: %c4611686018427387904_i64 = arith.constant 4611686018427387904 : i64 // CHECK-NEXT: %1 = "TFHE.add_glwe_int"(%0, %c4611686018427387904_i64) : (!TFHE.glwe, i64) -> !TFHE.glwe // CHECK-NEXT: %2 = "TFHE.keyswitch_glwe"(%1) {key = #TFHE.ksk} : (!TFHE.glwe) -> !TFHE.glwe - // CHECK-NEXT: %3 = "TFHE.bootstrap_glwe"(%2, %cst) {key = #TFHE.bsk} : (!TFHE.glwe, tensor<256xi64>) -> !TFHE.glwe + // CHECK-NEXT: %3 = "TFHE.bootstrap_glwe"(%2, %cst) {key = #TFHE.bsk} : (!TFHE.glwe, tensor<1024xi64>) -> !TFHE.glwe // CHECK-NEXT: %c36028797018963968_i64 = arith.constant 36028797018963968 : i64 // CHECK-NEXT: %4 = "TFHE.add_glwe_int"(%3, %c36028797018963968_i64) : (!TFHE.glwe, i64) -> !TFHE.glwe // CHECK-NEXT: return %4 : !TFHE.glwe diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/mul_eint_int.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/mul_eint_int.mlir index 6d8f36b6bd..01c5f3d151 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/mul_eint_int.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/mul_eint_int.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler %s --optimize-tfhe=false --optimizer-strategy=dag-mono --action=dump-tfhe 2>&1| FileCheck %s +// RUN: concretecompiler %s --passes=fhe-to-tfhe-scalar --v0-parameter=2,10,693,4,9,7,2 --action=dump-tfhe 2>&1| FileCheck %s // CHECK-LABEL: func.func @mul_eint_int(%arg0: !TFHE.glwe) -> !TFHE.glwe func.func @mul_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> { diff --git a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/sub_int_eint.mlir b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/sub_int_eint.mlir index c1894fe9c6..02c86d0147 100644 --- a/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/sub_int_eint.mlir +++ b/compilers/concrete-compiler/compiler/tests/check_tests/Conversion/FHEToTFHEScalar/sub_int_eint.mlir @@ -1,4 +1,4 @@ -// RUN: concretecompiler %s --optimize-tfhe=false --optimizer-strategy=dag-mono --action=dump-tfhe 2>&1| FileCheck %s +// RUN: concretecompiler %s --passes=fhe-to-tfhe-scalar --v0-parameter=2,10,693,4,9,7,2 --action=dump-tfhe 2>&1| FileCheck %s // CHECK-LABEL: func.func @sub_int_eint(%arg0: !TFHE.glwe) -> !TFHE.glwe func.func @sub_int_eint(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {