-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[PHI]Move sum op to PHI #45860
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
[PHI]Move sum op to PHI #45860
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
| if (x.size() > 0 && x[0]->initialized() && DenseTensor::classof(x[0])) { | ||
| if ((static_cast<const DenseTensor*>(x[0]))->Holder() == out->Holder()) { | ||
| in_place = true; | ||
| } | ||
| } | ||
|
|
||
| if (in_num >= 1 && DenseTensor::classof(x[0]) && x[0]->initialized()) { |
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.
已删除重复条件
| auto in = EigenVector<T>::Flatten(in_t); | ||
| result.device(place) = result + in; | ||
| } | ||
| VLOG(10) << "end sum kernel"; |
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 kernel会不会更合适一些?
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
|
|
||
| template <typename T, typename Context> | ||
| void AddNKernel(const Context& dev_ctx, | ||
| const std::vector<const SelectedRows*>& x, |
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::vector<const TensorBase*> 的kernel还需要std::vector<const SelectedRows*>类型的吗?
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.
需要,逻辑不同
chenwhql
left a comment
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的python api下面也需要去掉is_dense的判断分支
| namespace phi { | ||
|
|
||
| template <typename T, typename Context> | ||
| void AddNKernel(const Context& dev_ctx, |
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.
加注释说明一下,原则上TensorBase不允许作为kernel输入类型,这里主要是为了兼容fluid
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
|
|
||
| ////////////////// Forward api impls ////////////////////// | ||
|
|
||
| Tensor add_n_impl(const std::vector<Tensor>& x) { |
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_sr吗
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_sr的逻辑,3q
done |
chenwhql
left a comment
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
XiaoguangHu01
left a comment
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
Others
PR changes
Others
Describe
该pr主要做了如下工作:
1,将sum op的kernel迁移至phi并重构InferMeta进行兼容适配
2,混合Tensor类型的vector输入的算子迁移机制开发完善
3,InferShape兼容组件在SelectedRows情景下的多处bug修复
4,MetaTensor功能扩展,支持Tensor类型判断。