CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Paddle TensorRT] fix pd_op.conv2d converter and add pd_op.conv2d_transpose,pd_op.depthwise_conv2d_transpose converter #68663
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
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -323,3 +323,114 @@ def build_size_tensor( | |||
).get_output(0) | |||
|
|||
return size_tensor | |||
|
|||
|
|||
def ConvertConv2d(network, paddle_op, inputs): |
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.
注意命名,文件里的函数命名都不是驼峰命名
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.
done
python/paddle/tensorrt/impls/conv.py
Outdated
def depthwise_conv2d_converter(network, paddle_op, inputs): | ||
return ConvertConv2d(network, paddle_op, inputs) | ||
|
||
|
||
@converter_registry.register("pd_op.conv2d", trt_version="8.x") | ||
def conv2d_converter(network, paddle_op, inputs): | ||
input_tensor, weight = inputs | ||
weight_shape = paddle_op.operands()[1].source().shape | ||
|
||
padding = paddle_op.attrs().get("paddings", [0, 0]) | ||
stride = paddle_op.attrs().get("strides", [1, 1]) | ||
dilation = paddle_op.attrs().get("dilations", [1, 1]) | ||
groups = paddle_op.attrs().get("groups", 1) | ||
|
||
# weight_tensor = network.add_constant(weight_shape, weight).get_output(0) | ||
kernel_shape = trt.Dims((weight_shape[2], weight_shape[3])) | ||
|
||
conv_layer = network.add_convolution_nd( | ||
input_tensor, weight_shape[0], kernel_shape, weight | ||
) | ||
conv_layer.stride_nd = stride | ||
conv_layer.padding_nd = padding | ||
conv_layer.dilation_nd = dilation | ||
conv_layer.num_groups = groups | ||
|
||
return conv_layer.get_output(0) | ||
return ConvertConv2d(network, paddle_op, inputs) | ||
|
||
|
||
@converter_registry.register("pd_op.conv2d_transpose", trt_version="8.x") | ||
def conv2d_transpose_converter(network, paddle_op, inputs): | ||
return ConvertConv2d(network, paddle_op, inputs) | ||
|
||
|
||
@converter_registry.register( | ||
"pd_op.depthwise_conv2d_transpose", trt_version="8.x" | ||
) | ||
def depthwise_conv2d_transpose_converter(network, paddle_op, inputs): | ||
return ConvertConv2d(network, paddle_op, inputs) |
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.
这里需要写这么多次吗,可以试试一个函数套多个装饰器的做法
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.
done
PR Category
Inference
PR Types
New features
Description
card-71500
pd_op.conv2d之前的converter,对于padding为same和valid都存在精度问题,提PR修复,以及完成了pd_op.conv2d_transpose,pd_op.depthwise_conv2d_transpose converter