Skip to content

AliasAnalysis handles non-packed reshapes.#1295

Merged
wujingyue merged 3 commits intomainfrom
wjy/nonpack
Nov 17, 2023
Merged

AliasAnalysis handles non-packed reshapes.#1295
wujingyue merged 3 commits intomainfrom
wjy/nonpack

Conversation

@wujingyue
Copy link
Collaborator

@wujingyue wujingyue commented Nov 14, 2023

Partially taken from #1281 to keep that PR small.

@wujingyue wujingyue changed the title AliasAnalysis handles slices and non-packed reshapes. AliasAnalysis handles non-packed reshapes. Nov 14, 2023
@wujingyue
Copy link
Collaborator Author

!build

@wujingyue wujingyue force-pushed the wjy/nonpack branch 2 times, most recently from ce55952 to 61ef979 Compare November 14, 2023 05:38
@wujingyue
Copy link
Collaborator Author

!build

Copy link
Collaborator

@jacobhinkle jacobhinkle left a comment

Choose a reason for hiding this comment

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

Some initial comments.

Comment on lines +151 to +153
for (Expr* transform : DependencyCheck::getAllExprsBetween(
{out_root.begin(), out_root.end()},
{out_rfactor.begin(), out_rfactor.end()})) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use StmtSort::getExprsBetween for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What's the benefit of that? I also saw Dependencies::getAllExprs. I'm confused when to use which...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jacobhinkle I merged my PR but would still appreciate your thought on this. I found at least three functions doing the similar work :) I'm not sure when to use which.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great question. It seems to me like DependencyCheck and StmtSort are redundant; they are used roughly equally often and appear to provide the same functionality, with DependencyCheck maybe slightly more complicated. DependencyCheck has been around since the beginning of the project, while StmtSort evolved from ExprSort (csarofeen/pytorch#1376). ExprSort was introduced in https://github.com/pytorch/pytorch/pull/45218/files#diff-49787cacb3e793473c24bc615113fb2c782086cbe552c63ac75ffede45f417a1R240-R254. I have been mostly using StmtSort which has options for controlling whether we traverse members and attributes. We should make clear in the comments when to use each. CC @naoyam @jjsjann123

Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC, Dependencies has been used from a very beginning of the project, and later IterVisitor::traverseBetween and StmtSort were added. I believe StmtSort basically reproduces the same functionality as Dependencies but more concisely using IterVisitor::traverseBetween. I think it should be valid to replace all DependencyCheck::getAllExprs/ValsBetween with StmtSort::getExprs/Vals, but should be confirmed by @csarofeen

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that's correct.

Copy link
Collaborator

@jjsjann123 jjsjann123 left a comment

Choose a reason for hiding this comment

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

minor comments on some c++ nitpick. lgtm overall~~~

Copy link
Collaborator

@jjsjann123 jjsjann123 left a comment

Choose a reason for hiding this comment

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

Only realized it when I happen to see the hasAllocation check on LoadStoreOp

@wujingyue
Copy link
Collaborator Author

!build

Copy link
Collaborator

@jjsjann123 jjsjann123 left a comment

Choose a reason for hiding this comment

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

minor comment. LGTM

@wujingyue
Copy link
Collaborator Author

!build

@wujingyue wujingyue merged commit 801670e into main Nov 17, 2023
@wujingyue wujingyue deleted the wjy/nonpack branch November 17, 2023 19:22
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.

5 participants