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 Inference] add constant folding pass #45494

Merged
merged 53 commits into from
Aug 30, 2022

Conversation

zhoutianzi666
Copy link
Contributor

@zhoutianzi666 zhoutianzi666 commented Aug 28, 2022

PR types

Others

PR changes

Others

Describe

When a op's inputs and outputs is determined before feeding data to the model, we can remove this op from the model.
This ConstantFolding pass can remove all these like ops.

模型 关闭 启用pass
SwinTransformer_base_patch4_window12_384 45.4006 44.8208
hifigan_csmsc_static_0.1.1 25.2497 25.016

@paddle-bot
Copy link

paddle-bot bot commented Aug 28, 2022

你的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.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Aug 28, 2022
@zhoutianzi666 zhoutianzi666 changed the title Constant folding [Paddle-TRT] constant-folding Aug 28, 2022
PADDLE_ENFORCE_NOT_NULL(
graph, platform::errors::PreconditionNotMet("graph should not be null."));
FusePassBase::Init("constant_folding", graph);
auto *scope = param_scope();
Copy link
Contributor

Choose a reason for hiding this comment

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

增加nulltpr判断

for (auto out_node : op_node->outputs) {
map[out_node->Name()] = 0;
}
// Forbide other node in graph having the same name with nodes in map
Copy link
Contributor

Choose a reason for hiding this comment

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

forbid

Copy link
Contributor

@zhangjun zhangjun left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@cyj1986 cyj1986 left a comment

Choose a reason for hiding this comment

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

LGTM

@cyj1986 cyj1986 merged commit 97f43a8 into PaddlePaddle:develop Aug 30, 2022
@zhoutianzi666 zhoutianzi666 changed the title [Paddle-TRT] constant-folding [Paddle Inference] add constant folding pass Aug 14, 2023
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.

3 participants