From fc02bb5cd8ece713aa596021d306118727a31602 Mon Sep 17 00:00:00 2001 From: Andi Drebes Date: Wed, 8 Feb 2023 13:28:22 +0100 Subject: [PATCH] fix(compiler): Copy attributes when reinstantiating scf.for ops The switch to reinstantiating conversion patterns for the conversion from FHE to TFHE in commit 73fd6c5fe751c502bcc4c7c68da4a79b753fa791 caused all attributes of `scf.for` operations to be dropped during the conversion. This included the custom attribute `parallel`, which is exploited further down the compilation pipeline to generate parallel code. As a result, the performance of end-to-end benchmarks dropped significantly. This patch copies all attributes of `scf.for` operations upon reinstantiation, which solves the performance regression. --- compiler/lib/Conversion/Utils/Dialects/SCF.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/lib/Conversion/Utils/Dialects/SCF.cpp b/compiler/lib/Conversion/Utils/Dialects/SCF.cpp index 7886874a6..23896147f 100644 --- a/compiler/lib/Conversion/Utils/Dialects/SCF.cpp +++ b/compiler/lib/Conversion/Utils/Dialects/SCF.cpp @@ -20,6 +20,8 @@ TypeConvertingReinstantiationPattern::matchAndRewrite( adaptor.getStep(), adaptor.getInitArgs(), [&](OpBuilder &builder, Location loc, Value iv, ValueRange args) {}); + newForOp->setAttrs(adaptor.getAttributes()); + // Move operations from old for op to new one auto &newOperations = newForOp.getBody()->getOperations(); mlir::Block *oldBody = oldOp.getBody();