-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[MetaSchedule] Fix the order of applying AutoInline
in ScheduleUsingAnchorTrace
#13329
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
<< "If a spatial block cannot be inlined, it should be the output block"; | ||
if (CanReverseComputeInline(sch->state(), block_sref)) { | ||
sch->ReverseComputeInline(block); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another fix, just relaxing the wrong assumption at L144.
# "conv2d_nhwc_reindex_shared" has the predicate | ||
# T.where(((ax1_0 * 4 + ax1_1) * 32 + ax1_2) * 2 + ax1_3 < 64) due to anchor-block scheduling | ||
# (see Conv2dInt8_with_predicate_scheduled). Currently, if we try to reverse-inline a block to | ||
# its producer that has a predicate, the predicate disappears after reverse inlining. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @vinx13 to confirm if applying reverse_compute_inline
when the producer has a predicate should be disallowed. Currently it is allowed, and the predicate disappears. A minimum repro in https://gist.github.com/masahi/01a80b86062122ad57b9b1fd785fb960
Will leave this PR to @vinx13 :-) |
…ngAnchorTrace` (apache#13329) * index on concat-fusion-fix: 3ffe5b1 fix te extern create_prim_func test * Apply AutoInline to the last block after all other blocks are processed * Do not require CanReverseComputeInline to be true when CanComputeInline is false * add comment * add test * cpplint
…ngAnchorTrace` (apache#13329) * index on concat-fusion-fix: 3ffe5b1 fix te extern create_prim_func test * Apply AutoInline to the last block after all other blocks are processed * Do not require CanReverseComputeInline to be true when CanComputeInline is false * add comment * add test * cpplint
Note: the diff is bloated due to the test case.
In anchor-block tuning, we need to manually apply
AutoInline
to some blocks (those that are not part of the anchor subgraph). Currently the order of blocks to applyAutoInline
is undefined, but I've hit a case where this is problematic.For example, given these four blocks,
, we want to
AutoInline
"compute_3", "T_add_2" and "compute_4". If the order is "T_add_2" -> "compute_3" -> "compute_4", all three blocks can be inlined / reverse inlined to "compute_2". However, if the order is "T_add_2" -> "compute_4" -> "compute_3" , "compute_4" can neither be inlined or reverse inlined. This in turn can result in a buggy schedule to be generated (see the description in the test case).We can avoid this problem by always
AutoInlin
ing the last block after all other blocks have been processed. This ensures that the last block can be reverse inlined.@vinx13 @junrushao @zxybazh