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_specify_tensorrt_subgraph_precision #62402

Merged
merged 11 commits into from
Mar 11, 2024

Conversation

lizexu123
Copy link
Contributor

@lizexu123 lizexu123 commented Mar 5, 2024

PR types

New features

PR changes

Others

Description

Pcard-71501
推理新增指定trt子图,让指定的trt子图跑float16,让指定的的trt子图跑int8,让指定的trt子图跑bf16(trt9.0版本以上才支持)
使用说明:

config.exp_specify_tensorrt_subgraph_precision(
            ["conv2d_1.w_0"], [""], ["conv2d_2.w_0"]
        )

第一个参数,指定跑fp16的权重的名称,第二个参数,指定跑int8的权重的名称。第三个参数,指定跑bfp16的权重的名称。
只需要指定tensorrt_engine中一个权重的名称即可。
注释掉config.disable_glog_info()可以看日志,跑了fp16和bfp16。
image
也可以通过Nsight System 查看kernel的精度

Copy link

paddle-bot bot commented Mar 5, 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 changed the title add inference api:specify_tensorrt_subgraph_precision add inference api:exp_specify_tensorrt_subgraph_precision Mar 5, 2024
bool enable_fp16 = false;
if (precision_mode == phi::DataType::FLOAT16) enable_fp16 = true;
auto enable_int8 = Get<bool>("enable_int8");

for (auto para : parameters) {
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
for (auto para : parameters) {
for (const auto& para : parameters) {

}
}

for (auto para : parameters) {
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
for (auto para : parameters) {
for (const auto& para : parameters) {

auto trt_params_run_bfp16 =
Get<std::vector<std::string>>("trt_parameter_run_bfp16");

for (auto para : parameters) {
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
for (auto para : parameters) {
for (const auto& para : parameters) {

Comment on lines 465 to 471
<<<<<<< HEAD
CP_MEMBER(trt_parameters_run_fp16_);
CP_MEMBER(trt_parameters_run_int8_);
CP_MEMBER(trt_parameters_run_bfp16_);
=======
CP_MEMBER(trt_forbid_dynamic_op_)
>>>>>>> 2ca34a759a255660844914004f2b8b59057ce0fe
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.

尬了,刚发现,已改正

@@ -813,6 +813,10 @@ struct PD_INFER_DECL AnalysisConfig {
void Exp_DisableTensorRtSubgraph(
const std::vector<std::string>& var_name_not_trt);

void Exp_Specify_TensorRT_Subgraph_Precision(
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.

ok

@@ -813,6 +813,10 @@ struct PD_INFER_DECL AnalysisConfig {
void Exp_DisableTensorRtSubgraph(
const std::vector<std::string>& var_name_not_trt);

void Exp_SpecifyTensorRTSubgraphPrecision(
Copy link
Contributor

Choose a reason for hiding this comment

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

下个PR把这几个api都加上注释

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这最后一个PR了,我改下吧

yuanlehome
yuanlehome previously approved these changes Mar 7, 2024
@zhoutianzi666 zhoutianzi666 merged commit 01f01c3 into PaddlePaddle:develop Mar 11, 2024
30 checks passed
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Mar 11, 2024
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Mar 11, 2024
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