Skip to content

Conversation

sott0n
Copy link
Contributor

@sott0n sott0n commented Sep 7, 2023

This patch addresses a crash that occurs when negative dynamic sizes are provided in tensor.emptyOp by adding a check to ensure that dynamic sizes are non-negative.

Fixes #64064

@sott0n sott0n requested a review from a team as a code owner September 7, 2023 07:48
@github-actions github-actions bot added mlir:core MLIR Core Infrastructure mlir mlir:tensor labels Sep 7, 2023
<< getDynamicSizes().size() << ", expected "
<< getType().getNumDynamicDims();

if (getDynamicSizes().size() > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check does not seem needed?

if (getDynamicSizes().size() > 0) {
if (llvm::any_of(getDynamicSizes(), [](Value operand) {
APInt constSizeArg;
if (!matchPattern(operand, m_ConstantInt(&constSizeArg))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not belong to the verifier, because: https://mlir.llvm.org/getting_started/DeveloperGuide/#ir-verifier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for teaching me about IR's verifier.

This is why the guidelines to write verifier is to stick to information local to an operation (think “what I see when I print this operation alone”). Looking through operands or results is extremely unusual and should be avoided.

I understand it, so i will remove this checker from verifier.

if (cst.has_value()) {
// dynamic size must be non-negative.
if (cst.value() < 0)
return failure();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be enough without the verifier right?

@sott0n
Copy link
Contributor Author

sott0n commented Sep 11, 2023

@joker-eph Could you merge it?

@joker-eph joker-eph merged commit ca8cf90 into llvm:main Sep 11, 2023
@sott0n sott0n deleted the fix-tensor-empty-negative-size branch September 12, 2023 01:32
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
…vm#65577)

This patch addresses a crash that occurs when negative dynamic sizes are
provided in tensor.emptyOp by adding a check to ensure that dynamic
sizes are non-negative.

Fixes llvm#64064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir:tensor mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mlir] Inline pass crashed with assertion failure "(succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...)))"
2 participants