fix(compiler): Remove the 7bits restriction on compiler side, it's the optimizer that known the truth

This commit is contained in:
Quentin Bourgerie
2022-03-21 13:46:27 +01:00
parent fe13853286
commit 8961be33d2
7 changed files with 10 additions and 21 deletions

View File

@@ -9,7 +9,6 @@
namespace mlir {
namespace concretelang {
constexpr unsigned DEFAULT_PATTERN_BENEFIT = 1;
constexpr unsigned MAXIMUM_BIT_WIDTH = 7;
} // namespace concretelang
} // namespace mlir

View File

@@ -24,9 +24,6 @@ PYBIND11_MODULE(_concretelang, m) {
llvm::sys::PrintStackTraceOnErrorSignal(/*argv=*/"");
LLVMEnablePrettyStackTrace();
m.attr("MAXIMUM_BIT_WIDTH") =
pybind11::int_(mlir::concretelang::MAXIMUM_BIT_WIDTH);
m.def(
"register_dialects",
[](py::object capsule) {

View File

@@ -53,9 +53,8 @@ void FHEDialect::printType(::mlir::Type type,
mlir::LogicalResult EncryptedIntegerType::verify(
llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned p) {
if (p == 0 || p > mlir::concretelang::MAXIMUM_BIT_WIDTH) {
emitError() << "FHE.eint support only precision in ]0;"
<< mlir::concretelang::MAXIMUM_BIT_WIDTH << "]";
if (p == 0) {
emitError() << "FHE.eint didn't support precision equals to 0";
return mlir::failure();
}
return mlir::success();

View File

@@ -49,7 +49,6 @@ void TFHEDialect::printType(::mlir::Type type,
/// Verify that GLWE parameter are consistant
/// - The bits parameter is 64 (we support only this for v0)
/// - The p parameter is ]0;MAXIMUM_BIT_WIDTH]
::mlir::LogicalResult GLWECipherTextType::verify(
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
signed dimension, signed polynomialSize, signed bits, signed p) {
@@ -57,9 +56,8 @@ void TFHEDialect::printType(::mlir::Type type,
emitError() << "GLWE bits parameter can only be 64";
return ::mlir::failure();
}
if (p == 0 || p > (signed)mlir::concretelang::MAXIMUM_BIT_WIDTH) {
emitError() << "GLWE p parameter can only be in ]0;"
<< mlir::concretelang::MAXIMUM_BIT_WIDTH << "]";
if (p == 0) {
emitError() << "GLWE p parameter must be positive";
return mlir::failure();
}
return ::mlir::success();

View File

@@ -1,6 +1,6 @@
// RUN: not concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
// RUN: not concretecompiler --action=dump-llvm-ir %s 2>&1| FileCheck %s
// CHECK-LABEL: eint support only precision in ]0;7]
func @test(%arg0: !FHE.eint<8>) {
// CHECK-LABEL: Could not determine V0 parameters
func @test(%arg0: !FHE.eint<9>) {
return
}

View File

@@ -1,6 +1,6 @@
// RUN: not concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
// CHECK-LABEL: eint support only precision in ]0;7]
// CHECK-LABEL: FHE.eint didn't support precision equals to 0
func @test(%arg0: !FHE.eint<0>) {
return
}

View File

@@ -1,13 +1,9 @@
import pytest
from mlir.ir import Context, RankedTensorType, Location
from concrete.lang import register_dialects, MAXIMUM_BIT_WIDTH
from concrete.lang import register_dialects
from concrete.lang.dialects import fhe
def test_constants():
assert MAXIMUM_BIT_WIDTH == 7
@pytest.mark.parametrize("width", list(range(1, 8)))
def test_eint(width):
ctx = Context()
@@ -27,7 +23,7 @@ def test_eint_tensor(shape):
)
@pytest.mark.parametrize("width", [0, 8, 10, 12])
@pytest.mark.parametrize("width", [0])
def test_invalid_eint(width):
ctx = Context()
register_dialects(ctx)