-
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
Refactor op info parser #54859
Refactor op info parser #54859
Conversation
… add_kernel_dialect
… add_kernel_dialect
… lower_pd_op_to_kernel_dialect
… lower_pd_op_to_kernel_dialect
… lower_pd_op_to_kernel_dialect
… lower_pd_op_to_kernel_dialect
… new_interprector_support_new_IR
… new_interprector_support_new_IR
… new_interprector_support_new_IR
… new_interprector_support_new_IR
… new_ir_support_data_transfer
…e/Paddle into refactor_op_info_parser
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
@@ -48,6 +48,21 @@ const std::string& OpYamlInfoParser::AttrTypeName( | |||
return it->second.type_name; | |||
} | |||
|
|||
const std::string& OpYamlInfoParser::TensorAttrTypeName( | |||
const std::string& name) const { | |||
auto it = map_input_info_.find(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.
从新 IR 代码里的命名规范来看,不需要以map_
、vec_
此类数据结构作为 Prefix,命名以「简洁达义」为第一原则。
参考 IrContextImpl里的命名:
std::unordered_map<TypeId, AbstractType *> registed_abstract_types_;
ir::SpinLock registed_abstract_types_lock_;
// TypeStorage uniquer and cache instances.
StorageManager registed_type_storage_manager_;
// Cache some built-in type objects.
BFloat16Type bfp16_type;
Float16Type fp16_type;
Float32Type fp32_type;
Float64Type fp64_type;
Int16Type int16_type;
Int32Type int32_type;
Int64Type int64_type;
// Cached AbstractAttribute instances.
std::unordered_map<TypeId, AbstractAttribute *> registed_abstract_attributes_;
ir::SpinLock registed_abstract_attributes_lock_;
// AttributeStorage uniquer and cache instances.
StorageManager registed_attribute_storage_manager_;
// The dialect registered in the context.
std::unordered_map<std::string, Dialect *> registed_dialect_;
ir::SpinLock registed_dialect_lock_;
// The Op registered in the context.
OpInfoMap registed_op_infos_;
ir::SpinLock registed_op_infos_lock_;
ir::SpinLock destructor_lock_;
(*it)->dyn_cast<paddle::dialect::OpYamlInfoInterface>(); | ||
OpYamlInfoParser* op_info_parser = nullptr; | ||
if (op_info_interface) { | ||
op_info_parser = new OpYamlInfoParser(op_info_interface.GetOpInfo()); |
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.
这里为什么new了一个heap上的对象?我看后面并没有显式delete?
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.
确实有泄露,这个只是算子个数有关系,我提个pr修一下
|
||
auto& attr_type_name = op_yaml_info.AttrTypeName(t); | ||
|
||
if (attr_type_name == "paddle::dialect::IntArrayAttribute") { |
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.
string的比较是否比较低效?后续是否会考虑借助AttrType体系(如enum 或 isa)搭配 switch 来替换?
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.
这个可以考虑下
VLOG(6) << "ctx->EmplaceBackAttr: " << t; | ||
auto& attr_type_name = op_yaml_info.AttrTypeName(t); | ||
if (attr_type_name == "paddle::dialect::IntArrayAttribute") { | ||
ctx->EmplaceBackAttr( |
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.
这个代码段似乎出现了多次,后续可以考虑抽离复用提升可维护性?
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.
会的, 这个是前置pr,需要在这个基础上在迭代
… refactor_op_info_parser
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 overall
… refactor_op_info_parser
PR types
Others
PR changes
Others
Description
重构op yaml info模块,使用统一的模块,构造需要的信息,减少冗余代码
###Others
Pcard-67164