Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions paddle/fluid/pir/dialect/operator/ir/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@
args : (Tensor[] x, bool[] share_dims_and_dtype = {})
output : Tensor[](out){x.size()}, Tensor[](xout){x.size()}

- op : share_data
args : (Tensor x)
output : Tensor(out)
kernel:
func: share_data
param: [x]
Comment on lines +166 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

share_data 和 share_buffer 的区别是什么?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前看有两个区别吧:

  1. share_data支持DenseTensor和SelectedRows,share_buffer只支持前者
  2. 内部实现有一定区别,这个区别是DenseTensor::ShareDataWithDenseTensor::ShareBufferWith的区别,从注释上看,这两者的区别是
// NOTE: For historical reasons, this interface has a special behavior,
// sharing other tensor members except lod
DenseTensor& DenseTensor::ShareDataWith(const DenseTensor& src) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不可以考虑下在新IR上能不能顺便把这个历史问题解了?上面这两个算子的差异确实不容易区分,后来的开发者如果不了解背景看到这样逻辑很容易一头雾水,搞不好又会成为历史包袱

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经讨论决定,保留share_data,删除share_buffer。从新IR下删除share_buffer的工作辛苦 @yangguohao 看下,后面单独提个PR完成下。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经讨论决定,保留share_data,删除share_buffer。从新IR下删除share_buffer的工作辛苦 @yangguohao 看下,后面单独提个PR完成下。

好的 之后我提个 PR 处理

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于share_buffer的删除,只要去掉 paddle/fluid/pir/dialect/operator/ir/ops.yaml 中的定义即可


- op : write_to_array
args : (Tensor i, Tensor x)
output : Tensor[](out)
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/pir/dialect/operator/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const std::unordered_set<std::string> LegacyOpList = {
"pd_op.c_reduce_sum_",
"pd_op.c_allreduce_max_",
"pd_op.c_allgather",
"pd_op.seed"};
"pd_op.seed",
"pd_op.share_data"};

enum class AttrType {
UNDEFINED = 0,
Expand Down
6 changes: 6 additions & 0 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3190,6 +3190,12 @@
data_type : int64_t
tensors_name : StepsTensorList

- op: share_data
inputs :
x : X
outputs :
out : Out

- op: sigmoid_cross_entropy_with_logits
backward: sigmoid_cross_entropy_with_logits_grad
inputs :
Expand Down