fix(compiler/lowlfhe): Fix wrong shift value for EncodeIntOp lowering

That's work before because we enfoce 6 as global constraint while our runJit tests are on 7 bits
This commit is contained in:
Quentin Bourgerie
2021-08-13 15:54:08 +02:00
parent 96c50d5dca
commit 8796754513
4 changed files with 6 additions and 7 deletions

View File

@@ -149,8 +149,7 @@ struct LowLFHEEncodeIntOpPattern
mlir::Value castedInt = rewriter.create<mlir::ZeroExtendIOp>(
op.getLoc(), rewriter.getIntegerType(64), op->getOperands().front());
mlir::Value constantShiftOp = rewriter.create<mlir::ConstantOp>(
op.getLoc(),
rewriter.getI64IntegerAttr(64 - (op.getType().getP() - 1)));
op.getLoc(), rewriter.getI64IntegerAttr(64 - op.getType().getP()));
mlir::Type resultType = rewriter.getIntegerType(64);
rewriter.replaceOpWithNewOp<mlir::ShiftLeftOp>(op, resultType, castedInt,

View File

@@ -9,7 +9,7 @@ namespace mlir {
namespace zamalang {
// This is temporary while we doesn't yet have the high-level verification pass
FHECircuitConstraint defaultGlobalFHECircuitConstraint{.norm2 = 20, .p = 6};
FHECircuitConstraint defaultGlobalFHECircuitConstraint{.norm2 = 10, .p = 7};
void initLLVMNativeTarget() {
// Initialize LLVM targets.

View File

@@ -119,7 +119,7 @@ V0Parameter *getV0Parameter(size_t norm, size_t p) {
if (norm > NORM2_MAX) {
return nullptr;
}
if (p >= P_MAX) {
if (p > P_MAX) {
return nullptr;
}
// - 1 is an offset as norm and p are in [1, ...] and not [0, ...]

View File

@@ -1,8 +1,8 @@
// RUN: zamacompiler %s --run-jit --jit-args 2 2>&1| FileCheck %s
// RUN: zamacompiler %s --run-jit --jit-args 3 2>&1| FileCheck %s
// CHECK-LABEL: 3
// CHECK-LABEL: 42
func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> {
%0 = constant 1 : i8
%0 = constant 45 : i8
%1 = "HLFHE.sub_int_eint"(%0, %arg0): (i8, !HLFHE.eint<7>) -> (!HLFHE.eint<7>)
return %1: !HLFHE.eint<7>
}