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

Fix inceptionv3 #1446

Merged
merged 4 commits into from
Jul 18, 2018
Merged

Fix inceptionv3 #1446

merged 4 commits into from
Jul 18, 2018

Conversation

kevinthesun
Copy link
Contributor

Fix bugs for conv2d padding and conversion of avg pooling from mxnet to nnvm.
@yzhliu @yidawang

@tqchen
Copy link
Member

tqchen commented Jul 17, 2018

@@ -163,7 +163,7 @@ def _declaration_conv_NCHWc(wkl, sch, data, kernel):
out_height = (wkl.height + 2 * HPAD - wkl.hkernel) // HSTR + 1
out_width = (wkl.width + 2 * WPAD - wkl.wkernel) // WSTR + 1

DOPAD = (HPAD != 0 and WPAD != 0)
DOPAD = (HPAD != 0 or WPAD != 0)
Copy link
Member

@merrymercy merrymercy Jul 17, 2018

Choose a reason for hiding this comment

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

This is redundant.
We can always call nn.pad here and inline in the schedule.
Inline is able to simplify the case without padding to the simplest form.

Copy link
Contributor Author

@kevinthesun kevinthesun Jul 17, 2018

Choose a reason for hiding this comment

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

I think DOPAD helps avoid unnecessary pad operation. When padding is 0, nn.pad will still copy input to a new tensor.

Copy link
Member

@merrymercy merrymercy Jul 18, 2018

Choose a reason for hiding this comment

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

Yes, but if we inline the pad stage in schedule. They are the same.
If pad is zero, nn.pad simply copy the tensor. Then inline can eliminate this useless copy.

So we don't need to treat them as two cases.

Copy link
Member

Choose a reason for hiding this comment

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

@merrymercy I remember inline padding will introduce if/else in conv computing, which actually slows down compare to doing copy beforehand.

Copy link
Member

Choose a reason for hiding this comment

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

You can take a look at nn.pad. If all padding is zero, no if/else is introduced.
https://github.com/dmlc/tvm/blob/f32841fa839ecf09e512f702d3e9e28c27fe603f/topi/python/topi/nn/pad.py#L46

Copy link
Member

Choose a reason for hiding this comment

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

oh, yes, you're saying data_pad.inline(), I thought you guys were talking about inline pad into conv.

@tqchen
Copy link
Member

tqchen commented Jul 18, 2018

@merrymercy has a good point and may simplify the logic. Since this is a bugfix and the current way is also fine. I am going to merge this first, we can make followup changes

@tqchen tqchen merged commit 4a464c6 into apache:master Jul 18, 2018
@kevinthesun kevinthesun deleted the FixInception branch July 18, 2018 22:29
tqchen pushed a commit to tqchen/tvm that referenced this pull request Aug 4, 2018
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
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.

None yet

5 participants