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 alias analysis #185

Merged
merged 3 commits into from
Apr 20, 2023
Merged

Fix alias analysis #185

merged 3 commits into from
Apr 20, 2023

Conversation

naoyam
Copy link
Collaborator

@naoyam naoyam commented Apr 19, 2023

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
@@ -572,6 +572,11 @@ bool isReductionTvOp(const Expr* expr) {
return ir_utils::isTvOp(expr) && isReductionOp(expr);
}

bool isPointwiseTvOp(const Expr* expr) {
return isTvOp(expr) &&
expr->isOneOf<UnaryOp, BinaryOp, TernaryOp, LoadStoreOp>();
Copy link
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.

Copy link
Collaborator

@zasdfgbnm zasdfgbnm Apr 19, 2023

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
Collaborator 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
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
Collaborator 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
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
Collaborator 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
Collaborator

!build

@naoyam
Copy link
Collaborator Author

naoyam commented Apr 19, 2023

!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