[Mlir-commits] [mlir] [mlir][tosa] Add folding for TOSA ArgMax operator (PR #88871)
Dmitrii Agibov
llvmlistbot at llvm.org
Wed Apr 17 03:06:35 PDT 2024
================
@@ -507,6 +507,20 @@ OpFoldResult AddOp::fold(FoldAdaptor adaptor) {
resultTy);
}
+OpFoldResult ArgMaxOp::fold(FoldAdaptor adaptor) {
+ auto inputTy = llvm::dyn_cast<RankedTensorType>(getInput().getType());
+ auto outputTy = llvm::dyn_cast<RankedTensorType>(getType());
+ if (!inputTy || !outputTy || !inputTy.hasStaticShape() ||
+ !outputTy.hasStaticShape())
+ return {};
+
+ if (inputTy.getDimSize(getAxis()) == 1) {
+ return DenseElementsAttr::get(outputTy, 0);
+ }
----------------
d-agbv wrote:
Thank you for the review! I updated the code and dropped braces here.
https://github.com/llvm/llvm-project/pull/88871
More information about the Mlir-commits
mailing list