-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[IR] Support op attribute and refactor for new op definition #54068
[IR] Support op attribute and refactor for new op definition #54068
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
✅ This PR's description meets the template requirements! |
…tor_type_support_for_program_translator
…pport_translating_op_attribute
…_translating_op_attribute
…_translating_op_attribute
…_translating_op_attribute
…_translating_op_attribute
…_translating_op_attribute
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
paddle/ir/core/builtin_op.h
Outdated
|
||
static const char *name() { return "builtin.constant"; } | ||
|
||
static constexpr uint32_t attributes_num = 0; |
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.
constant是有属性的吧
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.
目前没有用到,先添加了Op,不确定要加什么属性。有建议吗?
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.
我后面会再支持可变 attribute 的时候重新设计一下 constOp
paddle/fluid/dialect/pd_attribute.cc
Outdated
@@ -18,7 +18,9 @@ namespace paddle { | |||
namespace dialect { | |||
phi::IntArray IntArrayAttribute::data() const { return storage()->GetAsKey(); } | |||
|
|||
phi::Scalar ScalarAttribute::data() const { return storage()->GetAsKey(); } | |||
paddle::experimental::Scalar ScalarAttribute::data() const { |
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.
这个从phi::改为 paddle::experimental::是有什么必要的原因吗?
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.
它们是两个不同的类型,在OpDesc中的Attribute类型是paddle::experimental::Scalar,所以这里做了修改。后面根据新讨论的ScalarAttribute重新适配下。
paddle/fluid/dialect/pd_interface.h
Outdated
@@ -36,7 +36,10 @@ class GetOpInfoInterface : public ir::OpInterfaceBase<GetOpInfoInterface> { | |||
struct Model : public Concept { | |||
static OpInfoTuple GetOpInfo() { return ConcreteOp::GetOpInfo(); } | |||
|
|||
Model() : Concept(GetOpInfo) {} | |||
Model() : Concept(GetOpInfo) { | |||
static_assert(sizeof(Model) == sizeof(Concept), |
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_assert(sizeof(Model) == sizeof(Concept)已经不需要了,可以在下个pr中删除。
…_translating_op_attribute
…_translating_op_attribute
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
// ops.size() = op size in BlockDesc + get_parameter_op + combine op | ||
EXPECT_EQ(op_size, p.Block(0).OpSize() + program->parameters_num() + 21); | ||
|
||
std::cout << *program << std::endl; |
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.
这行会出现编译错误
/paddle/test/cpp/ir/core/program_translator_test.cc:62:13: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘ir::Program’)
std::cout << *program << std::endl;
cmake 参数是 cmake .. -DPY_VERSION=3.7 -DWITH_GPU=OFF -DWITH_TESTING=ON
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.
有隐形冲突,目前已解决,可以拉取最新代码 / rerun 一下任务
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 types
New features
PR changes
Others
Description
This PR does the following thing:
Others
Pcard-67164