[Mlir-commits] [mlir] [mlir][math] Expand powfI operation for constant power operand. (PR #87081)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Mar 29 09:52:08 PDT 2024
================
@@ -202,6 +202,44 @@ static LogicalResult convertCeilOp(math::CeilOp op, PatternRewriter &rewriter) {
rewriter.replaceOp(op, ret);
return success();
}
+
+// Convert `math.fpowi` to a series of `arith.mulf` operations.
+// If the power is negative, we divide one by the result.
+static LogicalResult convertFPowIOp(math::FPowIOp op,
+ PatternRewriter &rewriter) {
+ ImplicitLocOpBuilder b(op->getLoc(), rewriter);
+ Value base = op.getOperand(0);
+ Value power = op.getOperand(1);
+ Type baseType = base.getType();
+
+ Attribute cstAttr;
+ if (!matchPattern(power, m_Constant(&cstAttr)))
+ return failure();
+
+ auto iAttr = dyn_cast<SplatElementsAttr>(cstAttr);
+ if (!iAttr)
+ return failure();
+
+ int64_t powerInt = iAttr.getSplatValue<int64_t>();
----------------
kuhar wrote:
Do we want to support the scalar case? `math.fpowi %0, %1 : f32, i64`
https://github.com/llvm/llvm-project/pull/87081
More information about the Mlir-commits
mailing list