-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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?
} | |
} else if (other->value_ptr || value_ptr) { | |
return false; | |
} |
taichi/ir/ir.h
Outdated
T *value_ptr; | ||
T value; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
There was a problem hiding this 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?
I also prefer to report error on this. The way taichi construct StmtField would already ensure this case almost never happens. Updates: |
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
Sure, it makes sense to me. |
Related issue = #1286
[Click here for the format server]