Skip to content

Fix alias analysis#185

Merged
naoyam merged 3 commits into
mainfrom
fix_alias_analysis
Apr 20, 2023
Merged

Fix alias analysis#185
naoyam merged 3 commits into
mainfrom
fix_alias_analysis

Conversation

@naoyam

@naoyam naoyam commented Apr 19, 2023

Copy link
Copy Markdown
Contributor

Set was replaced with LoadStoreOp, which was not recognized as UnaryOp, and thus the alias analysis failed to detect safe aliasing

Fixes #163

Set was replaced with LoadStoreOp, which was not recognized as UnaryOp,
and thus the alias analysis failed to detect safe aliasing
@naoyam
naoyam requested a review from zasdfgbnm April 19, 2023 20:55
Comment thread csrc/ir_utils.cpp Outdated

bool isPointwiseTvOp(const Expr* expr) {
return isTvOp(expr) &&
expr->isOneOf<UnaryOp, BinaryOp, TernaryOp, LoadStoreOp>();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just raise a question for discussion: Should we disable inner sharing for LoadStoreOp with consumer that has rfactor domain (that is, permutation ops)? I am not sure, but I think it should be OK to share.

@zasdfgbnm zasdfgbnm Apr 19, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

T2 = transpose(T1)
T3 = sin(T2)

For the example above, I think it is OK to share T3 with T1.

We shouldn't share T2 with T1, but I think we are already disallowing this type of sharing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. Is it really safe? Suppose t1 = transpose(t0), and both of them are on shared memory, code like below seemed to be generated:

__shared__ t0[N] = ...;
auto& t1 = t0;
t1[i * k + j] = t0[j *k + i];

This isn't valid an it's not really pointwise, is it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wait what, is t1 sharing with t0? I think we previously disabled it. csarofeen/pytorch#2490

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is right. But should we call it a pointwise op?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@zasdfgbnm

Copy link
Copy Markdown
Collaborator

!build

@naoyam

naoyam commented Apr 19, 2023

Copy link
Copy Markdown
Contributor Author

!build

@naoyam
naoyam merged commit d68da6b into main Apr 20, 2023
@naoyam
naoyam deleted the fix_alias_analysis branch April 20, 2023 00:11
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.

FusionPersistentSoftmaxLocalShared failure

2 participants