Skip to content
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

Fix for assume statement #16664

Closed
wants to merge 6 commits into from
Closed

Fix for assume statement #16664

wants to merge 6 commits into from

Conversation

sdalvi-quic
Copy link
Contributor

@sdalvi-quic sdalvi-quic commented Mar 1, 2024

The assume statement was not understanding the complete expression present inside. The predicate was not getting appended along with the buffer access. The additional predicate was added to the conditions list but was not appended while creating the buffer touch . This fix helps to resolve it.

The issue is that the "TestSimplifyUsingPartiallyProvenBufferValueScatter" test is not completing after the fix. Rest of the tests are passing. I guess the issue is not with the fix but might be somewhere else.

For reference : #16577

@Lunderberg, @jverma-quic and @quic-sanirudh Can you please review and point to the possible issue with the above test.

@quic-sanirudh
Copy link
Contributor

@tvm-bot rerun

Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

Overall, looks good, just a number of nitpick changes.

@@ -473,6 +473,7 @@ class ControlFlowGraphBuilder final : public IRVisitorWithAnalyzer {
void VisitAccess(const BufferAccess& node, BufferTouch::AccessType touch_type,
PrimExpr known_value_expr) {
auto& current_block = out_->control_flow_.back();
current_block.current_predicate = CurrentScopePredicate();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Instead of adding a member variable, can we add this as an additional parameter to current_block.MakeBufferTouch? That way, we avoid accidental re-use of current_predicate from other callsites.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I added an additional parameter to MakeBufferTouch.

if A[i] == 0:
A[i] = 42

def expected(A: T.Buffer(16, "int32")):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Instead of duplicating the same function definition, I'd recommend expected = before. That makes it clear to a reader that the simplification shouldn't cause any changes.

@@ -1325,6 +1326,34 @@ def expected(A: T.Buffer(16, "int32")):
A[i] = 42


class TestAssume(BaseBeforeAfter):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: The T.assume function is tested in other cases as well, but calling this TestAssume implies this is validating all behavior of T.assume. Can we rename the test case to TestAssumeMayContainAdditionalPredicate?

@sdalvi-quic
Copy link
Contributor Author

Thanks @Lunderberg I will do the above changes recommended!

I realized the issues that after this fix the "TestSimplifyUsingPartiallyProvenBufferValueScatter" test is not completing but, "TestSimplifyUsingPartiallyProvenBufferValueGather" test is passing. There does not seem to be an issue while generating the control flow graph but somewhere later after introducing the fix. Can you please point what might be the possible issue?

Currently src/tir/transforms/simplify.cc and src/tir/transforms/reduce_branching_through_overcompute.cc pass works with lowered IR but is there any way how we can use it for T.blocks level implementation of the IR?

Thank you!

@sdalvi-quic sdalvi-quic requested a review from Lunderberg March 7, 2024 23:27
@sdalvi-quic
Copy link
Contributor Author

Hello @Lunderberg and @junrushao can you please review the above PR?

@sdalvi-quic
Copy link
Contributor Author

Since there is bug in the scatter test which is not yet resolved it might get difficult to upstream this PR. Closing it for now may raise the same PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants