From 03c1588db44633788dba7dea6af7ff1d89d5964d Mon Sep 17 00:00:00 2001 From: youben11 Date: Mon, 18 Oct 2021 12:05:21 +0100 Subject: [PATCH] chore: update to LLVM 8b7cc93e major changes: - https://llvm.discourse.group/t/psa-removed-arithmetic-ops-from-standard/4455 - use add_mlir_public_c_api_library helper to correctly add a CAPI library --- .../include/zamalang/Conversion/Passes.td | 2 +- compiler/lib/CAPI/Dialect/CMakeLists.txt | 5 +- compiler/lib/CAPI/Support/CMakeLists.txt | 7 +-- .../TensorOpsToLinalg.cpp | 3 +- .../LowLFHEToConcreteCAPI.cpp | 51 ++++++++++--------- .../MLIRLowerableDialectsToLLVM.cpp | 3 ++ .../MidLFHEGlobalParametrization.cpp | 10 ++-- compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp | 40 +++++++++------ .../HLFHEToMidLFHE/add_eint_int.mlir | 4 +- .../HLFHEToMidLFHE/apply_univariate_cst.mlir | 4 +- .../HLFHEToMidLFHE/mul_eint_int.mlir | 4 +- .../HLFHEToMidLFHE/sub_int_eint.mlir | 4 +- .../LowLFHEToConcreteCAPI/bootstrap.mlir | 4 +- .../glwe_from_table.mlir | 10 ++-- .../LowLFHEToConcreteCAPI/keyswitch_lwe.mlir | 4 +- .../MidLFHEToLowLFHE/add_glwe_int.mlir | 4 +- .../apply_lookup_table_cst.mlir | 4 +- .../MidLFHEToLowLFHE/mul_glwe_int.mlir | 4 +- .../MidLFHEToLowLFHE/sub_int_glwe.mlir | 4 +- .../tests/Dialect/HLFHE/Analysis/MANP.mlir | 36 ++++++------- .../Dialect/HLFHE/Analysis/MANP_linalg.mlir | 18 +++---- .../Dialect/HLFHE/Analysis/MANP_tensor.mlir | 14 ++--- .../HLFHE/op_add_eint_int_err_inputs.mlir | 2 +- .../HLFHE/op_add_eint_int_err_result.mlir | 2 +- .../HLFHE/op_mul_eint_int_err_inputs.mlir | 2 +- .../HLFHE/op_mul_eint_int_err_result.mlir | 2 +- .../HLFHE/op_sub_int_eint_err_inputs.mlir | 2 +- .../HLFHE/op_sub_int_eint_err_result.mlir | 2 +- compiler/tests/Dialect/HLFHE/ops.mlir | 12 ++--- .../Dialect/HLFHE/tensor-ops-to-linalg.mlir | 2 +- compiler/tests/Dialect/LowLFHE/ops.mlir | 4 +- .../MidLFHE/op_add_glwe_int.invalid.mlir | 8 +-- .../Dialect/MidLFHE/op_add_glwe_int.mlir | 4 +- .../MidLFHE/op_mul_glwe_int.invalid.mlir | 8 +-- .../Dialect/MidLFHE/op_mul_glwe_int.mlir | 4 +- .../MidLFHE/op_sub_int_glwe.invalid.mlir | 8 +-- .../Dialect/MidLFHE/op_sub_int_glwe.mlir | 4 +- compiler/tests/python/test_compiler_engine.py | 2 +- compiler/tests/python/test_round_trip.py | 4 +- .../unittest/end_to_end_jit_hlfhelinalg.cc | 2 +- .../tests/unittest/end_to_end_jit_test.cc | 18 +++---- llvm-project | 2 +- 42 files changed, 170 insertions(+), 163 deletions(-) diff --git a/compiler/include/zamalang/Conversion/Passes.td b/compiler/include/zamalang/Conversion/Passes.td index 87e8092f9..b15ce5c9f 100644 --- a/compiler/include/zamalang/Conversion/Passes.td +++ b/compiler/include/zamalang/Conversion/Passes.td @@ -47,7 +47,7 @@ def LowLFHEUnparametrize : Pass<"lowlfhe-unparametrize", "mlir::ModuleOp"> { def MLIRLowerableDialectsToLLVM : Pass<"mlir-lowerable-dialects-to-llvm", "mlir::ModuleOp"> { let summary = "Lowers operations from MLIR lowerable dialects to LLVM"; let constructor = "mlir::zamalang::createConvertMLIRLowerableDialectsToLLVMPass()"; - let dependentDialects = ["mlir::StandardOpsDialect", "mlir::scf::SCFDialect", "mlir::LLVM::LLVMDialect"]; + let dependentDialects = ["mlir::StandardOpsDialect", "mlir::arith::ArithmeticDialect", "mlir::scf::SCFDialect", "mlir::LLVM::LLVMDialect"]; let options = []; } diff --git a/compiler/lib/CAPI/Dialect/CMakeLists.txt b/compiler/lib/CAPI/Dialect/CMakeLists.txt index 4a69936d3..112e1c3c7 100644 --- a/compiler/lib/CAPI/Dialect/CMakeLists.txt +++ b/compiler/lib/CAPI/Dialect/CMakeLists.txt @@ -1,12 +1,9 @@ set(LLVM_OPTIONAL_SOURCES HLFHE.cpp) -add_mlir_library(ZAMALANGCAPIHLFHE +add_mlir_public_c_api_library(ZAMALANGCAPIHLFHE HLFHE.cpp - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir-c - LINK_LIBS PUBLIC MLIRCAPIIR HLFHEDialect diff --git a/compiler/lib/CAPI/Support/CMakeLists.txt b/compiler/lib/CAPI/Support/CMakeLists.txt index 3f0cede78..7dbd947be 100644 --- a/compiler/lib/CAPI/Support/CMakeLists.txt +++ b/compiler/lib/CAPI/Support/CMakeLists.txt @@ -1,11 +1,8 @@ set(LLVM_OPTIONAL_SOURCES CompilerEngine.cpp) -add_mlir_library(ZAMALANGCAPISupport +add_mlir_public_c_api_library(ZAMALANGCAPISupport -CompilerEngine.cpp - - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir-c + CompilerEngine.cpp LINK_LIBS PUBLIC MLIRCAPIIR diff --git a/compiler/lib/Conversion/HLFHETensorOpsToLinalg/TensorOpsToLinalg.cpp b/compiler/lib/Conversion/HLFHETensorOpsToLinalg/TensorOpsToLinalg.cpp index 16c3fc1b9..8867ae1a3 100644 --- a/compiler/lib/Conversion/HLFHETensorOpsToLinalg/TensorOpsToLinalg.cpp +++ b/compiler/lib/Conversion/HLFHETensorOpsToLinalg/TensorOpsToLinalg.cpp @@ -112,7 +112,7 @@ struct DotToLinalgGeneric : public ::mlir::RewritePattern { // element and use it as a replacement for the result of the dot // operation mlir::Value idx0 = - rewriter.create(dotOp.getLoc(), 0); + rewriter.create(dotOp.getLoc(), 0); llvm::SmallVector indexes{idx0}; mlir::Value res = rewriter.create( dotOp.getLoc(), gop.getResult(0), indexes); @@ -360,6 +360,7 @@ void HLFHETensorOpsToLinalg::runOnFunction() { target.addLegalDialect(); target.addLegalDialect(); target.addLegalDialect(); + target.addLegalDialect(); target.addIllegalOp(); target.addIllegalDialect(); diff --git a/compiler/lib/Conversion/LowLFHEToConcreteCAPI/LowLFHEToConcreteCAPI.cpp b/compiler/lib/Conversion/LowLFHEToConcreteCAPI/LowLFHEToConcreteCAPI.cpp index df52e99a6..2d13e12b1 100644 --- a/compiler/lib/Conversion/LowLFHEToConcreteCAPI/LowLFHEToConcreteCAPI.cpp +++ b/compiler/lib/Conversion/LowLFHEToConcreteCAPI/LowLFHEToConcreteCAPI.cpp @@ -327,7 +327,7 @@ mlir::LogicalResult insertForwardDeclarations(mlir::Operation *op, /// ``` /// to /// ``` -/// err = constant 0 : i64 +/// err = arith.constant 0 : i64 /// call_op(err, out, arg0, arg1); /// ``` template @@ -350,10 +350,10 @@ struct LowLFHEOpToConcreteCAPICallPattern : public mlir::OpRewritePattern { // Replace the operation with a call to the `funcName` { // Create the err value - auto errOp = rewriter.create(op.getLoc(), - rewriter.getIndexAttr(0)); + auto errOp = rewriter.create( + op.getLoc(), rewriter.getIndexAttr(0)); // Add the call to the allocation - auto lweSizeOp = rewriter.create( + auto lweSizeOp = rewriter.create( op.getLoc(), rewriter.getIndexAttr(lweResultType.getSize())); mlir::SmallVector allocOperands{errOp, lweSizeOp}; auto allocGeneric = rewriter.create( @@ -411,10 +411,10 @@ struct LowLFHEZeroOpPattern auto lweResultType = resultType.cast(); // Create the err value - auto errOp = rewriter.create(op.getLoc(), - rewriter.getIndexAttr(0)); + auto errOp = rewriter.create( + op.getLoc(), rewriter.getIndexAttr(0)); // Allocate a fresh new ciphertext - auto lweSizeOp = rewriter.create( + auto lweSizeOp = rewriter.create( op.getLoc(), rewriter.getIndexAttr(lweResultType.getSize())); mlir::SmallVector allocOperands{errOp, lweSizeOp}; auto allocGeneric = rewriter.create( @@ -439,14 +439,14 @@ struct LowLFHEEncodeIntOpPattern matchAndRewrite(mlir::zamalang::LowLFHE::EncodeIntOp op, mlir::PatternRewriter &rewriter) const override { { - mlir::Value castedInt = rewriter.create( + mlir::Value castedInt = rewriter.create( op.getLoc(), rewriter.getIntegerType(64), op->getOperands().front()); - mlir::Value constantShiftOp = rewriter.create( + mlir::Value constantShiftOp = rewriter.create( op.getLoc(), rewriter.getI64IntegerAttr(64 - op.getType().getP())); mlir::Type resultType = rewriter.getIntegerType(64); - rewriter.replaceOpWithNewOp(op, resultType, castedInt, - constantShiftOp); + rewriter.replaceOpWithNewOp( + op, resultType, castedInt, constantShiftOp); } return mlir::success(); }; @@ -462,7 +462,7 @@ struct LowLFHEIntToCleartextOpPattern mlir::LogicalResult matchAndRewrite(mlir::zamalang::LowLFHE::IntToCleartextOp op, mlir::PatternRewriter &rewriter) const override { - mlir::Value castedInt = rewriter.replaceOpWithNewOp( + mlir::Value castedInt = rewriter.replaceOpWithNewOp( op, rewriter.getIntegerType(64), op->getOperands().front()); return mlir::success(); }; @@ -507,12 +507,12 @@ struct GlweFromTableOpPattern } } - auto errOp = rewriter.create(op.getLoc(), - rewriter.getIndexAttr(0)); + auto errOp = rewriter.create( + op.getLoc(), rewriter.getIndexAttr(0)); // allocate two glwe to build accumulator auto glweSizeOp = - rewriter.create(op.getLoc(), op->getAttr("k")); - auto polySizeOp = rewriter.create( + rewriter.create(op.getLoc(), op->getAttr("k")); + auto polySizeOp = rewriter.create( op.getLoc(), op->getAttr("polynomialSize")); mlir::SmallVector allocGlweOperands{errOp, glweSizeOp, polySizeOp}; @@ -536,11 +536,11 @@ struct GlweFromTableOpPattern op->getOperandTypes().front().cast(); assert(rankedTensorType.getRank() == 1 && "table lookup must be of a single dimension"); - auto sizeOp = rewriter.create( + auto sizeOp = rewriter.create( op.getLoc(), rewriter.getI64IntegerAttr(rankedTensorType.getDimSize(0))); auto precisionOp = - rewriter.create(op.getLoc(), op->getAttr("p")); + rewriter.create(op.getLoc(), op->getAttr("p")); mlir::SmallVector ForeignPlaintextListOperands{ errOp, op->getOperand(0), sizeOp, precisionOp}; auto foreignPlaintextListOp = rewriter.create( @@ -583,11 +583,11 @@ struct LowLFHEBootstrapLweOpPattern auto resultType = op->getResultTypes().front(); auto bstOutputSize = resultType.cast().getSize(); - auto errOp = rewriter.create(op.getLoc(), - rewriter.getIndexAttr(0)); + auto errOp = rewriter.create( + op.getLoc(), rewriter.getIndexAttr(0)); // allocate the result lwe ciphertext, should be of a generic type, to cast // before return - auto lweSizeOp = rewriter.create( + auto lweSizeOp = rewriter.create( op.getLoc(), rewriter.getIndexAttr(bstOutputSize)); mlir::SmallVector allocLweCtOperands{errOp, lweSizeOp}; auto allocateGenericLweCtOp = rewriter.create( @@ -640,11 +640,11 @@ struct LowLFHEKeySwitchLweOpPattern mlir::LogicalResult matchAndRewrite(mlir::zamalang::LowLFHE::KeySwitchLweOp op, mlir::PatternRewriter &rewriter) const override { - auto errOp = rewriter.create(op.getLoc(), - rewriter.getIndexAttr(0)); + auto errOp = rewriter.create( + op.getLoc(), rewriter.getIndexAttr(0)); // allocate the result lwe ciphertext, should be of a generic type, to cast // before return - auto lweSizeOp = rewriter.create( + auto lweSizeOp = rewriter.create( op.getLoc(), rewriter.getIndexAttr( op->getAttr("outputLweSize").cast().getInt())); @@ -717,7 +717,8 @@ void LowLFHEToConcreteCAPIPass::runOnOperation() { mlir::ConversionTarget target(getContext()); target.addIllegalDialect(); target.addLegalDialect(); + mlir::memref::MemRefDialect, + mlir::arith::ArithmeticDialect>(); // Setup rewrite patterns mlir::RewritePatternSet patterns(&getContext()); diff --git a/compiler/lib/Conversion/MLIRLowerableDialectsToLLVM/MLIRLowerableDialectsToLLVM.cpp b/compiler/lib/Conversion/MLIRLowerableDialectsToLLVM/MLIRLowerableDialectsToLLVM.cpp index b79504d94..83d8f4dd8 100644 --- a/compiler/lib/Conversion/MLIRLowerableDialectsToLLVM/MLIRLowerableDialectsToLLVM.cpp +++ b/compiler/lib/Conversion/MLIRLowerableDialectsToLLVM/MLIRLowerableDialectsToLLVM.cpp @@ -3,6 +3,7 @@ #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" +#include "mlir/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.h" #include "mlir/Conversion/LLVMCommon/ConversionTarget.h" #include "mlir/Conversion/LLVMCommon/TypeConverter.h" #include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h" @@ -54,6 +55,8 @@ void MLIRLowerableDialectsToLLVMPass::runOnOperation() { mlir::RewritePatternSet patterns(&getContext()); mlir::populateLoopToStdConversionPatterns(patterns); mlir::populateStdToLLVMConversionPatterns(typeConverter, patterns); + mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter, + patterns); mlir::populateMemRefToLLVMConversionPatterns(typeConverter, patterns); // Apply a `FullConversion` to `llvm`. diff --git a/compiler/lib/Conversion/MidLFHEGlobalParametrization/MidLFHEGlobalParametrization.cpp b/compiler/lib/Conversion/MidLFHEGlobalParametrization/MidLFHEGlobalParametrization.cpp index 0d471aba0..6e80c4196 100644 --- a/compiler/lib/Conversion/MidLFHEGlobalParametrization/MidLFHEGlobalParametrization.cpp +++ b/compiler/lib/Conversion/MidLFHEGlobalParametrization/MidLFHEGlobalParametrization.cpp @@ -148,8 +148,8 @@ struct MidLFHEApplyLookupTablePaddingPattern op.getType().cast(); auto expectedSize = 1 << glweInType.getP(); if (tabulatedLambdaType.getShape()[0] < expectedSize) { - auto constantOp = - mlir::dyn_cast_or_null(op.l_cst().getDefiningOp()); + auto constantOp = mlir::dyn_cast_or_null( + op.l_cst().getDefiningOp()); if (constantOp == nullptr) { op.emitError() << "padding for non-constant operator is NYI"; return mlir::failure(); @@ -174,8 +174,8 @@ struct MidLFHEApplyLookupTablePaddingPattern {expectedSize}, rewriter.getIntegerType(integerSize)); auto newDenseVals = mlir::DenseIntElementsAttr::get(newDenseValsType, rawNewDenseVals); - auto newConstantOp = - rewriter.create(constantOp.getLoc(), newDenseVals); + auto newConstantOp = rewriter.create( + constantOp.getLoc(), newDenseVals); // Replace the apply_lookup_table with the new constant mlir::SmallVector newResultTypes{op.getType()}; llvm::SmallVector newOperands{op.ct(), newConstantOp}; @@ -227,7 +227,7 @@ void populateWithMidLFHEApplyLookupTableParametrizationPattern( void populateWithMidLFHEApplyLookupTablePaddingPattern( mlir::RewritePatternSet &patterns, mlir::ConversionTarget &target) { patterns.add(patterns.getContext()); - target.addLegalOp(); + target.addLegalOp(); target.addDynamicallyLegalOp( [&](mlir::zamalang::MidLFHE::ApplyLookupTable op) { auto glweInType = diff --git a/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp b/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp index b8f4335d7..cf64a2f73 100644 --- a/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp +++ b/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -210,7 +211,7 @@ static std::string APIntToStringValUnsigned(const llvm::APInt &i) { // Calculates the square of the 2-norm of a tensor initialized with a // dense matrix of constant, signless integers. Aborts if the value // type or initialization of of `cstOp` is incorrect. -static llvm::APInt denseCstTensorNorm2Sq(mlir::ConstantOp cstOp) { +static llvm::APInt denseCstTensorNorm2Sq(mlir::arith::ConstantOp cstOp) { mlir::DenseIntElementsAttr denseVals = cstOp->getAttrOfType("value"); @@ -272,8 +273,9 @@ static llvm::APInt getSqMANP( "Only dot operations with tensors that are function arguments are " "currently supported"); - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(1).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(1).get().getDefiningOp()); if (cstOp) { // Dot product between a vector of encrypted integers and a vector @@ -320,8 +322,9 @@ static llvm::APInt getSqMANP( operandMANPs[0]->getValue().getMANP().hasValue() && "Missing squared Minimal Arithmetic Noise Padding for encrypted operand"); - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(1).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(1).get().getDefiningOp()); llvm::APInt eNorm = operandMANPs[0]->getValue().getMANP().getValue(); llvm::APInt sqNorm; @@ -374,8 +377,9 @@ static llvm::APInt getSqMANP( llvm::APInt eNorm = operandMANPs[1]->getValue().getMANP().getValue(); llvm::APInt sqNorm; - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(0).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(0).get().getDefiningOp()); if (cstOp) { // For constant plaintext operands simply use the constant value @@ -404,8 +408,9 @@ static llvm::APInt getSqMANP( operandMANPs[0]->getValue().getMANP().hasValue() && "Missing squared Minimal Arithmetic Noise Padding for encrypted operand"); - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(1).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(1).get().getDefiningOp()); llvm::APInt eNorm = operandMANPs[0]->getValue().getMANP().getValue(); llvm::APInt sqNorm; @@ -445,8 +450,9 @@ static llvm::APInt getSqMANP( llvm::APInt eNorm = operandMANPs[0]->getValue().getMANP().getValue(); llvm::APInt sqNorm; - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(1).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(1).get().getDefiningOp()); mlir::DenseIntElementsAttr denseVals = cstOp ? cstOp->getAttrOfType("value") : nullptr; @@ -507,8 +513,9 @@ static llvm::APInt getSqMANP( llvm::APInt eNorm = operandMANPs[1]->getValue().getMANP().getValue(); llvm::APInt sqNorm; - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(0).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(0).get().getDefiningOp()); mlir::DenseIntElementsAttr denseVals = cstOp ? cstOp->getAttrOfType("value") : nullptr; @@ -553,8 +560,9 @@ static llvm::APInt getSqMANP( llvm::APInt eNorm = operandMANPs[0]->getValue().getMANP().getValue(); llvm::APInt sqNorm; - mlir::ConstantOp cstOp = llvm::dyn_cast_or_null( - op->getOpOperand(1).get().getDefiningOp()); + mlir::arith::ConstantOp cstOp = + llvm::dyn_cast_or_null( + op->getOpOperand(1).get().getDefiningOp()); mlir::DenseIntElementsAttr denseVals = cstOp ? cstOp->getAttrOfType("value") : nullptr; @@ -734,7 +742,7 @@ struct MANPAnalysis : public mlir::ForwardDataFlowAnalysis { } } - else if (llvm::isa(op)) { + else if (llvm::isa(op)) { isDummy = true; } else if (llvm::isa( *op->getDialect())) { diff --git a/compiler/tests/Conversion/HLFHEToMidLFHE/add_eint_int.mlir b/compiler/tests/Conversion/HLFHEToMidLFHE/add_eint_int.mlir index 5cc76254a..7ec7e8409 100644 --- a/compiler/tests/Conversion/HLFHEToMidLFHE/add_eint_int.mlir +++ b/compiler/tests/Conversion/HLFHEToMidLFHE/add_eint_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @add_eint_int(%arg0: !MidLFHE.glwe<{_,_,_}{7}>) -> !MidLFHE.glwe<{_,_,_}{7}> func @add_eint_int(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_glwe_int"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{_,_,_}{7}>, i8) -> !MidLFHE.glwe<{_,_,_}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{_,_,_}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<7>, i8) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/Conversion/HLFHEToMidLFHE/apply_univariate_cst.mlir b/compiler/tests/Conversion/HLFHEToMidLFHE/apply_univariate_cst.mlir index 899e7b920..a451db9e3 100644 --- a/compiler/tests/Conversion/HLFHEToMidLFHE/apply_univariate_cst.mlir +++ b/compiler/tests/Conversion/HLFHEToMidLFHE/apply_univariate_cst.mlir @@ -2,10 +2,10 @@ // CHECK-LABEL: func @apply_lookup_table_cst(%arg0: !MidLFHE.glwe<{_,_,_}{7}>) -> !MidLFHE.glwe<{_,_,_}{7}> func @apply_lookup_table_cst(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - // CHECK-NEXT: %[[TABLE:.*]] = constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64> + // CHECK-NEXT: %[[TABLE:.*]] = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64> // CHECK-NEXT: %[[V0:.*]] = "MidLFHE.apply_lookup_table"(%arg0, %[[TABLE]]) {baseLogBS = -1 : i32, baseLogKS = -1 : i32, k = -1 : i32, levelBS = -1 : i32, levelKS = -1 : i32, outputSizeKS = -1 : i32, polynomialSize = -1 : i32} : (!MidLFHE.glwe<{_,_,_}{7}>, tensor<128xi64>) -> !MidLFHE.glwe<{_,_,_}{7}> // CHECK-NEXT: return %[[V0]] : !MidLFHE.glwe<{_,_,_}{7}> - %tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> + %tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> %1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<7>, tensor<128xi64>) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/Conversion/HLFHEToMidLFHE/mul_eint_int.mlir b/compiler/tests/Conversion/HLFHEToMidLFHE/mul_eint_int.mlir index 50682d056..a8fa5fc59 100644 --- a/compiler/tests/Conversion/HLFHEToMidLFHE/mul_eint_int.mlir +++ b/compiler/tests/Conversion/HLFHEToMidLFHE/mul_eint_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @mul_eint_int(%arg0: !MidLFHE.glwe<{_,_,_}{7}>) -> !MidLFHE.glwe<{_,_,_}{7}> func @mul_eint_int(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.mul_glwe_int"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{_,_,_}{7}>, i8) -> !MidLFHE.glwe<{_,_,_}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{_,_,_}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "HLFHE.mul_eint_int"(%arg0, %0): (!HLFHE.eint<7>, i8) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/Conversion/HLFHEToMidLFHE/sub_int_eint.mlir b/compiler/tests/Conversion/HLFHEToMidLFHE/sub_int_eint.mlir index 3de90a6a7..2fdacfdc6 100644 --- a/compiler/tests/Conversion/HLFHEToMidLFHE/sub_int_eint.mlir +++ b/compiler/tests/Conversion/HLFHEToMidLFHE/sub_int_eint.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @sub_int_eint(%arg0: !MidLFHE.glwe<{_,_,_}{7}>) -> !MidLFHE.glwe<{_,_,_}{7}> func @sub_int_eint(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.sub_int_glwe"(%[[V1]], %arg0) : (i8, !MidLFHE.glwe<{_,_,_}{7}>) -> !MidLFHE.glwe<{_,_,_}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{_,_,_}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "HLFHE.sub_int_eint"(%0, %arg0): (i8, !HLFHE.eint<7>) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/bootstrap.mlir b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/bootstrap.mlir index fa9d099c5..57158e1f5 100644 --- a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/bootstrap.mlir +++ b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/bootstrap.mlir @@ -16,8 +16,8 @@ // CHECK-NEXT: func private @allocate_lwe_ciphertext_u64(index, index) -> !LowLFHE.lwe_ciphertext<_,_> // CHECK-LABEL: func @bootstrap_lwe(%arg0: !LowLFHE.lwe_ciphertext<1024,4>, %arg1: !LowLFHE.glwe_ciphertext) -> !LowLFHE.lwe_ciphertext<1024,4> func @bootstrap_lwe(%arg0: !LowLFHE.lwe_ciphertext<1024,4>, %arg1: !LowLFHE.glwe_ciphertext) -> !LowLFHE.lwe_ciphertext<1024,4> { - // CHECK-NEXT: %[[ERR:.*]] = constant 0 : index - // CHECK-NEXT: %[[C0:.*]] = constant 1024 : index + // CHECK-NEXT: %[[ERR:.*]] = arith.constant 0 : index + // CHECK-NEXT: %[[C0:.*]] = arith.constant 1024 : index // CHECK-NEXT: %[[V1:.*]] = call @allocate_lwe_ciphertext_u64(%[[ERR]], %[[C0]]) : (index, index) -> !LowLFHE.lwe_ciphertext<_,_> // CHECK-NEXT: %[[V2:.*]] = call @getGlobalBootstrapKey() : () -> !LowLFHE.lwe_bootstrap_key // CHECK-NEXT: %[[V3:.*]] = builtin.unrealized_conversion_cast %arg0 : !LowLFHE.lwe_ciphertext<1024,4> to !LowLFHE.lwe_ciphertext<_,_> diff --git a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/glwe_from_table.mlir b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/glwe_from_table.mlir index 923a73c64..815366d04 100644 --- a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/glwe_from_table.mlir +++ b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/glwe_from_table.mlir @@ -17,14 +17,14 @@ // CHECK-NEXT: func private @allocate_lwe_ciphertext_u64(index, index) -> !LowLFHE.lwe_ciphertext<_,_> // CHECK-LABEL: func @glwe_from_table(%arg0: tensor<16xi64>) -> !LowLFHE.glwe_ciphertext func @glwe_from_table(%arg0: tensor<16xi64>) -> !LowLFHE.glwe_ciphertext { - // CHECK-NEXT: %[[V0:.*]] = constant 0 : index - // CHECK-NEXT: %[[C0:.*]] = constant 1 : i32 - // CHECK-NEXT: %[[C1:.*]] = constant 1024 : i32 + // CHECK-NEXT: %[[V0:.*]] = arith.constant 0 : index + // CHECK-NEXT: %[[C0:.*]] = arith.constant 1 : i32 + // CHECK-NEXT: %[[C1:.*]] = arith.constant 1024 : i32 // CHECK-NEXT: %[[V1:.*]] = call @allocate_glwe_ciphertext_u64(%[[V0]], %[[C0]], %[[C1]]) : (index, i32, i32) -> !LowLFHE.glwe_ciphertext // CHECK-NEXT: %[[V2:.*]] = call @allocate_glwe_ciphertext_u64(%[[V0]], %[[C0]], %[[C1]]) : (index, i32, i32) -> !LowLFHE.glwe_ciphertext // CHECK-NEXT: %[[V3:.*]] = call @allocate_plaintext_list_u64(%[[V0]], %[[C1]]) : (index, i32) -> !LowLFHE.plaintext_list - // CHECK-NEXT: %[[C2:.*]] = constant 16 : i64 - // CHECK-NEXT: %[[C3:.*]] = constant 4 : i32 + // CHECK-NEXT: %[[C2:.*]] = arith.constant 16 : i64 + // CHECK-NEXT: %[[C3:.*]] = arith.constant 4 : i32 // CHECK-NEXT: %[[V4:.*]] = call @runtime_foreign_plaintext_list_u64(%[[V0]], %arg0, %[[C2]], %[[C3]]) : (index, tensor<16xi64>, i64, i32) -> !LowLFHE.foreign_plaintext_list // CHECK-NEXT: call @fill_plaintext_list_with_expansion_u64(%[[V0]], %[[V3]], %[[V4]]) : (index, !LowLFHE.plaintext_list, !LowLFHE.foreign_plaintext_list) -> () // CHECK-NEXT: call @add_plaintext_list_glwe_ciphertext_u64(%[[V0]], %[[V1]], %[[V2]], %[[V3]]) : (index, !LowLFHE.glwe_ciphertext, !LowLFHE.glwe_ciphertext, !LowLFHE.plaintext_list) -> () diff --git a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/keyswitch_lwe.mlir b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/keyswitch_lwe.mlir index d7590ac56..5077fd23d 100644 --- a/compiler/tests/Conversion/LowLFHEToConcreteCAPI/keyswitch_lwe.mlir +++ b/compiler/tests/Conversion/LowLFHEToConcreteCAPI/keyswitch_lwe.mlir @@ -16,8 +16,8 @@ // CHECK-NEXT: func private @allocate_lwe_ciphertext_u64(index, index) -> !LowLFHE.lwe_ciphertext<_,_> // CHECK-LABEL: func @keyswitch_lwe(%arg0: !LowLFHE.lwe_ciphertext<1024,4>) -> !LowLFHE.lwe_ciphertext<1024,4> func @keyswitch_lwe(%arg0: !LowLFHE.lwe_ciphertext<1024,4>) -> !LowLFHE.lwe_ciphertext<1024,4> { - // CHECK-NEXT: %[[ERR:.*]] = constant 0 : index - // CHECK-NEXT: %[[C0:.*]] = constant 1 : index + // CHECK-NEXT: %[[ERR:.*]] = arith.constant 0 : index + // CHECK-NEXT: %[[C0:.*]] = arith.constant 1 : index // CHECK-NEXT: %[[V1:.*]] = call @allocate_lwe_ciphertext_u64(%[[ERR]], %[[C0]]) : (index, index) -> !LowLFHE.lwe_ciphertext<_,_> // CHECK-NEXT: %[[V2:.*]] = call @getGlobalKeyswitchKey() : () -> !LowLFHE.lwe_key_switch_key // CHECK-NEXT: %[[V3:.*]] = builtin.unrealized_conversion_cast %arg0 : !LowLFHE.lwe_ciphertext<1024,4> to !LowLFHE.lwe_ciphertext<_,_> diff --git a/compiler/tests/Conversion/MidLFHEToLowLFHE/add_glwe_int.mlir b/compiler/tests/Conversion/MidLFHEToLowLFHE/add_glwe_int.mlir index 8c9284546..e7a554bd2 100644 --- a/compiler/tests/Conversion/MidLFHEToLowLFHE/add_glwe_int.mlir +++ b/compiler/tests/Conversion/MidLFHEToLowLFHE/add_glwe_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @add_glwe_const_int(%arg0: !LowLFHE.lwe_ciphertext<1024,7>) -> !LowLFHE.lwe_ciphertext<1024,7> func @add_glwe_const_int(%arg0: !MidLFHE.glwe<{1024,1,64}{7}>) -> !MidLFHE.glwe<{1024,1,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "LowLFHE.encode_int"(%[[V1]]) : (i8) -> !LowLFHE.plaintext<8> // CHECK-NEXT: %[[V3:.*]] = "LowLFHE.add_plaintext_lwe_ciphertext"(%arg0, %[[V2]]) : (!LowLFHE.lwe_ciphertext<1024,7>, !LowLFHE.plaintext<8>) -> !LowLFHE.lwe_ciphertext<1024,7> // CHECK-NEXT: return %[[V3]] : !LowLFHE.lwe_ciphertext<1024,7> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,1,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,1,64}{7}>) return %1: !MidLFHE.glwe<{1024,1,64}{7}> } diff --git a/compiler/tests/Conversion/MidLFHEToLowLFHE/apply_lookup_table_cst.mlir b/compiler/tests/Conversion/MidLFHEToLowLFHE/apply_lookup_table_cst.mlir index 79581bbce..04debdf60 100644 --- a/compiler/tests/Conversion/MidLFHEToLowLFHE/apply_lookup_table_cst.mlir +++ b/compiler/tests/Conversion/MidLFHEToLowLFHE/apply_lookup_table_cst.mlir @@ -2,12 +2,12 @@ // CHECK-LABEL: func @apply_lookup_table_cst(%arg0: !LowLFHE.lwe_ciphertext<2048,4>) -> !LowLFHE.lwe_ciphertext<2048,4> func @apply_lookup_table_cst(%arg0: !MidLFHE.glwe<{2048,1,64}{4}>) -> !MidLFHE.glwe<{2048,1,64}{4}> { - // CHECK-NEXT: %[[TABLE:.*]] = constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64> + // CHECK-NEXT: %[[TABLE:.*]] = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64> // CHECK-NEXT: %[[V1:.*]] = "LowLFHE.glwe_from_table"(%[[TABLE]]) {k = 1 : i32, p = 4 : i32, polynomialSize = 2048 : i32} : (tensor<16xi64>) -> !LowLFHE.glwe_ciphertext // CHECK-NEXT: %[[V2:.*]] = "LowLFHE.keyswitch_lwe"(%arg0) {baseLog = 2 : i32, inputLweSize = 1 : i32, level = 3 : i32, outputLweSize = 600 : i32} : (!LowLFHE.lwe_ciphertext<2048,4>) -> !LowLFHE.lwe_ciphertext<600,4> // CHECK-NEXT: %[[V3:.*]] = "LowLFHE.bootstrap_lwe"(%[[V2]], %[[V1]]) {baseLog = 4 : i32, k = 1 : i32, level = 5 : i32, polynomialSize = 2048 : i32} : (!LowLFHE.lwe_ciphertext<600,4>, !LowLFHE.glwe_ciphertext) -> !LowLFHE.lwe_ciphertext<2048,4> // CHECK-NEXT: return %[[V3]] : !LowLFHE.lwe_ciphertext<2048,4> - %tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64> + %tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64> %1 = "MidLFHE.apply_lookup_table"(%arg0, %tlu){k=1:i32, polynomialSize=2048:i32, levelKS=3:i32, baseLogKS=2:i32, levelBS=5:i32, baseLogBS=4:i32, outputSizeKS=600:i32}: (!MidLFHE.glwe<{2048,1,64}{4}>, tensor<16xi64>) -> (!MidLFHE.glwe<{2048,1,64}{4}>) return %1: !MidLFHE.glwe<{2048,1,64}{4}> } diff --git a/compiler/tests/Conversion/MidLFHEToLowLFHE/mul_glwe_int.mlir b/compiler/tests/Conversion/MidLFHEToLowLFHE/mul_glwe_int.mlir index fa1e01b91..e7c5f9155 100644 --- a/compiler/tests/Conversion/MidLFHEToLowLFHE/mul_glwe_int.mlir +++ b/compiler/tests/Conversion/MidLFHEToLowLFHE/mul_glwe_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @mul_glwe_const_int(%arg0: !LowLFHE.lwe_ciphertext<1024,7>) -> !LowLFHE.lwe_ciphertext<1024,7> func @mul_glwe_const_int(%arg0: !MidLFHE.glwe<{1024,1,64}{7}>) -> !MidLFHE.glwe<{1024,1,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "LowLFHE.int_to_cleartext"(%[[V1]]) : (i8) -> !LowLFHE.cleartext<8> // CHECK-NEXT: %[[V3:.*]] = "LowLFHE.mul_cleartext_lwe_ciphertext"(%arg0, %[[V2]]) : (!LowLFHE.lwe_ciphertext<1024,7>, !LowLFHE.cleartext<8>) -> !LowLFHE.lwe_ciphertext<1024,7> // CHECK-NEXT: return %[[V3]] : !LowLFHE.lwe_ciphertext<1024,7> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,1,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,1,64}{7}>) return %1: !MidLFHE.glwe<{1024,1,64}{7}> } diff --git a/compiler/tests/Conversion/MidLFHEToLowLFHE/sub_int_glwe.mlir b/compiler/tests/Conversion/MidLFHEToLowLFHE/sub_int_glwe.mlir index fb09a1e39..51b755acf 100644 --- a/compiler/tests/Conversion/MidLFHEToLowLFHE/sub_int_glwe.mlir +++ b/compiler/tests/Conversion/MidLFHEToLowLFHE/sub_int_glwe.mlir @@ -2,12 +2,12 @@ // CHECK-LABEL: func @sub_const_int_glwe(%arg0: !LowLFHE.lwe_ciphertext<1024,7>) -> !LowLFHE.lwe_ciphertext<1024,7> func @sub_const_int_glwe(%arg0: !MidLFHE.glwe<{1024,1,64}{7}>) -> !MidLFHE.glwe<{1024,1,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[NEG:.*]] = "LowLFHE.negate_lwe_ciphertext"(%arg0) : (!LowLFHE.lwe_ciphertext<1024,7>) -> !LowLFHE.lwe_ciphertext<1024,7> // CHECK-NEXT: %[[V2:.*]] = "LowLFHE.encode_int"(%[[V1]]) : (i8) -> !LowLFHE.plaintext<8> // CHECK-NEXT: %[[V3:.*]] = "LowLFHE.add_plaintext_lwe_ciphertext"(%[[NEG]], %[[V2]]) : (!LowLFHE.lwe_ciphertext<1024,7>, !LowLFHE.plaintext<8>) -> !LowLFHE.lwe_ciphertext<1024,7> // CHECK-NEXT: return %[[V3]] : !LowLFHE.lwe_ciphertext<1024,7> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,1,64}{7}>) -> (!MidLFHE.glwe<{1024,1,64}{7}>) return %1: !MidLFHE.glwe<{1024,1,64}{7}> } diff --git a/compiler/tests/Dialect/HLFHE/Analysis/MANP.mlir b/compiler/tests/Dialect/HLFHE/Analysis/MANP.mlir index ad9f2e2e2..2b4eb1d1c 100644 --- a/compiler/tests/Dialect/HLFHE/Analysis/MANP.mlir +++ b/compiler/tests/Dialect/HLFHE/Analysis/MANP.mlir @@ -12,7 +12,7 @@ func @single_zero() -> !HLFHE.eint<2> func @single_cst_dot(%t: tensor<4x!HLFHE.eint<2>>) -> !HLFHE.eint<2> { - %cst = constant dense<[1, 2, 3, 4]> : tensor<4xi3> + %cst = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi3> // CHECK: %[[ret:.*]] = "HLFHE.dot_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 6 : ui{{[[0-9]+}}} : (tensor<4x!HLFHE.eint<2>>, tensor<4xi3>) -> !HLFHE.eint<2> %0 = "HLFHE.dot_eint_int"(%t, %cst) : (tensor<4x!HLFHE.eint<2>>, tensor<4xi3>) -> !HLFHE.eint<2> @@ -34,7 +34,7 @@ func @single_dyn_dot(%t: tensor<4x!HLFHE.eint<2>>, %dyn: tensor<4xi3>) -> !HLFHE func @single_cst_add_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %cst = constant 3 : i3 + %cst = arith.constant 3 : i3 // CHECK: %[[ret:.*]] = "HLFHE.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.add_eint_int"(%e, %cst) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -66,7 +66,7 @@ func @single_add_eint(%e0: !HLFHE.eint<2>, %e1: !HLFHE.eint<2>) -> !HLFHE.eint<2 func @single_cst_sub_int_eint(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %cst = constant 3 : i3 + %cst = arith.constant 3 : i3 // CHECK: %[[ret:.*]] = "HLFHE.sub_int_eint"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (i3, !HLFHE.eint<2>) -> !HLFHE.eint<2> %0 = "HLFHE.sub_int_eint"(%cst, %e) : (i3, !HLFHE.eint<2>) -> !HLFHE.eint<2> @@ -88,7 +88,7 @@ func @single_dyn_sub_int_eint(%e: !HLFHE.eint<2>, %i: i3) -> !HLFHE.eint<2> func @single_cst_mul_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %cst = constant 3 : i3 + %cst = arith.constant 3 : i3 // %0 = "HLFHE.mul_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 3 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.mul_eint_int"(%e, %cst) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -118,10 +118,10 @@ func @single_apply_lookup_table(%arg0: !HLFHE.eint<2>, %arg1: tensor<4xi64>) -> func @chain_add_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %cst0 = constant 3 : i3 - %cst1 = constant 7 : i3 - %cst2 = constant 2 : i3 - %cst3 = constant 1 : i3 + %cst0 = arith.constant 3 : i3 + %cst1 = arith.constant 7 : i3 + %cst2 = arith.constant 2 : i3 + %cst3 = arith.constant 1 : i3 // CHECK: %[[ret:.*]] = "HLFHE.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.add_eint_int"(%e, %cst0) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -139,10 +139,10 @@ func @chain_add_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> func @dag_add_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %Acst0 = constant 3 : i3 - %Acst1 = constant 7 : i3 - %Acst2 = constant 2 : i3 - %Acst3 = constant 1 : i3 + %Acst0 = arith.constant 3 : i3 + %Acst1 = arith.constant 7 : i3 + %Acst2 = arith.constant 2 : i3 + %Acst3 = arith.constant 1 : i3 // CHECK: %[[ret:.*]] = "HLFHE.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %A0 = "HLFHE.add_eint_int"(%e, %Acst0) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -153,12 +153,12 @@ func @dag_add_eint_int(%e: !HLFHE.eint<2>) -> !HLFHE.eint<2> // CHECK-NEXT: %[[ret:.*]] = "HLFHE.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 8 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %A3 = "HLFHE.add_eint_int"(%A2, %Acst3) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> - %Bcst0 = constant 1 : i3 - %Bcst1 = constant 5 : i3 - %Bcst2 = constant 2 : i3 - %Bcst3 = constant 7 : i3 - %Bcst4 = constant 4 : i3 - %Bcst5 = constant 7 : i3 + %Bcst0 = arith.constant 1 : i3 + %Bcst1 = arith.constant 5 : i3 + %Bcst2 = arith.constant 2 : i3 + %Bcst3 = arith.constant 7 : i3 + %Bcst4 = arith.constant 4 : i3 + %Bcst5 = arith.constant 7 : i3 // CHECK: %[[ret:.*]] = "HLFHE.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 2 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %B0 = "HLFHE.add_eint_int"(%e, %Bcst0) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> diff --git a/compiler/tests/Dialect/HLFHE/Analysis/MANP_linalg.mlir b/compiler/tests/Dialect/HLFHE/Analysis/MANP_linalg.mlir index e4a0fdda9..322223e02 100644 --- a/compiler/tests/Dialect/HLFHE/Analysis/MANP_linalg.mlir +++ b/compiler/tests/Dialect/HLFHE/Analysis/MANP_linalg.mlir @@ -2,7 +2,7 @@ func @single_cst_add_eint_int(%t: tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> { - %cst = std.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> + %cst = arith.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> // CHECK: %[[ret:.*]] = "HLFHELinalg.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> %0 = "HLFHELinalg.add_eint_int"(%t, %cst) : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> @@ -34,7 +34,7 @@ func @single_add_eint(%e0: tensor<8x!HLFHE.eint<2>>, %e1: tensor<8x!HLFHE.eint<2 func @single_cst_sub_int_eint(%e: tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> { - %cst = std.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> + %cst = arith.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> // CHECK: %[[ret:.*]] = "HLFHELinalg.sub_int_eint"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (tensor<8xi3>, tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> %0 = "HLFHELinalg.sub_int_eint"(%cst, %e) : (tensor<8xi3>, tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> @@ -56,7 +56,7 @@ func @single_dyn_sub_int_eint(%e: tensor<8x!HLFHE.eint<2>>, %i: tensor<8xi3>) -> func @single_cst_mul_eint_int(%e: tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> { - %cst = std.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> + %cst = arith.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> // %0 = "HLFHELinalg.mul_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 3 : ui{{[0-9]+}}} : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> %0 = "HLFHELinalg.mul_eint_int"(%e, %cst) : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> @@ -78,10 +78,10 @@ func @single_dyn_mul_eint_int(%e: tensor<8x!HLFHE.eint<2>>, %i: tensor<8xi3>) -> func @chain_add_eint_int(%e: tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2>> { - %cst0 = std.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> - %cst1 = std.constant dense<[0, 7, 2, 5, 6, 2, 1, 7]> : tensor<8xi3> - %cst2 = std.constant dense<[0, 1, 2, 0, 1, 2, 0, 1]> : tensor<8xi3> - %cst3 = std.constant dense<[0, 1, 1, 0, 0, 1, 0, 1]> : tensor<8xi3> + %cst0 = arith.constant dense<[0, 1, 2, 3, 3, 2, 1, 0]> : tensor<8xi3> + %cst1 = arith.constant dense<[0, 7, 2, 5, 6, 2, 1, 7]> : tensor<8xi3> + %cst2 = arith.constant dense<[0, 1, 2, 0, 1, 2, 0, 1]> : tensor<8xi3> + %cst3 = arith.constant dense<[0, 1, 1, 0, 0, 1, 0, 1]> : tensor<8xi3> // CHECK: %[[ret:.*]] = "HLFHELinalg.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> %0 = "HLFHELinalg.add_eint_int"(%e, %cst0) : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> // CHECK-NEXT: %[[ret:.*]] = "HLFHELinalg.add_eint_int"(%[[op0:.*]], %[[op1:.*]]) {MANP = 8 : ui{{[0-9]+}}} : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> @@ -96,7 +96,7 @@ func @chain_add_eint_int(%e: tensor<8x!HLFHE.eint<2>>) -> tensor<8x!HLFHE.eint<2 // ----- func @apply_lookup_table(%t: tensor<3x3x!HLFHE.eint<2>>) -> tensor<3x3x!HLFHE.eint<3>> { - %lut = std.constant dense<[1,3,5,7]> : tensor<4xi64> + %lut = arith.constant dense<[1,3,5,7]> : tensor<4xi64> // CHECK: %[[RES:.*]] = "HLFHELinalg.apply_lookup_table"(%[[T:.*]], %[[LUT:.*]]) {MANP = 1 : ui1} : (tensor<3x3x!HLFHE.eint<2>>, tensor<4xi64>) -> tensor<3x3x!HLFHE.eint<3>> %res = "HLFHELinalg.apply_lookup_table"(%t, %lut) : (tensor<3x3x!HLFHE.eint<2>>, tensor<4xi64>) -> tensor<3x3x!HLFHE.eint<3>> return %res : tensor<3x3x!HLFHE.eint<3>> @@ -105,7 +105,7 @@ func @apply_lookup_table(%t: tensor<3x3x!HLFHE.eint<2>>) -> tensor<3x3x!HLFHE.ei // ----- func @apply_lookup_table_after_op(%t: tensor<8x!HLFHE.eint<2>>, %i: tensor<8xi3>) -> tensor<8x!HLFHE.eint<3>> { - %lut = std.constant dense<[1,3,5,7]> : tensor<4xi64> + %lut = arith.constant dense<[1,3,5,7]> : tensor<4xi64> // CHECK: %[[V0:.*]] = "HLFHELinalg.mul_eint_int"([[T:.*]], %[[I:.*]]) {MANP = 8 : ui{{[0-9]+}}} : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> %0 = "HLFHELinalg.mul_eint_int"(%t, %i) : (tensor<8x!HLFHE.eint<2>>, tensor<8xi3>) -> tensor<8x!HLFHE.eint<2>> // CHECK-NEXT: %[[RES:.*]] = "HLFHELinalg.apply_lookup_table"(%[[V0:.*]], %[[LUT:.*]]) {MANP = 1 : ui1} : (tensor<8x!HLFHE.eint<2>>, tensor<4xi64>) -> tensor<8x!HLFHE.eint<3>> diff --git a/compiler/tests/Dialect/HLFHE/Analysis/MANP_tensor.mlir b/compiler/tests/Dialect/HLFHE/Analysis/MANP_tensor.mlir index 15dc45f61..548f09a62 100644 --- a/compiler/tests/Dialect/HLFHE/Analysis/MANP_tensor.mlir +++ b/compiler/tests/Dialect/HLFHE/Analysis/MANP_tensor.mlir @@ -13,7 +13,7 @@ func @tensor_from_elements_1(%a: !HLFHE.eint<2>, %b: !HLFHE.eint<2>, %c: !HLFHE. func @tensor_from_elements_2(%a: !HLFHE.eint<2>, %b: !HLFHE.eint<2>, %c: !HLFHE.eint<2>, %d: !HLFHE.eint<2>) -> tensor<4x!HLFHE.eint<2>> { - %cst = constant 3 : i3 + %cst = arith.constant 3 : i3 // CHECK: %[[V0:.*]] = "HLFHE.add_eint_int"(%[[a:.*]], %[[cst:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.add_eint_int"(%a, %cst) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -29,7 +29,7 @@ func @tensor_from_elements_2(%a: !HLFHE.eint<2>, %b: !HLFHE.eint<2>, %c: !HLFHE. func @tensor_extract_1(%t: tensor<4x!HLFHE.eint<2>>) -> !HLFHE.eint<2> { - %cst = constant 1 : index + %cst = arith.constant 1 : index // The MANP value is 1 as the tensor operand is a function argument // CHECK: %[[ret:.*]] = tensor.extract %[[t:.*]][%[[c1:.*]]] {MANP = 1 : ui{{[[0-9]+}}} : tensor<4x!HLFHE.eint<2>> @@ -42,8 +42,8 @@ func @tensor_extract_1(%t: tensor<4x!HLFHE.eint<2>>) -> !HLFHE.eint<2> func @tensor_extract_2(%a: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %c1 = constant 1 : index - %c3 = constant 3 : i3 + %c1 = arith.constant 1 : index + %c3 = arith.constant 3 : i3 // CHECK: %[[V0:.*]] = "HLFHE.add_eint_int"(%[[a:.*]], %[[c1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.add_eint_int"(%a, %c3) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -69,7 +69,7 @@ func @tensor_extract_slice_1(%t: tensor<2x10x!HLFHE.eint<2>>) -> tensor<1x5x!HLF func @tensor_extract_slice_2(%a: !HLFHE.eint<2>) -> tensor<2x!HLFHE.eint<2>> { - %c3 = constant 3 : i3 + %c3 = arith.constant 3 : i3 // CHECK: %[[V0:.*]] = "HLFHE.add_eint_int"(%[[a:.*]], %[[c1:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> %0 = "HLFHE.add_eint_int"(%a, %c3) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> @@ -95,8 +95,8 @@ func @tensor_insert_slice_1(%t0: tensor<2x10x!HLFHE.eint<2>>, %t1: tensor<2x2x!H func @tensor_insert_slice_2(%a: !HLFHE.eint<5>) -> tensor<4x!HLFHE.eint<5>> { - %c3 = constant 3 : i6 - %c6 = constant 6 : i6 + %c3 = arith.constant 3 : i6 + %c6 = arith.constant 6 : i6 // CHECK: %[[V0:.*]] = "HLFHE.add_eint_int"(%[[a:.*]], %[[c3:.*]]) {MANP = 4 : ui{{[0-9]+}}} : (!HLFHE.eint<5>, i6) -> !HLFHE.eint<5> %v0 = "HLFHE.add_eint_int"(%a, %c3) : (!HLFHE.eint<5>, i6) -> !HLFHE.eint<5> diff --git a/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_inputs.mlir b/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_inputs.mlir index 9e91eb794..2e7fec8d1 100644 --- a/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_inputs.mlir +++ b/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_inputs.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.add_eint_int' op should have the width of plain input equals to width of encrypted input + 1 func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %0 = constant 1 : i4 + %0 = arith.constant 1 : i4 %1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i4) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } diff --git a/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_result.mlir b/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_result.mlir index 79d014609..ba82ab61a 100644 --- a/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_result.mlir +++ b/compiler/tests/Dialect/HLFHE/op_add_eint_int_err_result.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.add_eint_int' op should have the width of encrypted inputs and result equals func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<3> { - %0 = constant 1 : i2 + %0 = arith.constant 1 : i2 %1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i2) -> (!HLFHE.eint<3>) return %1: !HLFHE.eint<3> } diff --git a/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_inputs.mlir b/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_inputs.mlir index 45b847b8e..b18b2cb31 100644 --- a/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_inputs.mlir +++ b/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_inputs.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.mul_eint_int' op should have the width of plain input equals to width of encrypted input + 1 func @mul_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %0 = constant 1 : i4 + %0 = arith.constant 1 : i4 %1 = "HLFHE.mul_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i4) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } diff --git a/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_result.mlir b/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_result.mlir index 50f288ba1..647bfb9b4 100644 --- a/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_result.mlir +++ b/compiler/tests/Dialect/HLFHE/op_mul_eint_int_err_result.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.mul_eint_int' op should have the width of encrypted inputs and result equals func @mul_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<3> { - %0 = constant 1 : i2 + %0 = arith.constant 1 : i2 %1 = "HLFHE.mul_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i2) -> (!HLFHE.eint<3>) return %1: !HLFHE.eint<3> } diff --git a/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_inputs.mlir b/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_inputs.mlir index 5bf4c57af..a66569ce5 100644 --- a/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_inputs.mlir +++ b/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_inputs.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.sub_int_eint' op should have the width of plain input equals to width of encrypted input + 1 func @sub_int_eint(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %0 = constant 1 : i4 + %0 = arith.constant 1 : i4 %1 = "HLFHE.sub_int_eint"(%0, %arg0): (i4, !HLFHE.eint<2>) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } diff --git a/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_result.mlir b/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_result.mlir index 3aa512584..df74e684d 100644 --- a/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_result.mlir +++ b/compiler/tests/Dialect/HLFHE/op_sub_int_eint_err_result.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: error: 'HLFHE.sub_int_eint' op should have the width of encrypted inputs and result equals func @sub_int_eint(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<3> { - %0 = constant 1 : i2 + %0 = arith.constant 1 : i2 %1 = "HLFHE.sub_int_eint"(%0, %arg0): (i2, !HLFHE.eint<2>) -> (!HLFHE.eint<3>) return %1: !HLFHE.eint<3> } diff --git a/compiler/tests/Dialect/HLFHE/ops.mlir b/compiler/tests/Dialect/HLFHE/ops.mlir index 44fefdf8e..40c0eca27 100644 --- a/compiler/tests/Dialect/HLFHE/ops.mlir +++ b/compiler/tests/Dialect/HLFHE/ops.mlir @@ -11,33 +11,33 @@ func @zero() -> !HLFHE.eint<2> { // CHECK-LABEL: func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i3 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i3 // CHECK-NEXT: %[[V2:.*]] = "HLFHE.add_eint_int"(%arg0, %[[V1]]) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> // CHECK-NEXT: return %[[V2]] : !HLFHE.eint<2> - %0 = constant 1 : i3 + %0 = arith.constant 1 : i3 %1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } // CHECK-LABEL: func @sub_int_eint(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> func @sub_int_eint(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i3 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i3 // CHECK-NEXT: %[[V2:.*]] = "HLFHE.sub_int_eint"(%[[V1]], %arg0) : (i3, !HLFHE.eint<2>) -> !HLFHE.eint<2> // CHECK-NEXT: return %[[V2]] : !HLFHE.eint<2> - %0 = constant 1 : i3 + %0 = arith.constant 1 : i3 %1 = "HLFHE.sub_int_eint"(%0, %arg0): (i3, !HLFHE.eint<2>) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } // CHECK-LABEL: func @mul_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> func @mul_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i3 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i3 // CHECK-NEXT: %[[V2:.*]] = "HLFHE.mul_eint_int"(%arg0, %[[V1]]) : (!HLFHE.eint<2>, i3) -> !HLFHE.eint<2> // CHECK-NEXT: return %[[V2]] : !HLFHE.eint<2> - %0 = constant 1 : i3 + %0 = arith.constant 1 : i3 %1 = "HLFHE.mul_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } diff --git a/compiler/tests/Dialect/HLFHE/tensor-ops-to-linalg.mlir b/compiler/tests/Dialect/HLFHE/tensor-ops-to-linalg.mlir index 573d03ac9..afc24f214 100644 --- a/compiler/tests/Dialect/HLFHE/tensor-ops-to-linalg.mlir +++ b/compiler/tests/Dialect/HLFHE/tensor-ops-to-linalg.mlir @@ -12,7 +12,7 @@ //CHECK-NEXT: %5 = "MidLFHE.add_glwe"(%4, %arg4) : (!MidLFHE.glwe<{_,_,_}{2}>, !MidLFHE.glwe<{_,_,_}{2}>) -> !MidLFHE.glwe<{_,_,_}{2}> //CHECK-NEXT: linalg.yield %5 : !MidLFHE.glwe<{_,_,_}{2}> //CHECK-NEXT: } -> tensor<1x!MidLFHE.glwe<{_,_,_}{2}>> -//CHECK-NEXT: %c0 = constant 0 : index +//CHECK-NEXT: %c0 = arith.constant 0 : index //CHECK-NEXT: %3 = tensor.extract %2[%c0] : tensor<1x!MidLFHE.glwe<{_,_,_}{2}>> //CHECK-NEXT: return %3 : !MidLFHE.glwe<{_,_,_}{2}> //CHECK-NEXT: } diff --git a/compiler/tests/Dialect/LowLFHE/ops.mlir b/compiler/tests/Dialect/LowLFHE/ops.mlir index fc80bebb5..86e97a143 100644 --- a/compiler/tests/Dialect/LowLFHE/ops.mlir +++ b/compiler/tests/Dialect/LowLFHE/ops.mlir @@ -181,10 +181,10 @@ func @const_cleartext() -> (!LowLFHE.cleartext<8>) { // CHECK-LABEL: func @int_to_cleartext() -> !LowLFHE.cleartext<6> func @int_to_cleartext() -> !LowLFHE.cleartext<6> { - // CHECK-NEXT: %[[V0:.*]] = constant 5 : i6 + // CHECK-NEXT: %[[V0:.*]] = arith.constant 5 : i6 // CHECK-NEXT: %[[V1:.*]] = "LowLFHE.int_to_cleartext"(%[[V0]]) : (i6) -> !LowLFHE.cleartext<6> // CHECK-NEXT: return %[[V1]] : !LowLFHE.cleartext<6> - %0 = constant 5 : i6 + %0 = arith.constant 5 : i6 %1 = "LowLFHE.int_to_cleartext"(%0) : (i6) -> !LowLFHE.cleartext<6> return %1 : !LowLFHE.cleartext<6> } diff --git a/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.invalid.mlir b/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.invalid.mlir index cf743fb65..c74f98364 100644 --- a/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.invalid.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.invalid.mlir @@ -2,7 +2,7 @@ // GLWE p parameter func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{6}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.add_glwe_int' op should have the same GLWE 'p' parameter}} %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,12,64}{6}>) return %1: !MidLFHE.glwe<{1024,12,64}{6}> @@ -12,7 +12,7 @@ func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // GLWE dimension parameter func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512,12,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.add_glwe_int' op should have the same GLWE 'dimension' parameter}} %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{512,12,64}{7}>) return %1: !MidLFHE.glwe<{512,12,64}{7}> @@ -22,7 +22,7 @@ func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512, // GLWE polynomialSize parameter func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,11,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.add_glwe_int' op should have the same GLWE 'polynomialSize' parameter}} %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,11,64}{7}>) return %1: !MidLFHE.glwe<{1024,11,64}{7}> @@ -32,7 +32,7 @@ func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // integer width doesn't match GLWE parameter func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> { - %0 = constant 1 : i9 + %0 = arith.constant 1 : i9 // expected-error @+1 {{'MidLFHE.add_glwe_int' op should have the width of `b` equals or less than 'p'+1}} %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i9) -> (!MidLFHE.glwe<{1024,12,64}{7}>) return %1: !MidLFHE.glwe<{1024,12,64}{7}> diff --git a/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.mlir b/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.mlir index 3b7d1d510..dc2f9be2b 100644 --- a/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_add_glwe_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> func @add_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.add_glwe_int"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> !MidLFHE.glwe<{1024,12,64}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.add_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,12,64}{7}>) return %1: !MidLFHE.glwe<{1024,12,64}{7}> } diff --git a/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.invalid.mlir b/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.invalid.mlir index 4c3a2d238..a258c6ba2 100644 --- a/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.invalid.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.invalid.mlir @@ -2,7 +2,7 @@ // GLWE p parameter func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{6}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.mul_glwe_int' op should have the same GLWE 'p' parameter}} %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,12,64}{6}>) return %1: !MidLFHE.glwe<{1024,12,64}{6}> @@ -12,7 +12,7 @@ func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // GLWE dimension parameter func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512,12,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.mul_glwe_int' op should have the same GLWE 'dimension' parameter}} %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{512,12,64}{7}>) return %1: !MidLFHE.glwe<{512,12,64}{7}> @@ -22,7 +22,7 @@ func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512, // GLWE polynomialSize parameter func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,11,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.mul_glwe_int' op should have the same GLWE 'polynomialSize' parameter}} %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,11,64}{7}>) return %1: !MidLFHE.glwe<{1024,11,64}{7}> @@ -32,7 +32,7 @@ func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // integer width doesn't match GLWE parameter func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> { - %0 = constant 1 : i9 + %0 = arith.constant 1 : i9 // expected-error @+1 {{'MidLFHE.mul_glwe_int' op should have the width of `b` equals or less than 'p'+1}} %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i9) -> (!MidLFHE.glwe<{1024,12,64}{7}>) return %1: !MidLFHE.glwe<{1024,12,64}{7}> diff --git a/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.mlir b/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.mlir index 3c4a01957..727877cd0 100644 --- a/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_mul_glwe_int.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> func @mul_glwe_int(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.mul_glwe_int"(%arg0, %[[V1]]) : (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> !MidLFHE.glwe<{1024,12,64}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.mul_glwe_int"(%arg0, %0): (!MidLFHE.glwe<{1024,12,64}{7}>, i8) -> (!MidLFHE.glwe<{1024,12,64}{7}>) return %1: !MidLFHE.glwe<{1024,12,64}{7}> } diff --git a/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.invalid.mlir b/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.invalid.mlir index debf54b4d..37f05e4d6 100644 --- a/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.invalid.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.invalid.mlir @@ -2,7 +2,7 @@ // GLWE p parameter func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{6}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.sub_int_glwe' op should have the same GLWE 'p' parameter}} %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> (!MidLFHE.glwe<{1024,12,64}{6}>) return %1: !MidLFHE.glwe<{1024,12,64}{6}> @@ -12,7 +12,7 @@ func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // GLWE dimension parameter func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512,12,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.sub_int_glwe' op should have the same GLWE 'dimension' parameter}} %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> (!MidLFHE.glwe<{512,12,64}{7}>) return %1: !MidLFHE.glwe<{512,12,64}{7}> @@ -22,7 +22,7 @@ func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{512, // GLWE polynomialSize parameter func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,11,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.sub_int_glwe' op should have the same GLWE 'polynomialSize' parameter}} %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> (!MidLFHE.glwe<{1024,11,64}{7}>) return %1: !MidLFHE.glwe<{1024,11,64}{7}> @@ -32,7 +32,7 @@ func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024 // integer width doesn't match GLWE parameter func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,11,64}{7}> { - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 // expected-error @+1 {{'MidLFHE.sub_int_glwe' op should have the same GLWE 'polynomialSize' parameter}} %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> (!MidLFHE.glwe<{1024,11,64}{7}>) return %1: !MidLFHE.glwe<{1024,11,64}{7}> diff --git a/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.mlir b/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.mlir index 47b850daa..3d7e2d070 100644 --- a/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.mlir +++ b/compiler/tests/Dialect/MidLFHE/op_sub_int_glwe.mlir @@ -2,11 +2,11 @@ // CHECK-LABEL: func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> func @sub_int_glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> { - // CHECK-NEXT: %[[V1:.*]] = constant 1 : i8 + // CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i8 // CHECK-NEXT: %[[V2:.*]] = "MidLFHE.sub_int_glwe"(%[[V1]], %arg0) : (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> !MidLFHE.glwe<{1024,12,64}{7}> // CHECK-NEXT: return %[[V2]] : !MidLFHE.glwe<{1024,12,64}{7}> - %0 = constant 1 : i8 + %0 = arith.constant 1 : i8 %1 = "MidLFHE.sub_int_glwe"(%0, %arg0): (i8, !MidLFHE.glwe<{1024,12,64}{7}>) -> (!MidLFHE.glwe<{1024,12,64}{7}>) return %1: !MidLFHE.glwe<{1024,12,64}{7}> } diff --git a/compiler/tests/python/test_compiler_engine.py b/compiler/tests/python/test_compiler_engine.py index 54d7cdac3..fba08a94e 100644 --- a/compiler/tests/python/test_compiler_engine.py +++ b/compiler/tests/python/test_compiler_engine.py @@ -66,7 +66,7 @@ def test_compile_and_run_invalid_arg_number(mlir_input, args): pytest.param( """ func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - %tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> + %tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> %1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<7>, tensor<128xi64>) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/python/test_round_trip.py b/compiler/tests/python/test_round_trip.py index 6253bcca2..6c31d2016 100644 --- a/compiler/tests/python/test_round_trip.py +++ b/compiler/tests/python/test_round_trip.py @@ -6,7 +6,7 @@ VALID_INPUTS = [ pytest.param( """ func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> { - %0 = constant 1 : i3 + %0 = arith.constant 1 : i3 %1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>) return %1: !HLFHE.eint<2> } @@ -37,7 +37,7 @@ VALID_INPUTS = [ pytest.param( """ func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> { - %tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> + %tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64> %1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<7>, tensor<128xi64>) -> (!HLFHE.eint<7>) return %1: !HLFHE.eint<7> } diff --git a/compiler/tests/unittest/end_to_end_jit_hlfhelinalg.cc b/compiler/tests/unittest/end_to_end_jit_hlfhelinalg.cc index 89d644969..6142f1a37 100644 --- a/compiler/tests/unittest/end_to_end_jit_hlfhelinalg.cc +++ b/compiler/tests/unittest/end_to_end_jit_hlfhelinalg.cc @@ -881,7 +881,7 @@ TEST(End2EndJit_HLFHELinalg, apply_lookup_table) { // [3,0,1] lut [1,3,5,7] = [7,1,3] // [2,3,0] [5,7,1] func @main(%t: tensor<3x3x!HLFHE.eint<2>>) -> tensor<3x3x!HLFHE.eint<3>> { - %lut = std.constant dense<[1,3,5,7]> : tensor<4xi64> + %lut = arith.constant dense<[1,3,5,7]> : tensor<4xi64> %res = "HLFHELinalg.apply_lookup_table"(%t, %lut) : (tensor<3x3x!HLFHE.eint<2>>, tensor<4xi64>) -> tensor<3x3x!HLFHE.eint<3>> return %res : tensor<3x3x!HLFHE.eint<3>> } diff --git a/compiler/tests/unittest/end_to_end_jit_test.cc b/compiler/tests/unittest/end_to_end_jit_test.cc index 591bbe682..dab44e903 100644 --- a/compiler/tests/unittest/end_to_end_jit_test.cc +++ b/compiler/tests/unittest/end_to_end_jit_test.cc @@ -45,7 +45,7 @@ func @main(%arg0: !HLFHE.eint<7>, %arg1: !HLFHE.eint<7>) -> !HLFHE.eint<7> { TEST(CompileAndRunHLFHE, add_u64) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%arg0: i64, %arg1: i64) -> i64 { - %1 = addi %arg0, %arg1 : i64 + %1 = arith.addi %arg0, %arg1 : i64 return %1: i64 } )XXX", @@ -215,7 +215,7 @@ func @main(%t: tensor<10x!HLFHE.eint<5>>, %i: index, %j: index) -> TEST(CompileAndRunTensorEncrypted, dim_5) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%t: tensor<10x!HLFHE.eint<5>>) -> index{ - %c0 = constant 0 : index + %c0 = arith.constant 0 : index %c = tensor.dim %t, %c0 : tensor<10x!HLFHE.eint<5>> return %c : index } @@ -244,8 +244,8 @@ func @main(%0: !HLFHE.eint<5>) -> tensor<1x!HLFHE.eint<5>> { TEST(CompileAndRunTensorEncrypted, in_out_tensor_with_op_5) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%in: tensor<2x!HLFHE.eint<5>>) -> tensor<3x!HLFHE.eint<5>> { - %c_0 = constant 0 : index - %c_1 = constant 1 : index + %c_0 = arith.constant 0 : index + %c_1 = arith.constant 1 : index %a = tensor.extract %in[%c_0] : tensor<2x!HLFHE.eint<5>> %b = tensor.extract %in[%c_1] : tensor<2x!HLFHE.eint<5>> %aplusa = "HLFHE.add_eint"(%a, %a): (!HLFHE.eint<5>, !HLFHE.eint<5>) -> @@ -285,7 +285,7 @@ func @main(%arg0: tensor<2x!HLFHE.eint<7>>, %arg1: tensor<2xi8>, %acc: !HLFHE.eint<7> %5 = "HLFHE.add_eint"(%4, %arg4) : (!HLFHE.eint<7>, !HLFHE.eint<7>) -> !HLFHE.eint<7> linalg.yield %5 : !HLFHE.eint<7> } -> tensor<1x!HLFHE.eint<7>> - %c0 = constant 0 : index + %c0 = arith.constant 0 : index %ret = tensor.extract %2[%c0] : tensor<1x!HLFHE.eint<7>> return %ret : !HLFHE.eint<7> } @@ -329,7 +329,7 @@ TEST_P(CompileAndRunWithPrecision, identity_func) { mlirProgram << "func @main(%arg0: !HLFHE.eint<" << precision << ">) -> !HLFHE.eint<" << precision << "> { \n" - << " %tlu = std.constant dense<[0"; + << " %tlu = arith.constant dense<[0"; for (uint64_t i = 1; i < sizeOfTLU; i++) mlirProgram << ", " << i; @@ -375,8 +375,8 @@ INSTANTIATE_TEST_SUITE_P(TestHLFHEApplyLookupTable, CompileAndRunWithPrecision, TEST(TestHLFHEApplyLookupTable, multiple_precision) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%arg0: !HLFHE.eint<6>, %arg1: !HLFHE.eint<3>) -> !HLFHE.eint<6> { - %tlu_7 = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]> : tensor<64xi64> - %tlu_3 = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7]> : tensor<8xi64> + %tlu_7 = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]> : tensor<64xi64> + %tlu_3 = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7]> : tensor<8xi64> %a = "HLFHE.apply_lookup_table"(%arg0, %tlu_7): (!HLFHE.eint<6>, tensor<64xi64>) -> (!HLFHE.eint<6>) %b = "HLFHE.apply_lookup_table"(%arg1, %tlu_3): (!HLFHE.eint<3>, tensor<8xi64>) -> (!HLFHE.eint<6>) %a_plus_b = "HLFHE.add_eint"(%a, %b): (!HLFHE.eint<6>, !HLFHE.eint<6>) -> (!HLFHE.eint<6>) @@ -390,7 +390,7 @@ func @main(%arg0: !HLFHE.eint<6>, %arg1: !HLFHE.eint<3>) -> !HLFHE.eint<6> { TEST(CompileAndRunTLU, random_func) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%arg0: !HLFHE.eint<6>) -> !HLFHE.eint<6> { - %tlu = std.constant dense<[16, 91, 16, 83, 80, 74, 21, 96, 1, 63, 49, 122, 76, 89, 74, 55, 109, 110, 103, 54, 105, 14, 66, 47, 52, 89, 7, 10, 73, 44, 119, 92, 25, 104, 123, 100, 108, 86, 29, 121, 118, 52, 107, 48, 34, 37, 13, 122, 107, 48, 74, 59, 96, 36, 50, 55, 120, 72, 27, 45, 12, 5, 96, 12]> : tensor<64xi64> + %tlu = arith.constant dense<[16, 91, 16, 83, 80, 74, 21, 96, 1, 63, 49, 122, 76, 89, 74, 55, 109, 110, 103, 54, 105, 14, 66, 47, 52, 89, 7, 10, 73, 44, 119, 92, 25, 104, 123, 100, 108, 86, 29, 121, 118, 52, 107, 48, 34, 37, 13, 122, 107, 48, 74, 59, 96, 36, 50, 55, 120, 72, 27, 45, 12, 5, 96, 12]> : tensor<64xi64> %1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<6>, tensor<64xi64>) -> (!HLFHE.eint<6>) return %1: !HLFHE.eint<6> } diff --git a/llvm-project b/llvm-project index 55e76c70a..8b7cc93e9 160000 --- a/llvm-project +++ b/llvm-project @@ -1 +1 @@ -Subproject commit 55e76c70a4f7fd5e13cf6c317a183bc3e6c59a03 +Subproject commit 8b7cc93e9dc7e4e3b3a5cb014fa8d047c47f4818