-
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
【NewIR】modify static_op_function vector mutable attr bug (Split op ) #57218
【NewIR】modify static_op_function vector mutable attr bug (Split op ) #57218
Conversation
… dev/refine_mutable_attr_split
你的PR提交成功,感谢你对开源项目的贡献! |
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
@@ -132,19 +132,29 @@ def _gen_api_inputs(self, op_info): | |||
ret.append(f'{self._type_map[type]} {name}') | |||
return ', '.join(ret) | |||
|
|||
def _gen_api_attrs(self, op_info, with_default, is_mutable_attr): | |||
def _gen_api_attrs( | |||
self, op_info, with_default, is_mutable_attr, is_vector_mutable_sttr |
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.
is_vector_mutable_sttr -> is_vector_mutable_attr
mutable_attr.append(f'{OP_RESULT} {name}') | ||
if ( | ||
mutable_type_list[mutable_name_list.index(name)][0] | ||
== "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.
发现该pr有大量这样的写法,可以把"paddle::dialect::IntArrayAttribute"抽出来变成全局变量,或者是封装成函数,避免硬编码
@@ -132,19 +132,29 @@ def _gen_api_inputs(self, op_info): | |||
ret.append(f'{self._type_map[type]} {name}') | |||
return ', '.join(ret) | |||
|
|||
def _gen_api_attrs(self, op_info, with_default, is_mutable_attr): | |||
def _gen_api_attrs( | |||
self, op_info, with_default, is_mutable_attr, is_vector_mutable_sttr |
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.
is_vector_mutable_attr?
paddle/fluid/pybind/eager_utils.cc
Outdated
@@ -138,6 +138,25 @@ bool PyObject_CheckIROpResult(PyObject* obj) { | |||
return PyObject_TypeCheck(obj, g_ir_opresult_pytype); | |||
} | |||
|
|||
bool PyObject_CheckIRVectorOfOpResult(PyObject* obj) { | |||
if (PyList_Check(obj)) { |
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.
这里需要补充对于tuple的处理吗?
paddle/fluid/pybind/eager_utils.cc
Outdated
} | ||
for (Py_ssize_t i = 0; i < len; i++) { | ||
item = PyList_GetItem(obj, i); | ||
if (!PyObject_CheckIROpResult(item)) { |
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.
现在可以处理python端传过来的[1, OpResult, 2]这样int和OpResult混合的list吗?
PR types
Bug fixes
PR changes
others
Description
pcard-67164
修改python-c 接口代码,将可变attribute 在python-c层全部转为opreslut 传递给pd_api 接口。由于一个op可能有多个可变attribute,无法限制用户全部使用同一形式传参,而支持各个组合会使代码分支增多,因此统一处理为输入形式。
修改前生成代码为
同时,若vector 类型的attrbute 以input输入,pd_api.h 提供的接口应该为 std::vector<ir::OpResult >形式; 但static_op_function调用形式为 OpResult, 因此生成两种可变attribute input 形式的接口,加attr 形式接口共三个。
2.split python api 适配
3.ir_backward 修复full 无法创建空shape,-1shape opreslut 问题
此pr 拆解为 #57281 #57333 comments 回复#57354