Skip to content

Conversation

@0x45f
Copy link
Contributor

@0x45f 0x45f commented Dec 28, 2022

PR types

Bug fixes

PR changes

OPs

Describe

修改默认的GetExpectedKernelType逻辑。默认GetExpectedKernelType的逻辑是根据inputs最后一个var的type选择kernel类型,但是支持可变attrs后对于tensor类型的attr会被加入到inputs,导致会被错误的通过attr选择kernel类型,本PR对这个错误进行了修复

@paddle-bot
Copy link

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

auto tmp_list = ctx.InNameList();
std::vector<std::string> in_name_list;
std::transform(tmp_list.begin(),
tmp_list.end(),
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以去掉

if (Info().HasOpProtoAndChecker()) {
for (auto& attr : Info().Proto().attrs()) {
auto it =
std::find(in_name_list.begin(), in_name_list.end(), attr.name());
Copy link
Contributor

Choose a reason for hiding this comment

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

这里使用std::find_if,第三个参数用lambda函数即可,会更简洁一些。用法参考:https://en.cppreference.com/w/cpp/algorithm/find

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改感谢

@0x45f 0x45f merged commit 8a85955 into PaddlePaddle:develop Dec 30, 2022
@0x45f 0x45f deleted the fix-get-expected-kernel-type branch December 30, 2022 02:43
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