Skip to content

[mlir][linalg]-Fix wrong assertion in the getMatchingYieldValue inter… #89590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2025

Conversation

amirBish
Copy link
Contributor

…face

In order to have a consistent implementation for getMatchingYieldValue for linalg generic with buffer/tensor semantics, we should assert the opOperand index based on the numDpsInits and not numOfResults which may be zero in the buffer semantics.

@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-linalg

Author: Amir Bishara (amirBish)

Changes

…face

In order to have a consistent implementation for getMatchingYieldValue for linalg generic with buffer/tensor semantics, we should assert the opOperand index based on the numDpsInits and not numOfResults which may be zero in the buffer semantics.


Full diff: https://github.com/llvm/llvm-project/pull/89590.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td (+1-1)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index fbf3f19cde0e9b..d20925da778e0a 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -486,7 +486,7 @@ def LinalgStructuredInterface
         int64_t resultIndex =
             opOperand->getOperandNumber() - $_op.getNumDpsInputs();
         assert(resultIndex >= 0 &&
-               resultIndex < this->getOperation()->getNumResults());
+               resultIndex < $_op.getNumDpsInits());
         Operation *yieldOp = getBlock()->getTerminator();
         return &yieldOp->getOpOperand(resultIndex);
       }]

Copy link
Member

@akuegel akuegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a test that would trigger the wrong assert?

@amirBish
Copy link
Contributor Author

Could you please add a test that would trigger the wrong assert?

Sure, should it be added as a unit test under mlir/unittests/Dialect or any other location?

@ftynse
Copy link
Member

ftynse commented Apr 22, 2024

If it's possible to trigger this with on some input IR with mlir-opt and a pass, we should rather have that.

@amirBish
Copy link
Contributor Author

If it's possible to trigger this with on some input IR with mlir-opt and a pass, we should rather have that.

Thanks for the suggestion, just checked/searched there is no usage for this method in mlir sources. any insights about how to test the change?

@amirBish
Copy link
Contributor Author

amirBish commented Aug 7, 2025

If it's possible to trigger this with on some input IR with mlir-opt and a pass, we should rather have that.

Thanks for the suggestion, just checked/searched there is no usage for this method in mlir sources. any insights about how to test the change?

@ftynse ping :)

@amirBish amirBish force-pushed the linalg/fix_wrong_assertion branch from d49e0c4 to ae50df9 Compare August 7, 2025 15:16
…face

In order to have a consistent implementation for getMatchingYieldValue
for linalg generic with buffer/tensor semantics, we should assert the
opOperand index based on the numDpsInits and not numOfResults which may
be zero in the buffer semantics.
@amirBish amirBish force-pushed the linalg/fix_wrong_assertion branch from 7f51661 to 2cd284e Compare August 7, 2025 15:19
@amirBish amirBish merged commit ff616a1 into llvm:main Aug 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants