mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
feat: implement MANP calculation for tensor.insert op
This commit is contained in:
@@ -966,6 +966,20 @@ static llvm::APInt getSqMANP(
|
||||
operandMANPs[1]->getValue().getMANP().getValue());
|
||||
}
|
||||
|
||||
static llvm::APInt getSqMANP(
|
||||
mlir::tensor::InsertOp op,
|
||||
llvm::ArrayRef<mlir::LatticeElement<MANPLatticeValue> *> operandMANPs) {
|
||||
|
||||
assert(
|
||||
operandMANPs.size() >= 2 &&
|
||||
operandMANPs[0]->getValue().getMANP().hasValue() &&
|
||||
operandMANPs[1]->getValue().getMANP().hasValue() &&
|
||||
"Missing squared Minimal Arithmetic Noise Padding for encrypted operand");
|
||||
|
||||
return APIntUMax(operandMANPs[0]->getValue().getMANP().getValue(),
|
||||
operandMANPs[1]->getValue().getMANP().getValue());
|
||||
}
|
||||
|
||||
static llvm::APInt getSqMANP(
|
||||
mlir::tensor::CollapseShapeOp op,
|
||||
llvm::ArrayRef<mlir::LatticeElement<MANPLatticeValue> *> operandMANPs) {
|
||||
@@ -1274,6 +1288,18 @@ struct MANPAnalysis : public mlir::ForwardDataFlowAnalysis<MANPLatticeValue> {
|
||||
isDummy = true;
|
||||
}
|
||||
}
|
||||
// InsertOp
|
||||
else if (auto insertOp = llvm::dyn_cast<mlir::tensor::InsertOp>(op)) {
|
||||
if (insertOp.result()
|
||||
.getType()
|
||||
.cast<mlir::TensorType>()
|
||||
.getElementType()
|
||||
.isa<mlir::concretelang::FHE::EncryptedIntegerType>()) {
|
||||
norm2SqEquiv = getSqMANP(insertOp, operands);
|
||||
} else {
|
||||
isDummy = true;
|
||||
}
|
||||
}
|
||||
// InsertSliceOp
|
||||
else if (auto insertSliceOp =
|
||||
llvm::dyn_cast<mlir::tensor::InsertSliceOp>(op)) {
|
||||
|
||||
Reference in New Issue
Block a user