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

add inference api:exp_disable_tensorrt_dynamic_shape_ops #62352

Merged
merged 10 commits into from
Mar 6, 2024

Conversation

lizexu123
Copy link
Contributor

@lizexu123 lizexu123 commented Mar 4, 2024

PR types

New features

PR changes

Others

Description

Pcard-71501
推理新增dynamic_shape op禁止使用trt推理,使用原生gpu推理。
此处的dynamic shape op指的是,运行的时候shape会改变的Op,这些Op被禁止进入TRT。
image
如上图,tensorrt_engine的输入为dynamic_shape,使用

config.exp_disable_tensorrt_dynamic_shape_ops(True)
image

如图所示,使用原生gpu推理

Copy link

paddle-bot bot commented Mar 4, 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.

@lizexu123 lizexu123 closed this Mar 4, 2024
@lizexu123 lizexu123 reopened this Mar 4, 2024
@@ -813,6 +813,8 @@ struct PD_INFER_DECL AnalysisConfig {
void Exp_DisableTensorRtSubgraph(
const std::vector<std::string>& var_name_not_trt);

void Exp_DisableDynamicTensorRTOPs(bool trt_forbid_dynamic_op);
Copy link
Contributor

Choose a reason for hiding this comment

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

Exp_DisableDynamicTensorRTOPs -> Exp_DisableTensorRTDynamicShapeOPs是不是更易理解?

@@ -34,6 +34,41 @@ namespace paddle {
namespace inference {
namespace tensorrt {

bool checkForDynamicShapes(const framework::OpDesc& desc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

根据Paddle命名规范,checkForDynamicShapes->CheckForDynamicShapes

Comment on lines 3255 to 3258
if (forbid_dynamic_op_enter_into_trt) {
bool is_dynamic = checkForDynamicShapes(desc);
return is_dynamic;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

这里逻辑不太对吧,如果是动态shape,返回true?如果当前op没有支持trt converter并且是动态shape也返回true?

Comment on lines 3343 to 3346
if (forbid_dynamic_op_enter_into_trt) {
bool is_dynamic = checkForDynamicShapes(desc);
return is_dynamic;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Comment on lines 3385 to 3388
if (forbid_dynamic_op_enter_into_trt) {
bool is_dynamic = checkForDynamicShapes(desc);
return is_dynamic;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

@lizexu123 lizexu123 changed the title add inference api:exp_disable_dynamic_tensorrt_ops add inference api:exp_disable_tensorrt_dynamic_shape_ops Mar 5, 2024
if (forbid_dynamic_op_enter_into_trt && IsDynamicShapeOp(desc)) {
return false;
}

if (with_dynamic_shape) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这里需要加这几个op判断吗?

if (forbid_dynamic_op_enter_into_trt && IsDynamicShapeOp(desc)) {
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

按照前面op teller的架构写判断

@@ -34,6 +34,42 @@ namespace paddle {
namespace inference {
namespace tensorrt {

// 检查是否是动态shape,如果是动态shape,则返回true,否则返回false
Copy link
Contributor

Choose a reason for hiding this comment

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

换个英文的注释

@@ -34,6 +34,42 @@ namespace paddle {
namespace inference {
namespace tensorrt {

// 检查是否是动态shape,如果是动态shape,则返回true,否则返回false
bool IsDynamicShapeOp(const framework::OpDesc& desc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

DynamicShape 这个是和tensorrt的DynamicShape 一样吗?

@yuanlehome
Copy link
Contributor

最近添加的几个相关api,需要在paddle-inference-demo仓库中补充下api文档~

@lizexu123
Copy link
Contributor Author

最近添加的几个相关api,需要在paddle-inference-demo仓库中补充下api文档~
好的

@zhoutianzi666 zhoutianzi666 merged commit 90529ac into PaddlePaddle:develop Mar 6, 2024
30 checks passed
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.

4 participants