Skip to content

[SCHEDULE] New Reduction Mode for Tensorize - #727

Merged
tqchen merged 5 commits into
apache:masterfrom
kun-zh:master
Dec 27, 2017
Merged

tqchen merged 5 commits into
apache:masterfrom
kun-zh:master

Conversation

@kun-zh

@kun-zh kun-zh commented Dec 26, 2017

Copy link
Copy Markdown
Contributor

…e 714. @tqchen , This fix can resolve the original issue which I raised. Please review it , thanks.

@tqchen tqchen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are some codestyle problem, you can reproduce locally via make lint. Other comments are explicitly inlined

Comment thread src/op/op_util.cc Outdated
Stmt body,
Stmt update)
{
Expr condition = (make_zero(Int(32)) == make_zero(Int(32))); //will try Bool(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

build a Array<Expr> containing condition, use https://github.com/dmlc/tvm/blob/master/src/arithmetic/compute_expr.h#L42 to do reduction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, please check

Comment thread src/op/op_util.cc Outdated
auto vit = dom_map.find(iv);
CHECK(vit != dom_map.end());
const Range& vrange = vit->second;
Expr newcond = ( iv->var == vrange->min);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use condition

if (likely(var1> min1) or likely(var2 > min2)) {
   update
} else {
   body
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/op/op_util.cc Outdated
return ir::Substitute(s, init);
}

Stmt TransformUpdate(const Stage& stage,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function is specific to Tensorize, move it to tensorize.cc, no need to keep comment in header file, move comment document to tensorize.cc as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, move the function into tensorize.cc

Comment thread src/op/tensorize.cc Outdated
update = MergeNest(update_nest, update);
return MergeNest(common, Block::make(init, update));
} else {
// The update

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a comment about what this logic is about. Something like

// when init intrinsic is not available, transform to reset in the first iter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/op/tensorize.cc Outdated
return MergeNest(common, Block::make(init, update));
} else {
// The update
Stmt update = TransformUpdate (stage, dom_map,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add CHECK(body.defined());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@tqchen tqchen changed the title when there is no intrin func, using body for initialization. For issu… [SCHEDULE] New Reduction Mode for Tensorize Dec 26, 2017
@tqchen

tqchen commented Dec 26, 2017

Copy link
Copy Markdown
Member

@tqchen

tqchen commented Dec 26, 2017

Copy link
Copy Markdown
Member

there is one additional drawback of the approach which requires additional verification. We cannot let the n.main_predicates do not contain conditions on the outer Reduce IterVar.

For example, if condition contains rc>1 (and rc is from [0, n) ), then the initial checking condition is no longer correct. Error shall be raised when such case is detected.

This can be done via something similar to https://github.com/dmlc/tvm/blob/master/src/op/tensorize.cc#L124

Comment thread src/op/tensorize.cc Outdated
CHECK(intrin->reduce_init.defined())
<< "Reduction init op for intrin " << intrin << " is not defined";
// Comment out the following check for the case when there is no init func
//CHECK(intrin->reduce_init.defined())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove lgtm, simply remove them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@kun-zh

kun-zh commented Dec 27, 2017

Copy link
Copy Markdown
Contributor Author

Refined the code per review comment, and add a test case in unittest, will add more cases in the following days.

@@ -0,0 +1,90 @@
import tvm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

move this to test_schedule_tensorize.py We can use different function name

@tqchen
tqchen merged commit bb6ddd2 into apache:master Dec 27, 2017
tqchen pushed a commit to tqchen/tvm that referenced this pull request Dec 31, 2017
* when there is no intrin func, using body for initialization. For issue 714.

* Refine code per review comments, and add a test case.

* Fix lint issues.
tqchen pushed a commit to tqchen/tvm that referenced this pull request Jul 6, 2018
* when there is no intrin func, using body for initialization. For issue 714.

* Refine code per review comments, and add a test case.

* Fix lint issues.
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
* when there is no intrin func, using body for initialization. For issue 714.

* Refine code per review comments, and add a test case.

* Fix lint issues.
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