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

[CINN] Add more rules to cinn_to_pd_op pass #64354

Merged
merged 3 commits into from
May 17, 2024

Conversation

chen2016013
Copy link
Contributor

PR Category

CINN

PR Types

Improvements

Description

Pcard-67164
为cinn op到pd op的转换添加更多规则

Copy link

paddle-bot bot commented May 16, 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.

::pir::IrMapping& ir_mapping, // NOLINT
::pir::Builder& builder) { // NOLINT
VLOG(6) << "transform " << op->name() << " from cinn_op to pd_op";
auto attrs = op->attributes();
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
auto attrs = op->attributes();
const auto& attrs = op->attributes();

避免map的copy

VLOG(6) << "transform " << op->name() << " from cinn_op to pd_op";
auto attrs = op->attributes();

float scale = attrs.at("scale").dyn_cast<::pir::FloatAttribute>().data();
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
float scale = attrs.at("scale").dyn_cast<::pir::FloatAttribute>().data();
const float scale = attrs.at("scale").dyn_cast<::pir::FloatAttribute>().data();

可以养成const的习惯

::pir::IrMapping& ir_mapping, // NOLINT
::pir::Builder& builder) { // NOLINT
VLOG(6) << "transform " << op->name() << " from cinn_op to pd_op";
auto attrs = op->attributes();
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,对于不需要修改attrs的转换规则,建议使用const &,下面的函数也可以系统性看下

@chen2016013 chen2016013 merged commit 3f85a60 into PaddlePaddle:develop May 17, 2024
31 checks passed
co63oc pushed a commit to co63oc/Paddle that referenced this pull request May 18, 2024
* add more rules to cinn_to_pd_op pass

* update
co63oc pushed a commit to co63oc/Paddle that referenced this pull request May 19, 2024
* add more rules to cinn_to_pd_op pass

* update
@chen2016013 chen2016013 deleted the test0513 branch May 24, 2024 07:56
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