diff --git a/compilers/concrete-compiler/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td b/compilers/concrete-compiler/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td index 3901069c8..8e092273a 100644 --- a/compilers/concrete-compiler/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td +++ b/compilers/concrete-compiler/compiler/include/concretelang/Dialect/TFHE/IR/TFHEOps.td @@ -100,6 +100,8 @@ def TFHE_EncodeExpandLutForBootstrapOp : TFHE_Op<"encode_expand_lut_for_bootstra ); let results = (outs 1DTensorOf<[I64]> : $result); + + let hasVerifier = 1; } def TFHE_EncodeLutForCrtWopPBSOp : TFHE_Op<"encode_lut_for_crt_woppbs", [Pure]> { diff --git a/compilers/concrete-compiler/compiler/lib/Dialect/TFHE/IR/TFHEOps.cpp b/compilers/concrete-compiler/compiler/lib/Dialect/TFHE/IR/TFHEOps.cpp index d1d25ed18..7447b0cf1 100644 --- a/compilers/concrete-compiler/compiler/lib/Dialect/TFHE/IR/TFHEOps.cpp +++ b/compilers/concrete-compiler/compiler/lib/Dialect/TFHE/IR/TFHEOps.cpp @@ -117,6 +117,24 @@ mlir::LogicalResult MulGLWEIntOp::verify() { *this); } +mlir::LogicalResult EncodeExpandLutForBootstrapOp::verify() { + mlir::IntegerAttr polySizeAttr = this->getPolySizeAttr(); + + mlir::RankedTensorType rtt = + this->getResult().getType().template cast(); + + if (rtt.getNumElements() != polySizeAttr.getInt()) { + this->emitError("The number of elements of the output tensor of ") + << rtt.getNumElements() + << " does not match the size of the polynomial of " + << polySizeAttr.getInt(); + + return mlir::failure(); + } + + return mlir::success(); +} + template mlir::LogicalResult verifyBootstrapSingleLUTConstraints(BootstrapOpT &op) { GLWEBootstrapKeyAttr keyAttr = op.getKeyAttr();