CKKS pipeline fails on (scalar) integer types
Using secret tensors of integer types work fine with the CKKS pipeline (e.g., simple_sum.mlir works fine).
However, trying the same with scalar types does not work:
// heir-opt --mlir-to-ckks
func.func @test_scalar(%x: i32 {secret.secret}) -> i32 {
%0 = arith.addi %x, %x : i32
return %0 : i32
}
This fails in the compiler (cannot add client interface), while the same program but with arith.muli will heir-opt and even emit OpenFHE code fine (but then fail later, when trying to clang compile the OpenFHE helpers).
Initially, I was going to just submit a PR to add an explicit check to see if there's any secret integers and error if there are (like the "disallowFloat" check in --secret-to-bgv), but I think we might actually want to allow integer types in the CKKS long-term, so it might be the better fix this at the root.
Also, the difference in behaviour between add and mul indicates there's some management oddness factoring into this @ZenithalHourlyRate ?
Also note that I am refactoring the client interface passes in https://github.com/google/heir/pull/1778
In my testing both addi and muli works, and the client interface exists though it is wierd (ring_f64 encoding i32)
func.func @test_scalar(%ct: !ct_L0) -> !ct_L0 {
%ct_0 = ckks.add %ct, %ct : (!ct_L0, !ct_L0) -> !ct_L0
return %ct_0 : !ct_L0
}
func.func @test_scalar__encrypt__arg0(%arg0: i32, %pk: !pkey_L0) -> !ct_L0 {
%pt = lwe.rlwe_encode %arg0 {encoding = #inverse_canonical_encoding, ring = #ring_f64_1_x1024} : i32 -> !pt
%ct = lwe.rlwe_encrypt %pt, %pk : (!pt, !pkey_L0) -> !ct_L0
return %ct : !ct_L0
}