-
Notifications
You must be signed in to change notification settings - Fork 365
feat: support 1D, 2D, and 3D avg and max pooling dynamo converters #2317
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few code comments, otherwise looks good to me
if stride is None: | ||
stride = kernel_size | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the function documentation and the schema, it should not be allowed for stride to be None
, so this can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out! According to the schema, the stride could be []
by default, so I made changes accordingly.
@@ -0,0 +1,106 @@ | |||
from typing import Optional, Sequence, Union | |||
|
|||
# @manual=//deeplearning/trt/python:py_tensorrt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed
from torch.fx.node import Target | ||
from torch_tensorrt.dynamo.conversion.converter_utils import extend_attr_to_tuple | ||
from torch_tensorrt.fx.converters.converter_utils import ( | ||
SourceIR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch to using the torch_tensorrt.dynamo
version of SourceIR
if stride is None: | ||
stride = kernel_size | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment (can remove)
|
||
|
||
# Note: MaxPool1d uses max_pool2d as it converts to 2D first. | ||
@dynamo_tensorrt_converter(torch.ops.aten.max_pool2d.default, capability_validator=max_pool_param_validator) # type: ignore[misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could max_pool1d
support be added here as well? Schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add torch.ops.aten.max_pool1d.default
but it won't be used. Even for torch.nn.AvgPool1d
, it still calls torch.ops.aten.avg_pool2d.default
, as you can see in the test file: https://github.com/pytorch/TensorRT/pull/2317/files#diff-9fce39bc42c66d2866c41665779cab7da0a4d3fe54576925e2b66c17a1cf1ebfR20-R43
But anyways, the 1d schema looks same as others, so I added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that - I plan to add a lowering pass which will lead us to that converter, so it will still be helpful.
…/TensorRT into pool_dynamo_converters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, pending CI!
Description
Support 1D, 2D, and 3D avg and max pooling dynamo converters.
Fixes #2200
Type of change
Checklist: