mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 12:15:09 -05:00
feat(compiler): Add HLFHELinalg.zero operation
Add a new operation `HLFHELinalg.zero`, broadcasting an encrypted, zero-valued integer into a tensor of encrypted integers with static shape. Example creating a one-dimensional tensor with five elements all initialized to an encrypted zero: %tensor = "HLFHELinalg.zero"() : () -> tensor<5x!HLFHE.eint<4>>
This commit is contained in:
@@ -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<And<[TensorOf<[EncryptedIntegerType]>.predicate, HasStaticShapePred]>>:$aggregate);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -859,6 +859,7 @@ struct MANPAnalysis : public mlir::ForwardDataFlowAnalysis<MANPLatticeValue> {
|
||||
llvm::dyn_cast<mlir::zamalang::HLFHE::MulEintIntOp>(op)) {
|
||||
norm2SqEquiv = getSqMANP(mulEintIntOp, operands);
|
||||
} else if (llvm::isa<mlir::zamalang::HLFHE::ZeroEintOp>(op) ||
|
||||
llvm::isa<mlir::zamalang::HLFHELinalg::ZeroOp>(op) ||
|
||||
llvm::isa<mlir::zamalang::HLFHE::ApplyLookupTableEintOp>(op)) {
|
||||
norm2SqEquiv = llvm::APInt{1, 1, false};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user