Skip to content

Commit

Permalink
[ONNX][TOPI][Relay]Support dilations in pooling operators (apache#7928)
Browse files Browse the repository at this point in the history
* change more pooling operators

dilations -> dilation to match old field names in conv

fix python interface into new relay nodes

fix order of arguments

update type relation for dilations

change topi interface to use dilations

* spooky, there are two implementations! Change to 1 topi

use generic poolnd instead of 2d implementation for topi

remove old pooling topi

* rename pool --> pool2d in topi

change pool -> pool2d, make topi tests work now

make op level 2 pass with interface changes

fix dilation being hardcoded to 1

proper calculation for avgs among dilations

proper avg pool padding behavior

change name of pool test to pool2d test

* add poolnd baseline implementation

more fixes to edge cases for poolnd, delete old versions

replace topi tests with new baseline python version

clean up tests

make tests more readable kind of

add dilation topi tests FINALLY

remove see_pool.py

remove dilation from grad

* fix subtle implementation detail between topi and baseline python pool op

* rewrite tests to be more generic for relay pooling ops

add relay dilation tests, FINALLY

add some comments to testing code

linting and formatting

add ASF header

make 10/10 for black formatting lol

more appeasing the formatting gods

wow

add parameters to documentation

fix test import

Jostle CI

fix more broken unit tests using old version of pool

fix wrong var used for bound calc

add dilation to arm tests

add docstring to python make funcs

* fix pattern utils out of place args

* properly forward more tests to use dilations in pooling

formatting

more formatting

relax constraints on test to make it pass

relax more constraints

fix some pytorch frontend errors

fix error

better test conditions

jostle build

* fix padding bug with ceil mode

jostle build

cleaner pool condition

remove see_pool.py again

* add dilations field to onnx importer

blacking files

black file

* address matthew's comments
  • Loading branch information
AndrewZhaoLuo authored and Trevor Morris committed May 6, 2021
1 parent 858c274 commit c40c05f
Show file tree
Hide file tree
Showing 26 changed files with 1,419 additions and 936 deletions.
24 changes: 24 additions & 0 deletions include/tvm/relay/attrs/nn.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ struct MaxPool2DAttrs : public tvm::AttrsNode<MaxPool2DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> padding;
Array<IndexExpr> dilation;
tvm::String layout;
bool ceil_mode;

Expand All @@ -694,6 +695,9 @@ struct MaxPool2DAttrs : public tvm::AttrsNode<MaxPool2DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1, 1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1, 1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0, 0}))
.describe(
Expand All @@ -717,6 +721,7 @@ struct AvgPool2DAttrs : public tvm::AttrsNode<AvgPool2DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> padding;
Array<IndexExpr> dilation;
tvm::String layout;
bool ceil_mode;
bool count_include_pad;
Expand All @@ -726,6 +731,9 @@ struct AvgPool2DAttrs : public tvm::AttrsNode<AvgPool2DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1, 1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1, 1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0, 0}))
.describe(
Expand Down Expand Up @@ -813,6 +821,7 @@ struct AdaptivePool3DAttrs : public tvm::AttrsNode<AdaptivePool3DAttrs> {
struct MaxPool1DAttrs : public tvm::AttrsNode<MaxPool1DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> dilation;
Array<IndexExpr> padding;
std::string layout;
bool ceil_mode;
Expand All @@ -822,6 +831,9 @@ struct MaxPool1DAttrs : public tvm::AttrsNode<MaxPool1DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0}))
.describe(
Expand All @@ -843,6 +855,7 @@ struct MaxPool1DAttrs : public tvm::AttrsNode<MaxPool1DAttrs> {
struct AvgPool1DAttrs : public tvm::AttrsNode<AvgPool1DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> dilation;
Array<IndexExpr> padding;
std::string layout;
bool ceil_mode;
Expand All @@ -853,6 +866,9 @@ struct AvgPool1DAttrs : public tvm::AttrsNode<AvgPool1DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0}))
.describe(
Expand All @@ -877,6 +893,7 @@ struct AvgPool1DAttrs : public tvm::AttrsNode<AvgPool1DAttrs> {
struct MaxPool3DAttrs : public tvm::AttrsNode<MaxPool3DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> dilation;
Array<IndexExpr> padding;
std::string layout;
bool ceil_mode;
Expand All @@ -886,6 +903,9 @@ struct MaxPool3DAttrs : public tvm::AttrsNode<MaxPool3DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1, 1, 1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1, 1, 1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0, 0, 0}))
.describe(
Expand All @@ -908,6 +928,7 @@ struct MaxPool3DAttrs : public tvm::AttrsNode<MaxPool3DAttrs> {
struct AvgPool3DAttrs : public tvm::AttrsNode<AvgPool3DAttrs> {
Array<IndexExpr> pool_size;
Array<IndexExpr> strides;
Array<IndexExpr> dilation;
Array<IndexExpr> padding;
std::string layout;
bool ceil_mode;
Expand All @@ -918,6 +939,9 @@ struct AvgPool3DAttrs : public tvm::AttrsNode<AvgPool3DAttrs> {
TVM_ATTR_FIELD(strides)
.set_default(Array<IndexExpr>({1, 1, 1}))
.describe("Specifies the strides of the convolution.");
TVM_ATTR_FIELD(dilation)
.set_default(Array<IndexExpr>({1, 1, 1}))
.describe("Specifies the dilation of the convolution.");
TVM_ATTR_FIELD(padding)
.set_default(Array<IndexExpr>({0, 0, 0}))
.describe(
Expand Down
Loading

0 comments on commit c40c05f

Please sign in to comment.