diff --git a/compiler/include/zamalang/Dialect/HLFHELinalg/IR/HLFHELinalgOps.td b/compiler/include/zamalang/Dialect/HLFHELinalg/IR/HLFHELinalgOps.td index 729b1e801..88455ba63 100644 --- a/compiler/include/zamalang/Dialect/HLFHELinalg/IR/HLFHELinalgOps.td +++ b/compiler/include/zamalang/Dialect/HLFHELinalg/IR/HLFHELinalgOps.td @@ -444,5 +444,21 @@ def MatMulIntEintOp : HLFHELinalg_Op<"matmul_int_eint", [TensorBinaryIntEint]> { }]; } +def ZeroOp : HLFHELinalg_Op<"zero", []> { + let summary = "Creates a new tensor with all elements initialized to an encrypted zero."; + + let description = [{ + Creates a new tensor with the shape specified in the result type and initializes its elements with an encrypted zero. + + Example: + ```mlir + %tensor = "HLFHELinalg.zero"() : () -> tensor<5x!HLFHE.eint<4>> + ``` + }]; + + let arguments = (ins); + + let results = (outs Type.predicate, HasStaticShapePred]>>:$aggregate); +} #endif diff --git a/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp b/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp index aa8845fd6..bc35a076a 100644 --- a/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp +++ b/compiler/lib/Dialect/HLFHE/Analysis/MANP.cpp @@ -859,6 +859,7 @@ struct MANPAnalysis : public mlir::ForwardDataFlowAnalysis { llvm::dyn_cast(op)) { norm2SqEquiv = getSqMANP(mulEintIntOp, operands); } else if (llvm::isa(op) || + llvm::isa(op) || llvm::isa(op)) { norm2SqEquiv = llvm::APInt{1, 1, false}; }