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

[PIR] translate old ir to pir_program and trt program #70364

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

risemeup1
Copy link
Contributor

@risemeup1 risemeup1 commented Dec 20, 2024

PR Category

Execute Infrastructure

PR Types

Others

Description

  • 此PR功能:
    test/ir/inference/下的单测都是跑的旧IR单测,并且覆盖的case场景比较全,之前的逻辑是将旧ir转成trt program,然后对比旧IR和trt program的结果,现在利用PT,将old ir转成 pir ,然后将pir转成trt program,对比新IR下和trr program下的结果,用此来摸底pir-trt场景下算子问题,暂时使用exe.run的方式,没有选择predictor.run的方式,此PR在多个算子验证成功

  • 暴露出的问题
    1 新IR progrma转trt program时,config文件里的输入数据只支持fp32,不支持int32,此PR修复此问题

image

2 使用predictor.run的方式遇到一些program没有builtin.paramter,在save_inference_model时不会保存.pdiparams,然后在paddle_infer.create_predictor(config)会报错
ff92546d842aba77e357144910310f06

3 有些算子对trt版本有要求,在新IR下要求trt不能低于8.6

  • To do:
    1 验证更多的算子
    2 使用inpreter.run跑新IR program和trt program

Copy link

paddle-bot bot commented Dec 20, 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.

@risemeup1 risemeup1 changed the title Tranform to trt program [PIR] translate old ir to pir_program and trt program Dec 20, 2024
keys = list(prog_config.inputs.keys())
trt_config.input_data_type = prog_config.inputs[keys[0]].dtype

paddle.framework.set_flags({"FLAGS_trt_min_group_size": 1})
Copy link
Contributor

Choose a reason for hiding this comment

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

这个在执行完对比结果的时候最好还原,设置为3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@@ -342,6 +342,143 @@ def _cast(self) -> None:
return self


def create_fake_pir_model(program_config):
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不能复用create_fake_model吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里不能复用create_fake_model吗

不可以,两个函数返回的值不一样

Comment on lines 146 to 155
# for static_shape
clear_dynamic_shape()
self.trt_param.precision = paddle_infer.PrecisionType.Float32
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False
), 1e-5
self.trt_param.precision = paddle_infer.PrecisionType.Half
yield self.create_inference_config(), generate_trt_nodes_num(
attrs, False
), (1e-3, 1e-3)
Copy link
Contributor

Choose a reason for hiding this comment

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

pir-trt下不再有static shape,可以在单测基类里设置一下,如果跑的单测case是static shape(没有设置min/max shape),直接跳过即可

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@@ -0,0 +1,173 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
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.

不需要

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.

2 participants