-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 deny param list to solve unuse param cannot found problem #36996
Conversation
Thanks for your contribution! |
for (auto* op : cluster) { | ||
if (deny_param_list.count(op->Name())) { | ||
const auto* desc = op->Op(); | ||
if (desc == nullptr) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (desc == nullptr) continue; | |
这部分可能为空吗?如果没有可能就加PADDLE_ENFORCE吧。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可能吧,Pass中其它地方也有类似判断
static std::unordered_map<std::string, std::string> deny_param_list = { | ||
{"batch_norm", "ReserveSpace"}}; | ||
|
||
bool OpHasInput(const OpDesc* op_desc, const std::string& param_name) { | ||
const auto& inputs = op_desc->InputNames(); | ||
return std::find(inputs.cbegin(), inputs.cend(), param_name) != inputs.cend(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static std::unordered_map<std::string, std::string> deny_param_list = { | |
{"batch_norm", "ReserveSpace"}}; | |
bool OpHasInput(const OpDesc* op_desc, const std::string& param_name) { | |
const auto& inputs = op_desc->InputNames(); | |
return std::find(inputs.cbegin(), inputs.cend(), param_name) != inputs.cend(); | |
} |
if (desc == nullptr) continue; | ||
|
||
auto deny_param_name = deny_param_list.at(op->Name()); | ||
if (OpHasInput(desc, deny_param_name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (OpHasInput(desc, deny_param_name)) { | |
if (desc->Inputs.count(deny_param_name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -299,17 +307,41 @@ void AddCinnOpToGraph(const GraphNodeSet& cluster, | |||
framework::OpDesc cinn_op_desc; | |||
cinn_op_desc.SetType(kCinnLaunchOp); | |||
std::vector<std::string> input_names; | |||
|
|||
std::unordered_set<std::string> deny_var_list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
找deny_var_list
的逻辑封装成一个函数吧,返回类型为std::unordered_setstd::string 即可。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
static std::unordered_map<std::string, std::string> deny_param_list = { | ||
{"batch_norm", "ReserveSpace"}, | ||
{"transpose2", "XShape"}, | ||
{"reshape2", "XShape"}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个还是放在函数外面吧,声明本文件的静态常量对象(注意命名),和kDelim类似,放在匿名空间中就不用加static修饰。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -56,6 +56,40 @@ namespace { | |||
// & FLAGS_deny_cinn_ops. | |||
constexpr char kDelim[] = ";"; | |||
|
|||
std::unordered_set<std::string> GetDenyVarNamesList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::unordered_set<std::string> GetDenyVarNamesList( | |
std::unordered_set<std::string> GetDenyVarNames( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -56,6 +56,64 @@ namespace { | |||
// & FLAGS_deny_cinn_ops. | |||
constexpr char kDelim[] = ";"; | |||
|
|||
static const std::unordered_map<std::string, std::unordered_set<std::string>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在匿名空间中不用再加static了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Bug fixes
PR changes
APIs
Describe
解决
batch_norm
、transpose
等op存在无用输出参数,导致cinn_launch_op
运行报错的问题。