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

[Paddle Tensorrt] add pd_op.greater_than, pd_op.less_than marker and converter #68686

Merged
merged 13 commits into from
Oct 25, 2024

Conversation

Hanyonggong
Copy link
Contributor

PR Category

Inference

PR Types

New features

Description

card-71500
添加greater_than op 和 less_than op的marker、converter和单测

Copy link

paddle-bot bot commented Oct 14, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@Hanyonggong Hanyonggong changed the title [Paddle Tensorrt] add pd_op.greater_than and pa_op.less_than tensorrt support [Paddle Tensorrt] add pd_op.greater_than and pa_op.less_than pir support Oct 14, 2024
@Hanyonggong Hanyonggong changed the title [Paddle Tensorrt] add pd_op.greater_than and pa_op.less_than pir support [Paddle Tensorrt] add pd_op.greater_than, pa_op.less_than marker and converter Oct 14, 2024
@Hanyonggong Hanyonggong changed the title [Paddle Tensorrt] add pd_op.greater_than, pa_op.less_than marker and converter [Paddle Tensorrt] add pd_op.greater_than, pd_op.less_than marker and converter Oct 14, 2024
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.GREATER
)
return trt_cast(network, layer_output, trt.float32)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不可能只支持float32类型吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.LESS
)
return trt_cast(network, layer_output, trt.float32)
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@paddle-bot paddle-bot bot added the contributor External developers label Oct 14, 2024


@converter_registry.register("pd_op.greater_than", trt_version="8.x")
def greater_than_converter(network, paddle_op, inputs):
Copy link
Contributor

Choose a reason for hiding this comment

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

建议Binray的Converter可以合并

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Hanyonggong Hanyonggong marked this pull request as draft October 16, 2024 07:11
@Hanyonggong Hanyonggong marked this pull request as ready for review October 16, 2024 07:14
@Hanyonggong Hanyonggong marked this pull request as draft October 17, 2024 08:30
@Hanyonggong Hanyonggong marked this pull request as ready for review October 17, 2024 08:30
@Hanyonggong Hanyonggong marked this pull request as draft October 17, 2024 10:46
@Hanyonggong Hanyonggong marked this pull request as ready for review October 17, 2024 10:46
@Hanyonggong Hanyonggong marked this pull request as draft October 17, 2024 11:40
@Hanyonggong Hanyonggong marked this pull request as ready for review October 17, 2024 11:41
XieYunshen
XieYunshen previously approved these changes Oct 18, 2024
def setUp(self):
self.python_api = paddle.greater_than
self.api_args = {
"x": np.random.randn(3).astype(np.float32),
Copy link
Contributor

Choose a reason for hiding this comment

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

整体没啥问题,但是单测是否覆盖更多的类型,例如INT、float16等类型会更好。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

lizexu123
lizexu123 previously approved these changes Oct 22, 2024
@lizexu123 lizexu123 requested a review from XieYunshen October 23, 2024 06:40
XieYunshen
XieYunshen previously approved these changes Oct 23, 2024
Comment on lines 27 to 34
if paddle_op.name() == "pd_op.greater_than":
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.GREATER
)
else:
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.LESS
)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里分支处理并不严谨,建议改成这样

Suggested change
if paddle_op.name() == "pd_op.greater_than":
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.GREATER
)
else:
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.LESS
)
if paddle_op.name() == "pd_op.greater_than":
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.GREATER
)
elif paddle_op.name() == "pd_op.less_than"::
layer_output = add_elementwise_layer(
network, paddle_op, inputs, trt.ElementWiseOperation.LESS
)
else:
throw xxx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return false;
}
#if IS_TRT_VERSION_LT(8400)
VLOG(3) << "LessThanOp is not supported when TensorRT < 8.4";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
VLOG(3) << "LessThanOp is not supported when TensorRT < 8.4";
VLOG(3) << "pd_op.less_than is not supported when TensorRT < 8.4";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

auto x_dtype = pir::GetDataTypeFromValue(x);
auto y_dtype = pir::GetDataTypeFromValue(y);
if (x_dtype.isa<pir::BoolType>() || y_dtype.isa<pir::BoolType>()) {
VLOG(3) << "Greater_than op do not support bool datatype";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
VLOG(3) << "Greater_than op do not support bool datatype";
VLOG(3) << "pd_op.greater_than op do not support bool datatype";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Hanyonggong Hanyonggong dismissed stale reviews from XieYunshen and lizexu123 via 62f57eb October 23, 2024 07:51
@lizexu123 lizexu123 merged commit f1c1c95 into PaddlePaddle:develop Oct 25, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants