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

[ir] Make sure "StmtFieldManager" to be correct if we modify some fields after the ctor #1587

Merged
merged 4 commits into from
Jul 27, 2020

Conversation

TH3CHARLie
Copy link
Collaborator

@codecov
Copy link

codecov bot commented Jul 25, 2020

Codecov Report

Merging #1587 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1587      +/-   ##
==========================================
- Coverage   86.81%   86.76%   -0.05%     
==========================================
  Files          19       19              
  Lines        3685     3679       -6     
  Branches      653      653              
==========================================
- Hits         3199     3192       -7     
- Misses        353      354       +1     
  Partials      133      133              
Impacted Files Coverage Δ
python/taichi/lang/ops.py 92.51% <0.00%> (-0.82%) ⬇️
python/taichi/lang/__init__.py 80.20% <0.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c37c04...782cc44. Read the comment docs.

Copy link
Contributor

@xumingkuan xumingkuan left a comment

Choose a reason for hiding this comment

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

Cool! Thanks for fixing this.

}

bool equal(const StmtField *other_generic) const override {
if (auto other = dynamic_cast<const StmtFieldNumeric *>(other_generic)) {
if (other->value_ptr && value_ptr) {
return *(other->value_ptr) == *value_ptr;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if only one of them is a pointer?

Suggested change
}
} else if (other->value_ptr || value_ptr) {
return false;
}

taichi/ir/ir.h Outdated
Comment on lines 426 to 427
T *value_ptr;
T value;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consider using std::variant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wow, that's something I haven't think of, I'll definitely try that

@xumingkuan xumingkuan requested a review from yuanming-hu July 26, 2020 01:55
Copy link
Contributor

@xumingkuan xumingkuan left a comment

Choose a reason for hiding this comment

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

Cool!

Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

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

Thank you so much! Looks great.

If it makes sense, I would let the pointer-nonpointer comparison case return a loud error, since I don't think a normal Taichi program should run into that case. @xumingkuan WDYT?

taichi/ir/ir.h Outdated Show resolved Hide resolved
@TH3CHARLie
Copy link
Collaborator Author

TH3CHARLie commented Jul 26, 2020

Thank you so much! Looks great.

If it makes sense, I would let the pointer-nonpointer comparison case return a loud error, since I don't think a normal Taichi program should run into that case. @xumingkuan WDYT?

I also prefer to report error on this. The way taichi construct StmtField would already ensure this case almost never happens.

Updates:
I'd like to commit yuanming's suggested changes now, it can be changed later if @xumingkuan has better ideas.

TH3CHARLie and others added 2 commits July 26, 2020 23:09
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
@xumingkuan
Copy link
Contributor

Thank you so much! Looks great.

If it makes sense, I would let the pointer-nonpointer comparison case return a loud error, since I don't think a normal Taichi program should run into that case. @xumingkuan WDYT?

Sure, it makes sense to me.

@xumingkuan xumingkuan merged commit eccf7bb into taichi-dev:master Jul 27, 2020
@FantasyVR FantasyVR mentioned this pull request Jul 29, 2020
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.

4 participants