Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions paddle/fluid/pir/dialect/op_generator/ops_api_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
'c_reducescatter',
'c_softmax_with_cross_entropy',
'decayed_adagrad',
'distributed_push_sparse',
'distributed_lookup_table',
'dpsgd',
'embedding_grad_sparse',
Expand Down
9 changes: 9 additions & 0 deletions paddle/fluid/pir/dialect/operator/ir/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@
func : distributed_lookup_table
data_type : dtype

- op : distributed_push_sparse
args : (Tensor[] ids, Tensor[] shows, Tensor[] clicks, int table_id = 0, int size = 8, bool is_distributed = false, str push_sparse_version = "push_sparse", int64_t padding_idx = -1, DataType dtype=DataType::FLOAT32, bool is_test = false, bool use_cvm_op = false)
output : Tensor[](output){ids.size()}
infer_meta :
func : DistributedPushSparseInferMeta
kernel :
func: distributed_push_sparse
data_type : dtype

- op : divide
args : (Tensor x, Tensor y)
output : Tensor(out)
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/pir/dialect/operator/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const std::unordered_set<std::string> LegacyOpList = {
CBroadcast_Op::name(),
CSyncCalcStream_Op::name(),
CSyncCommStream_Op::name(),
DistributedPushSparseOp::name(),
FtrlOp::name(),
FusedElemwiseAddActivationOp::name(),
FusedElemwiseAddActivationGradOp::name(),
Expand Down
6 changes: 4 additions & 2 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,10 @@
out : Out

- op : distributed_push_sparse
extra :
attrs : ['int[] slots = {}']
inputs :
{ids : Ids, shows : Shows, clicks: Clicks}
outputs :
out : Outputs

- op : divide (elementwise_div)
backward : divide_grad (elementwise_div_grad)
Expand Down
26 changes: 26 additions & 0 deletions paddle/phi/infermeta/ternary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,32 @@ void BoxCoderInferMeta(const MetaTensor& prior_box,
output_box->set_dtype(target_box.dtype());
}

void DistributedPushSparseInferMeta(
const std::vector<const MetaTensor*>& ids,
const std::vector<const MetaTensor*>& shows,
const std::vector<const MetaTensor*>& clicks,
int table_id,
int size,
bool is_distributed,
const std::string& push_sparse_version,
int64_t padding_idx,
DataType dtype,
bool is_test,
bool use_cvm_op,
std::vector<MetaTensor*> output) {
auto ids_dims = ids[0]->dims();
PADDLE_ENFORCE_EQ(ids_dims.size(),
2,
phi::errors::InvalidArgument(
"The dimension of the 'Ids' tensor must be 2."));
for (auto& out : output) {
if (out == nullptr) {
continue;
}
out->set_dtype(ids[0]->dtype());
Copy link
Contributor

Choose a reason for hiding this comment

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

这个output不需要设置dim信息吗?

Copy link
Contributor

Choose a reason for hiding this comment

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

这个output不需要设置dim信息吗?

原本的InferShape里并没有相关代码,这类Op一般是通过pass插入,不是正常组网得到的,我觉得还是不加为好。

}
}

void DpsgdInferMeta(const MetaTensor& param,
const MetaTensor& grad,
const MetaTensor& learning_rate,
Expand Down
14 changes: 14 additions & 0 deletions paddle/phi/infermeta/ternary.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ void BoxCoderInferMeta(const MetaTensor& prior_box,
MetaTensor* output_box,
MetaConfig config = MetaConfig());

void DistributedPushSparseInferMeta(
const std::vector<const MetaTensor*>& ids,
const std::vector<const MetaTensor*>& shows,
const std::vector<const MetaTensor*>& clicks,
int table_id,
int size,
bool is_distributed,
const std::string& push_sparse_version,
int64_t padding_idx,
DataType dtype,
bool is_test,
bool use_cvm_op,
std::vector<MetaTensor*> output);

void DpsgdInferMeta(const MetaTensor& param,
const MetaTensor& grad,
const MetaTensor& learning_rate,
Expand Down