refactor(compiler): HLFHE.dot_eint_int: Switch from reference to value semantics

This changes the semantics of `HLFHE.dot_eint_int` from memref-based
reference semantics to tensor-based value semantics. The former:

  "HLFHE.dot_eint_int"(%arg0, %arg1, %arg2) :
     (memref<Nx!HLFHE.eint<0>>, memref<Nxi32>, memref<!HLFHE.eint<0>>) -> ()

becomes:

  "HLFHE.dot_eint_int"(%arg0, %arg1) :
     (tensor<Nx!HLFHE.eint<0>>, tensor<Nxi32>) -> !HLFHE.eint<0>

As a side effect, data-flow analyses become much easier. With the
previous memref type of the plaintext argument it is difficult to
check whether the plaintext values are statically defined constants or
originate from a memory region changed at execution time (e.g., for
analyses evaluating the impact on noise). Changing the plaintext type
from `memref` to `vector` makes such analyses significantly easier.
This commit is contained in:
Andi Drebes
2021-07-27 10:58:28 +02:00
committed by Quentin Bourgerie
parent cb580f16d2
commit 8b9c9f2da1
7 changed files with 108 additions and 104 deletions

View File

@@ -91,13 +91,11 @@ def ApplyLookupTableEintOp : HLFHE_Op<"apply_lookup_table"> {
// Tensor operations
// Dot product
def Dot : HLFHE_Op<"dot_eint_int", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
// Output memref is passed as the last argument; Input and output
// relationships are modeled through MemoryEffectsOpInterface`
def Dot : HLFHE_Op<"dot_eint_int"> {
let arguments = (ins
Type<And<[StaticShapeMemRefOf<[EncryptedIntegerType]>.predicate, HasAnyRankOfPred<[1]>]>>:$lhs,
Type<And<[StaticShapeMemRefOf<[AnyInteger]>.predicate, HasAnyRankOfPred<[1]>]>>:$rhs,
Type<And<[StaticShapeMemRefOf<[EncryptedIntegerType]>.predicate, HasAnyRankOfPred<[0]>]>>:$out);
Type<And<[TensorOf<[EncryptedIntegerType]>.predicate, HasStaticShapePred, HasAnyRankOfPred<[1]>]>>:$lhs,
Type<And<[TensorOf<[AnyInteger]>.predicate, HasStaticShapePred, HasAnyRankOfPred<[1]>]>>:$rhs);
let results = (outs EncryptedIntegerType:$out);
let verifier = [{
if(::mlir::failed(
mlir::verifyCompatibleShape(