[Mlir-commits] [mlir] [mlir][tosa] Add folder for multiply like reduce_prod operation (PR #128067)
Georgios Pinitas
llvmlistbot at llvm.org
Mon Feb 24 10:01:43 PST 2025
================
@@ -963,10 +963,38 @@ REDUCE_FOLDER(ReduceAllOp)
REDUCE_FOLDER(ReduceAnyOp)
REDUCE_FOLDER(ReduceMaxOp)
REDUCE_FOLDER(ReduceMinOp)
-REDUCE_FOLDER(ReduceProdOp)
REDUCE_FOLDER(ReduceSumOp)
#undef REDUCE_FOLDER
+OpFoldResult ReduceProdOp::fold(FoldAdaptor adaptor) {
+ ShapedType inputTy = llvm::cast<ShapedType>(getInput().getType());
+ if (!inputTy.hasRank())
+ return {};
+ if (inputTy == getType() &&
+ (inputTy.getRank() == 0 || inputTy.getDimSize(getAxis()) == 1))
+ return getInput();
+
+ // Fold multiply like reduce_prod operators using mulBinaryFolder
----------------
GeorgeARM wrote:
This is quite limited special-cased. What is the motivation behind this?
https://github.com/llvm/llvm-project/pull/128067
More information about the Mlir-commits
mailing list