Skip to content

Reduce the work to add a new expr: mutator cleanup #2199

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

Merged
merged 9 commits into from
Nov 19, 2022
Merged

Conversation

zasdfgbnm
Copy link
Collaborator

No description provided.

@zasdfgbnm zasdfgbnm changed the title [WIP] Reduce the work to add a new expr: mutator cleanup Reduce the work to add a new expr: mutator cleanup Nov 18, 2022
@zasdfgbnm zasdfgbnm marked this pull request as ready for review November 18, 2022 22:15
@zasdfgbnm zasdfgbnm requested a review from naoyam November 18, 2022 22:15
@@ -480,19 +486,14 @@ class TORCH_CUDA_CU_API Expr : public Statement {
std::vector<Val*> outputs,
std::vector<Statement*> attributes);

virtual newObjectFuncType* newObjectFunc() const = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this "newObject" interface now return a function pointer? What's wrong with the previous version?

Copy link
Collaborator Author

@zasdfgbnm zasdfgbnm Nov 19, 2022

Choose a reason for hiding this comment

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

Because of this container->removeExpr(op); in the mutate method. When an IR node is removed from a container, its vtable no longer exist, and op->newObject will cause segfault.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just do op->newObject() before removing it?

Copy link
Collaborator Author

@zasdfgbnm zasdfgbnm Nov 19, 2022

Choose a reason for hiding this comment

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

And we can not swap the order of op->newObject and container->removeExpr because this causes some consistency check failure (an IterDomain used in multiple expr).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

C++ does not allow me to do the following either :(

auto fn = op->newObject;

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, makes sense.

Copy link
Collaborator

@naoyam naoyam left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the cleanup

@zasdfgbnm zasdfgbnm merged commit b02b95c into devel Nov 19, 2022
@zasdfgbnm zasdfgbnm deleted the mutator-cleanup branch November 19, 2022 01:14
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.

2 participants