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

[Torch] Add support for max_pool1d #5142

Merged
merged 4 commits into from
Mar 24, 2020
Merged

[Torch] Add support for max_pool1d #5142

merged 4 commits into from
Mar 24, 2020

Conversation

wyc-ruiker
Copy link
Contributor

Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

add max_pool1d in #5133, @masahi @alexwong

@wyc-ruiker wyc-ruiker changed the title Wyc [Torch] Add support for max_pool1d Mar 24, 2020
input_data = torch.rand(input_shape).float()
verify_model(MaxPool1D1().float().eval(), input_data=input_data)
verify_model(MaxPool1D2().float().eval(), input_data=input_data)
verify_model(MaxPool1D3().float().eval(), input_data=input_data)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -213,12 +213,33 @@ def _impl(inputs, input_types):
pool_size = _infer_shape(inputs[1])
strides = _infer_shape(inputs[2])
padding = _infer_shape(inputs[3])

dilation = _infer_shape(inputs[4])
Copy link
Member

@masahi masahi Mar 24, 2020

Choose a reason for hiding this comment

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

does pooling have dilation argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In https://pytorch.org/docs/stable/nn.html#maxpool1d, MaxPool1d and MaxPool2d have dilation argument.

@@ -987,6 +987,10 @@ Array<te::Tensor> Pool1DCompute(const Attrs& attrs,
<< " or 4-D input (e.g. NCWc on for vector instructions)"
<< " or 5-D input (e.g. NCWnc for tensor accelerators)";

if (param->padding.size() == 1) {
padding.push_back(padding[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? Does 1D pooling require two pad values (left & right)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -363,9 +363,35 @@ class MaxPool2D2(Module):
def forward(self, *args):
return torch.nn.MaxPool2d(kernel_size=[10, 10])(args[0])

class MaxPool2D3(Module):
Copy link
Member

Choose a reason for hiding this comment

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

Remove this wrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't we need a test for padding and stride in Maxpool?

Copy link
Member

Choose a reason for hiding this comment

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

I am talking about the same point as https://github.com/apache/incubator-tvm/pull/5142/files#r397046667

Yes, you should have a test, but no need to write a wrapper class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am talking about the same point as https://github.com/apache/incubator-tvm/pull/5142/files#r397046667

Yes, you should have a test, but no need to write a wrapper class

Thanks. I misunderstood your review suggestion :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@masahi masahi merged commit 3aabbd9 into apache:master Mar 24, 2020
@masahi
Copy link
Member

masahi commented Mar 24, 2020

Thanks @wyc-ruiker

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 16, 2020
* [Torch] Add support for max_pool1d

* add test

* fix line-too-long

* remove wrapper class
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Apr 17, 2020
* [Torch] Add support for max_pool1d

* add test

* fix line-too-long

* remove wrapper class
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.

2 participants