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

Remove duplicate as Checks and CHECK value #2531

Merged
merged 3 commits into from
Feb 3, 2019

Conversation

alexeyr
Copy link
Contributor

@alexeyr alexeyr commented Jan 31, 2019

The first two commits fix a few problems found by PVS Studio, the third removes some duplicate as<Whatever> calls for readability and consistency.

@@ -73,9 +73,10 @@ class GPUCodeVerifier : public IRVisitor {

void Visit_(const AttrStmt *op) {
if (op->attr_key == attr::storage_scope) {
if (op->value.as<StringImm>()->value == "local") {
std::string opValue = op->value.as<StringImm>()->value;
Copy link
Member

Choose a reason for hiding this comment

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

naming convention: opValue->op_value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (the next one too).

if (op.as<ScanOpNode>()) {
const auto& update = op.as<ScanOpNode>()->update;
const auto& init = op.as<ScanOpNode>()->init;
if (auto scanOp = op.as<ScanOpNode>()) {
Copy link
Member

Choose a reason for hiding this comment

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

nit, naming convention

@tqchen tqchen added the status: need update need update based on feedbacks label Jan 31, 2019
@tqchen tqchen changed the title Bug fixes Remove duplicate as Checks and CHECK value Jan 31, 2019
@@ -470,8 +470,8 @@ void CodeGenStackVM::VisitExpr_(const Select *op) {
}

void CodeGenStackVM::VisitStmt_(const AssertStmt *op) {
if (op->message.as<StringImm>()) {
int sid = this->GetStrID(op->message.as<StringImm>()->value);
if (auto str = op->message.as<StringImm>()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this "const auto* str" instead of "auto str", to expressly show that str is expected to be a const pointer.

Copy link
Contributor

Choose a reason for hiding this comment

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

The "as" template is defined here. Very hard to dig out:
https://github.com/dmlc/HalideIR/blob/master/src/tvm/node/node.h#L306

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@alexeyr alexeyr force-pushed the pvs-warnings branch 3 times, most recently from 3cf47f4 to 8743399 Compare February 1, 2019 09:58
@alexeyr
Copy link
Contributor Author

alexeyr commented Feb 1, 2019

@tqchen Given the name change, would it be better to split first two commits into a separate pull request?

@alexeyr alexeyr force-pushed the pvs-warnings branch 2 times, most recently from 6ba5a6a to f0110ae Compare February 1, 2019 13:21
@@ -718,10 +718,10 @@ class StoragePlanRewriter : public IRMutator {
src_entry->attach_scope_ == thread_scope_ &&
src_entry->elem_type == ae.alloc->type.element_of() &&
visitor.Check(s.stmt, var, src)) {
uint64_t const_nbits = static_cast<uint64_t>(
Copy link
Contributor

@Anthony-Mai Anthony-Mai Feb 1, 2019

Choose a reason for hiding this comment

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

This change is non-necessary, and makes the code worse. It is best to do the multiplication in uint32_t and then cast the result to uint64_t, than doing the math in uint64_t, which is more expensive. Hypothetically when multiply 32 bits integers the result could overflow 32 bits range. But first it is not going to happen. Second if it happens you have a bigger problem as you cannot allocate 4GB (2^32) worth of memory at a time. So don't change here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking about an overflow. But your second point especially makes sense, I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait, it's nbits, not bytes, so it's "only" 536 MB (that's probably why it's uint64_t and not size_t in the first place). Still, the multipliers are probably small enough, as your first point mentions.

@tqchen
Copy link
Member

tqchen commented Feb 1, 2019

it is fine, given these changes are all minor fixes, we can merge this in as a single PR, please address the CI problem and comments

@alexeyr
Copy link
Contributor Author

alexeyr commented Feb 2, 2019

@tqchen I will, thanks.

@tqchen tqchen merged commit 5b8ff8d into apache:master Feb 3, 2019
@tqchen tqchen added status: accepted and removed status: need update need update based on feedbacks labels Feb 3, 2019
@tqchen
Copy link
Member

tqchen commented Feb 3, 2019

Thanks to @alexeyr @Anthony-Mai , this is now merged

libing4752 pushed a commit to libing4752/tvm that referenced this pull request Feb 18, 2019
merrymercy pushed a commit to merrymercy/tvm that referenced this pull request Feb 18, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
@yzhliu yzhliu mentioned this pull request Mar 2, 2019
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants