mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 12:15:09 -05:00
enhance(compiler): Add verifier of MidLFHE.GLWE parameters
This commit is contained in:
@@ -42,6 +42,10 @@ def MulPlainOp : MidLFHE_Op<"mul_plain"> {
|
||||
build($_builder, $_state, a.getType(), a, b);
|
||||
}]>
|
||||
];
|
||||
|
||||
let verifier = [{
|
||||
return ::mlir::zamalang::verifyMulPlainOp(*this);
|
||||
}];
|
||||
}
|
||||
|
||||
def HAddOp : MidLFHE_Op<"h_add"> {
|
||||
@@ -53,6 +57,10 @@ def HAddOp : MidLFHE_Op<"h_add"> {
|
||||
build($_builder, $_state, a.getType(), a, b);
|
||||
}]>
|
||||
];
|
||||
|
||||
let verifier = [{
|
||||
return ::mlir::zamalang::verifyHAddOp(*this);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ZAMALANG_DIALECT_MIDLFHE_IR_MIDLFHETYPES_H
|
||||
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
#include <mlir/Dialect/StandardOps/IR/Ops.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/BuiltinTypes.h>
|
||||
#include <mlir/IR/DialectImplementation.h>
|
||||
|
||||
@@ -121,9 +121,11 @@ def GLWECipherTextType : MidLFHE_Type<"GLWECipherText"> {
|
||||
|
||||
if ($_parser.parseGreater())
|
||||
return Type();
|
||||
|
||||
return get($_ctxt, dimension, polynomialSize, bits, paddingBits, p, phantomBits, scalingFactor, log2StdDev);
|
||||
Location loc = $_parser.getEncodedSourceLoc($_parser.getNameLoc());
|
||||
return getChecked(loc, loc.getContext(), dimension, polynomialSize, bits, paddingBits, p, phantomBits, scalingFactor, log2StdDev);
|
||||
}];
|
||||
|
||||
let genVerifyDecl = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,3 +37,75 @@ void MidLFHEDialect::printType(::mlir::Type type,
|
||||
// TODO - What should be done here?
|
||||
printer << "unknwontype";
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the nubmer of bits from the log2StdDev parameter of a GLWE.
|
||||
* This is widely inspired by the rust version on concrete:
|
||||
*
|
||||
* pub fn nb_bit_from_variance_99(var: f64, torus_bit: usize) -> usize {
|
||||
* // compute sigma
|
||||
* let sigma: f64 = f64::sqrt(var);
|
||||
*
|
||||
* // the constant to get 99% of the normal distribution
|
||||
* let z: f64 = 3.;
|
||||
* let tmp = torus_bit as f64 + f64::log2(sigma * z);
|
||||
* if tmp < 0. {
|
||||
* // means no bits are affected by the noise in the integer
|
||||
* representation (discrete space) 0usize } else { tmp.ceil() as usize
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
unsigned nbBitsFromLog2StdDev(signed log2StdDev, signed bits) {
|
||||
long double sigma = std::pow(2, log2StdDev);
|
||||
long double z = 3;
|
||||
long double tmp = bits + std::log2(sigma * z);
|
||||
if (tmp < 0.) {
|
||||
return 0;
|
||||
}
|
||||
return std::ceil(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that GLWE parameter are consistant, the layout of the ciphertext is
|
||||
* organized like that.
|
||||
*
|
||||
* [0 0 0 0 0 0 0 0 X X X X X X X M M M M M M M X X X X X X X X 0 0 0 0 0 0 0 E
|
||||
* E E E E E E E E E E E E] ^ paddingBits ^ ^ p ^ ^
|
||||
* phantomBits ^ ^ nb_bits of log2StdDev ^ ^ scalingFactor We
|
||||
* verify :
|
||||
* - The bits parameter is 32 or 64 (we support only this value for now)
|
||||
* - The message is not overlaped by the error
|
||||
* - The message is still in the ciphertext
|
||||
*/
|
||||
::mlir::LogicalResult GLWECipherTextType::verify(
|
||||
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
|
||||
signed dimension, signed polynomialSize, signed bits, signed paddingBits,
|
||||
signed p, signed phantomBits, signed scalingFactor, signed log2StdDev) {
|
||||
if (bits != -1 && bits != 32 && bits != 64) {
|
||||
emitError() << "GLWE bits parameter can only be 32 or 64";
|
||||
return ::mlir::failure();
|
||||
}
|
||||
if (bits != -1 && log2StdDev != -1 && scalingFactor != -1 &&
|
||||
phantomBits != -1) {
|
||||
unsigned errBits = nbBitsFromLog2StdDev(log2StdDev, bits);
|
||||
if (errBits > scalingFactor + phantomBits) {
|
||||
emitError() << "GLWE error overlap message, errBits(" << errBits
|
||||
<< ") > scalingFactor(" << scalingFactor << ") + phantomBits("
|
||||
<< phantomBits << ")";
|
||||
return ::mlir::failure();
|
||||
}
|
||||
}
|
||||
if (bits != -1 && paddingBits != -1 && p != -1 && phantomBits != -1 &&
|
||||
scalingFactor != -1) {
|
||||
signed int phantomLeft =
|
||||
(bits - scalingFactor) - phantomBits - p - paddingBits;
|
||||
if (phantomLeft < 0) {
|
||||
// TODO: better message ...
|
||||
emitError() << "GLWE message cannot be represented "
|
||||
<< (bits - scalingFactor) << "vs"
|
||||
<< (phantomBits - p - paddingBits);
|
||||
return ::mlir::failure();
|
||||
}
|
||||
}
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace mlir {
|
||||
namespace zamalang {
|
||||
using ::mlir::zamalang::MidLFHE::AddPlainOp;
|
||||
using ::mlir::zamalang::MidLFHE::GLWECipherTextType;
|
||||
using ::mlir::zamalang::MidLFHE::HAddOp;
|
||||
using ::mlir::zamalang::MidLFHE::MulPlainOp;
|
||||
|
||||
bool predPBSRegion(::mlir::Region ®ion) {
|
||||
if (region.getBlocks().size() != 1) {
|
||||
@@ -93,6 +95,169 @@ bool verifyAddResultHasSameParameters(::mlir::OpState &op,
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
bool verifyHAddResultPadding(::mlir::OpState &op, GLWECipherTextType &inA,
|
||||
GLWECipherTextType &inB, GLWECipherTextType &out) {
|
||||
// If the inputs has no value of paddingBits that doesn't constraint output.
|
||||
if (inA.getPaddingBits() == -1 && inB.getPaddingBits() == -1) {
|
||||
return true;
|
||||
}
|
||||
return verifyAddResultPadding(op, inA, out);
|
||||
}
|
||||
|
||||
int hAddLog2StdDevOfResult(int a, int b) {
|
||||
long double va = std::pow(std::pow(2, a), 2);
|
||||
long double vb = std::pow(std::pow(2, b), 2);
|
||||
long double vr = va + vb;
|
||||
return std::log2(::sqrt(vr));
|
||||
}
|
||||
|
||||
bool verifyHAddResultLog2StdDev(::mlir::OpState &op, GLWECipherTextType &inA,
|
||||
GLWECipherTextType &inB,
|
||||
GLWECipherTextType &out) {
|
||||
// If the inputs has no value of log2StdDev that doesn't constraint output.
|
||||
if (inA.getLog2StdDev() == -1 && inB.getLog2StdDev() == -1) {
|
||||
return true;
|
||||
}
|
||||
int expectedLog2StdDev =
|
||||
hAddLog2StdDevOfResult(inA.getLog2StdDev(), inB.getLog2StdDev());
|
||||
if (out.getLog2StdDev() != expectedLog2StdDev) {
|
||||
::llvm::Twine msg(
|
||||
"has unexpected log2StdDev parameter of its GLWE result, expected:");
|
||||
op.emitOpError(msg.concat(::llvm::Twine(expectedLog2StdDev)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool verifyHAddSameGLWEParameter(::mlir::OpState &op, GLWECipherTextType &inA,
|
||||
GLWECipherTextType &inB,
|
||||
GLWECipherTextType &out) {
|
||||
if (inA.getDimension() != inB.getDimension() ||
|
||||
inA.getDimension() != out.getDimension()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "dimension");
|
||||
return false;
|
||||
}
|
||||
if (inA.getPolynomialSize() != inB.getPolynomialSize() &&
|
||||
inA.getPolynomialSize() != out.getPolynomialSize()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "polynomialSize");
|
||||
return false;
|
||||
}
|
||||
if (inA.getBits() != inB.getBits() && inA.getBits() != out.getBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "bits");
|
||||
return false;
|
||||
}
|
||||
if (inA.getP() != inB.getP() && inA.getP() != out.getP()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "p");
|
||||
return false;
|
||||
}
|
||||
if (inA.getPhantomBits() != inB.getPhantomBits() &&
|
||||
inA.getPhantomBits() != out.getPhantomBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "phantomBits");
|
||||
return false;
|
||||
}
|
||||
if (inA.getScalingFactor() && inB.getScalingFactor() &&
|
||||
inA.getScalingFactor() != out.getScalingFactor()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "scalingFactor");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
::mlir::LogicalResult verifyHAddOp(HAddOp &op) {
|
||||
GLWECipherTextType inA = op.a().getType().cast<GLWECipherTextType>();
|
||||
GLWECipherTextType inB = op.b().getType().cast<GLWECipherTextType>();
|
||||
GLWECipherTextType out = op.getResult().getType().cast<GLWECipherTextType>();
|
||||
if (!verifyHAddResultPadding(op, inA, inB, out)) {
|
||||
return ::mlir::failure();
|
||||
}
|
||||
if (!verifyHAddResultLog2StdDev(op, inA, inB, out)) {
|
||||
return ::mlir::failure();
|
||||
}
|
||||
if (!verifyHAddSameGLWEParameter(op, inA, inB, out)) {
|
||||
return ::mlir::failure();
|
||||
}
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
bool verifyMulPlainOpPadding(::mlir::OpState &op, GLWECipherTextType &inA,
|
||||
::mlir::Value &inB, GLWECipherTextType &out) {
|
||||
if (inA.getPaddingBits() == -1) {
|
||||
return true;
|
||||
}
|
||||
if (inA.getPaddingBits() == 0) {
|
||||
if (out.getPaddingBits() != 0) {
|
||||
op.emitError(
|
||||
"the result shoud have 0 paddingBits has input has 0 paddingBits");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
unsigned int additionalBit = 0;
|
||||
::mlir::ConstantIntOp constantOp = inB.getDefiningOp<::mlir::ConstantIntOp>();
|
||||
if (constantOp != nullptr) {
|
||||
int64_t value = constantOp.getValue();
|
||||
additionalBit = std::ceil(std::log2(value)) + 1;
|
||||
} else {
|
||||
::mlir::IntegerType tyB = inB.getType().cast<::mlir::IntegerType>();
|
||||
additionalBit = tyB.getIntOrFloatBitWidth();
|
||||
}
|
||||
unsigned int expectedPadding = inA.getPaddingBits() - additionalBit;
|
||||
if (out.getPaddingBits() != expectedPadding) {
|
||||
::llvm::Twine msg(
|
||||
"has unexpected padding parameter of its GLWE result, expected:");
|
||||
op.emitOpError(msg.concat(::llvm::Twine(expectedPadding)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool verifyMulPlainResultHasSameParameters(::mlir::OpState &op,
|
||||
GLWECipherTextType &in,
|
||||
GLWECipherTextType &out) {
|
||||
if (in.getDimension() != out.getDimension()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "dimension");
|
||||
return false;
|
||||
}
|
||||
if (in.getPolynomialSize() != out.getPolynomialSize()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "polynomialSize");
|
||||
return false;
|
||||
}
|
||||
if (in.getBits() != out.getBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "bits");
|
||||
return false;
|
||||
}
|
||||
if (in.getP() != out.getP()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "p");
|
||||
return false;
|
||||
}
|
||||
if (in.getPhantomBits() != out.getPhantomBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "phantomBits");
|
||||
return false;
|
||||
}
|
||||
if (in.getScalingFactor() != out.getScalingFactor()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "scalingFactor");
|
||||
return false;
|
||||
}
|
||||
if (in.getLog2StdDev() != out.getLog2StdDev()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "log2StdDev");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
::mlir::LogicalResult verifyMulPlainOp(MulPlainOp &op) {
|
||||
GLWECipherTextType inA = op.a().getType().cast<GLWECipherTextType>();
|
||||
::mlir::Value inB = op.b();
|
||||
GLWECipherTextType out = op.getResult().getType().cast<GLWECipherTextType>();
|
||||
if (!verifyMulPlainOpPadding(op, inA, inB, out)) {
|
||||
return ::mlir::failure();
|
||||
}
|
||||
if (!verifyMulPlainResultHasSameParameters(op, inA, out)) {
|
||||
return ::mlir::failure();
|
||||
}
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
} // namespace zamalang
|
||||
} // namespace mlir
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @add_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
func @add_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}> {
|
||||
// CHECK-LABEL: func @add_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>
|
||||
func @add_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = constant 1 : i32
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, i32) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>, i32) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>
|
||||
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @add_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,-64}{2,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}>
|
||||
func @add_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,-64}{2,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}> {
|
||||
// CHECK-LABEL: func @add_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}>
|
||||
func @add_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = constant 1 : i32
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,-64}{2,7,0,32,-25}>, i32) -> !MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{2,7,0,41,-25}>, i32) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}>
|
||||
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,-64}{2,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,-64}{1,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{2,7,0,41,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{1,7,0,41,-25}>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE bits parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,32}{0,7,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,32}{0,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,32}{0,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,32}{0,7,0,25,-82}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,32}{0,7,0,25,-82}>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: should have the same GLWE dimension parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1023,12,64}{0,7,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1023,12,64}{0,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1023,12,64}{0,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE log2StdDev parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-29}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-29}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-29}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}>
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE p parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,6,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,6,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,6,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: the result shoud have 0 paddingBits has input has 0 paddingBits
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{1,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{1,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}>
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: the result should have one less padding bit than the input
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{2,7,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>) -> !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{2,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{2,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{2,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE phantomBits parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,1,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,51,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,1,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,1,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,51,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}>
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE polynomialSize parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,10,64}{0,7,0,32,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,10,64}{0,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,10,64}{0,7,0,32,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE scalingFactor parameter
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,30,-25}> {
|
||||
func @add_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,30,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,30,-25}>
|
||||
%1 = "MidLFHE.add_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}>
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @add_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, %arg1: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}>
|
||||
func @add_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, %arg1: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "MidLFHE.h_add"(%arg0, %arg1) : (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}>
|
||||
|
||||
// CHECK-LABEL: func @add_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
func @add_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "MidLFHE.h_add"(%arg0, %arg1) : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
|
||||
%0 = "MidLFHE.h_add"(%arg0, %arg1): (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>)
|
||||
return %0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
%0 = "MidLFHE.h_add"(%arg0, %arg1): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}>)
|
||||
return %0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-24}>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
|
||||
// CHECK-LABEL: func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "MidLFHE.h_mul"(%arg0, %arg1) : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-LABEL: func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, %arg1: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>
|
||||
func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, %arg1: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "MidLFHE.h_mul"(%arg0, %arg1) : (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>
|
||||
|
||||
%0 = "MidLFHE.h_mul"(%arg0, %arg1): (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>)
|
||||
return %0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
%0 = "MidLFHE.h_mul"(%arg0, %arg1): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>)
|
||||
return %0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
// CHECK-LABEL: func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
func @mul_plain_glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}> {
|
||||
|
||||
// CHECK-LABEL: func @mul_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
func @mul_plain_no_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = constant 1 : i32
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.mul_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, i32) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.mul_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @mul_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,55,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}>
|
||||
func @mul_plain_padding(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,55,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = constant 1 : i32
|
||||
// CHECK-NEXT: %[[V2:.*]] = "MidLFHE.mul_plain"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{2,7,0,55,-25}>, i32) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}>
|
||||
// CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}>
|
||||
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{2,7,0,55,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{1,7,0,55,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE bits parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,41,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,32}{0,7,0,25,-82}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,32}{0,7,0,25,-82}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: should have the same GLWE dimension parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1023,12,64}{0,7,0,57,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE log2StdDev parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-29}>
|
||||
}
|
||||
8
compiler/tests/Dialect/MidLFHE/op_mul_plain_err_p.mlir
Normal file
8
compiler/tests/Dialect/MidLFHE/op_mul_plain_err_p.mlir
Normal file
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE p parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,6,0,57,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: the result shoud have 0 paddingBits has input has 0 paddingBits
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{1,7,0,50,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: the result should have one less padding bit than the input
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>) -> !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{2,7,0,51,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE phantomBits parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,51,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,51,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,1,51,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE polynomialSize parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,10,64}{0,7,0,50,-25}>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: should have the same GLWE scalingFactor parameter
|
||||
func @mul_plain(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}> {
|
||||
%0 = constant 1 : i32
|
||||
%1 = "MidLFHE.mul_plain"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{0,7,0,50,-25}>, i32) -> (!MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}>)
|
||||
return %1: !MidLFHE.glwe<{1024,12,64}{0,7,0,49,-25}>
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @pbs_ciphertext(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: i32) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}> {
|
||||
func @pbs_ciphertext(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>, %arg1: i32) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}> {
|
||||
// CHECK-LABEL: func @pbs_ciphertext(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, %arg1: i32) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}> {
|
||||
func @pbs_ciphertext(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>, %arg1: i32) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "MidLFHE.pbs"(%arg0) ( {
|
||||
// CHECK-NEXT: ^bb0(%[[V2:.*]]: i32): // no predecessors
|
||||
// CHECK-NEXT: %[[V4:.*]] = divi_unsigned %[[V2]], %arg1 : i32
|
||||
// CHECK-NEXT: "MidLFHE.pbs_return"(%[[V4]]) : (i32) -> ()
|
||||
// CHECK-NEXT: }) {base_log = 8 : i32, big_n = 1024 : i32, level = 2 : i32, log_noise = -20 : i32} : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}>
|
||||
// CHECK-NEXT: }) {base_log = 8 : i32, big_n = 1024 : i32, level = 2 : i32, log_noise = -82 : i32} : (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}>
|
||||
// CHECK-NEXT: return %[[V1]] : !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}>
|
||||
%0 = "MidLFHE.pbs"(%arg0)({
|
||||
^bb0(%a:i32):
|
||||
%1 = std.divi_unsigned %a, %arg1 : i32
|
||||
"MidLFHE.pbs_return"(%1) : (i32) -> ()
|
||||
}){big_n=1024: i32, log_noise=-20: i32, base_log=8 : i32, level=2 : i32} : (!MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}>
|
||||
}){big_n=1024: i32, log_noise=-82: i32, base_log=8 : i32, level=2 : i32} : (!MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}>
|
||||
|
||||
return %0 : !MidLFHE.glwe<{2048,10,64}{0,7,0,32,-20}>
|
||||
return %0 : !MidLFHE.glwe<{2048,10,64}{0,7,0,2,-82}>
|
||||
}
|
||||
@@ -1,13 +1,7 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @glwe_unknwon_parameter(%arg0: !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}>) -> !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}>
|
||||
func @glwe_unknwon_parameter(%arg0: !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}>) -> !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}> {
|
||||
// CHECK-LABEL: return %arg0 : !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}>
|
||||
return %arg0: !MidLFHE.glwe<{_,_,_}{_,7,_,_,_}>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
func @glwe(%arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>) -> !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}> {
|
||||
// CHECK-LABEL: return %arg0 : !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
return %arg0: !MidLFHE.glwe<{1024,12,-64}{0,7,0,32,-25}>
|
||||
// CHECK-LABEL: func @glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
func @glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}> {
|
||||
// CHECK-LABEL: return %arg0 : !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
return %arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,57,-25}>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// RUN: not zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: error: GLWE error overlap message, errBits(41) > scalingFactor(40) + phantomBits(0)
|
||||
func @glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,40,-25}>) -> !MidLFHE.glwe<{1024,12,64}{0,7,0,40,-25}> {
|
||||
return %arg0: !MidLFHE.glwe<{1024,12,64}{0,7,0,40,-25}>
|
||||
}
|
||||
Reference in New Issue
Block a user