CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[New IR] add Add_n op description and python api #56080
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
[New IR] add Add_n op description and python api #56080
Conversation
…r_program_translator
… refactor_program_translator
…r_program_translator
… into refactor_program_translator
…r_program_translator
你的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 overall, comments can be fixed in next PR
@@ -146,6 +147,8 @@ class {op_name} : public ir::Op<{op_name}{interfaces}{traits}> {{ | |||
'bool': 'ir::BoolAttribute', | |||
} | |||
|
|||
no_need_gen_ops = {'add_n'} |
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.
全局变量应该全大写,类似 _NO_NEED_GEN_OPS,按照规范,这个变量应该只在这文件里使用吧,“在特殊情况下需要用到全局变量时, 应将全局变量声明为模块级变量或者类属性, 并在名称前加 _ 以示为内部状态. ”,参考:https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules/#section-4
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
(void)x; | ||
|
||
std::vector<phi::DenseTensor> vec_dense_x; | ||
for (size_t i = 0; i < static_cast<size_t>(x.size()); i++) { |
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.
for (size_t i = 0; i < static_cast<size_t>(x.size()); i++) { | |
for (size_t i = 0; i < x.size(); i++) { |
VectorType.size()返回的就是size_t
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
@@ -22,7 +22,24 @@ | |||
|
|||
namespace paddle { | |||
namespace pybind { | |||
PyObject *static_api_add_n(PyObject *self, PyObject *args, PyObject *kwargs) { | |||
try { | |||
VLOG(6) << "Add mean op into program"; |
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) << "Add mean op into program"; | |
VLOG(6) << "Add add_n op into program"; |
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
ir::Value inputs() { return operand_source(0); } | ||
ir::OpResult out() { return result(0); } | ||
ir::Attribute attribute(const std::string &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.
这里是不是不需要单独加一个{}作用域
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删除
#include "paddle/phi/core/dense_tensor.h" | ||
#include "paddle/phi/core/enforce.h" | ||
#include "paddle/phi/infermeta/backward.h" | ||
#include "paddle/phi/infermeta/binary.h" |
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.
add_n 的 infer_meta 在multiary.h 中,其他的头文件是不是可以去掉
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
paddle/fluid/pybind/eager_utils.cc
Outdated
if (PyObject_TypeCheck(item, g_ir_opresult_pytype)) { | ||
result_list.emplace_back(::pybind11::handle(item).cast<ir::OpResult>()); | ||
} else if (item == Py_None) { | ||
result_list.emplace_back(); |
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.
凭空创建OpResult,这里是不是有问题,建议去掉item == Py_None的条件
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.
此处跳过处理,不默认构造opresult
why have two empty file |
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
…interface to reply #56080 (#56120) * refine program translator * fix warning: not override * fix bug * merge new modifications * modify by reviews * resolve conflicts * resolve conflicts * fix * fix * fix conflicts * pseudocode of backward * modify test * modify register op * clear other code * modify ci build bug * reply review comments * reply review comments * delete print and add_n c++ interface --------- Co-authored-by: kangguangli <kangguangli@hotmail.com>
PR types
Others
PR changes
Others
Description
手写add_n op 定义, 打通python api 创建add_n op 路径。
pcard-67164