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

fuse constant padding into conv kernels #7515

Merged
merged 4 commits into from
Mar 2, 2021

Conversation

mbrookhart
Copy link
Contributor

cc @masahi @csullivan

Currently supports conv1d/2d/3d. I can probably do the same thing for conv transpose and pooling, but this is getting a little long, what do you guys think?

Copy link
Contributor

@csullivan csullivan left a comment

Choose a reason for hiding this comment

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

Thanks @mbrookhart!
Support for other operators that handle would be a nice follow on, but this handles the majority of problematic cases of padding happening explicitly from ONNX's use of auto_pad. On deeplabv3-mobilenetv2 this reduces the number of explicit nn.pad calls from 54 -> 11. Those remaining are part of a space to depth transformation.

src/relay/transforms/simplify_expr.cc Outdated Show resolved Hide resolved
src/relay/transforms/simplify_expr.cc Outdated Show resolved Hide resolved
@masahi masahi self-assigned this Feb 25, 2021
Copy link
Contributor

@csullivan csullivan left a comment

Choose a reason for hiding this comment

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

Wonderful! Thanks @mbrookhart

src/relay/transforms/simplify_expr.cc Show resolved Hide resolved
@csullivan
Copy link
Contributor

Note that given the layout inference of the implementation, users should consider running SimplifyExpr prior to layout transformations via ConvertLayout or otherwise. Else it may be the case that a layout_transform will block the fusion.

@masahi masahi merged commit 633ee11 into apache:main Mar 2, 2021
@masahi
Copy link
Member

masahi commented Mar 2, 2021

Thanks @mbrookhart @csullivan

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
* fuse constant padding into conv kernels

* change the kernel to support other layouts

* add channel-last test

* add a comment about bailing early
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request May 11, 2021
* fuse constant padding into conv kernels

* change the kernel to support other layouts

* add channel-last test

* add a comment about bailing early
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.

3 participants