-
Notifications
You must be signed in to change notification settings - Fork 54
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
Schedule loop domains such that reshape transforms are cancelled #3679
Conversation
!test |
!test |
@@ -62,7 +66,48 @@ void scheduleLoopDomainsLike( | |||
// LoopDomainSchedulingTest.ScheduleLoopDomainsBy1 for more examples. | |||
void scheduleLoopDomainsBy( | |||
const std::vector<TensorView*>& tvs, | |||
Expr* transform); | |||
Expr* transform, | |||
Direction replay_dir = Direction::Undefined); |
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.
Added an optional parameter to restrict the direction.
!test |
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.
LGTM. Just one small clarifying question.
// as t0, which could minimize strided accesses. | ||
// | ||
// This scheduling is not always feasible. Specifically, if a reshape | ||
// outout iter domain is resized, the loop domain needs to keep using |
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.
Could you give an example of what the output would look like if some transforms can't be cancelled? For example if we had a further tensor
// t4 = pad(t3) // [i1, i0*i2 + 2]
Then we cannot cancel anything. Presumably if there is a decomposition of the reshape where some is cancellable and another part is not, we will cancel the part that is possible to cancel.
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.
How about this test?
The reshape for tv1
is not cancelled as the following slice depends on it, whereas the tv3 reshape is cancelled.
!build |
!build |
This PR adds a scheduling primitive,
cancelReshapeInLoopDomains(TensorView* from_tv)
, where all reshape transforms appearing betweenfrom_tv
and fusion outputs are effectively cancelled in their loop domains. Please see the comment for a motivating example.This could be used to remove the restriction of the interfering reshape in reduction/normalization fusions.