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

[Frontend][Tensorflow] Support SAME padding for dynamic h, w when stride == 1 #7885

Merged
merged 3 commits into from
Apr 21, 2021

Conversation

trevor-m
Copy link
Contributor

@trevor-m trevor-m commented Apr 19, 2021

Previously TVM would throw an error if an operator was using SAME padding and also had a dynamic H or W dimension:
unsupported operand type(s) for %: 'Any' and 'int'

However, if stride == 1, then the input dimension value is actually not needed to compute the padding values.

Also added explicit message for the remaining unsupported case (strides != 1).

Added a test case for pooling, but this change helps all of the following operators:

  • Conv2D
  • Conv2DBackpropInput
  • DepthwiseConv2dNative
  • Conv3D
  • Conv3DBackpropInputV2
  • AvgPool
  • MaxPool
  • AvgPool3D
  • MaxPool3D
  • Dilation2D

If strides is not 1, we currently don't have a way to support the dynamic padding. I did some experiments, but it seems type inferencing through dyn.nn.pad is not sufficient because it doesn't know that only H and W dimensions are padded. Also, the output wouldn't be correct due to count_include_pad=False. So it seems we would need to modify all of these relay operators in order to fully support SAME or dynamic padding.

Copy link
Contributor

@kevinthesun kevinthesun left a comment

Choose a reason for hiding this comment

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

LGTM

@trevor-m
Copy link
Contributor Author

Thanks for reviewing!

@kevinthesun kevinthesun merged commit f28c75f into apache:main Apr 21, 2021
@kevinthesun
Copy link
Contributor

Thanks @trevor-m

mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Apr 22, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
echuraev pushed a commit to echuraev/tvm that referenced this pull request Apr 29, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
umangyadav pushed a commit to umangyadav/tvm that referenced this pull request May 5, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

* Fix lint
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request May 11, 2021
…ide == 1 (apache#7885)

* Support SAME padding for dynamic workloads when stride == 1

* Fix lint

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