Skip to content

Commit

Permalink
add autogen code support for merge_selected_rows (#52274)
Browse files Browse the repository at this point in the history
* add autogen code support for merge_selected_rows

* bug fixed
  • Loading branch information
GreatV authored Mar 30, 2023
1 parent 336160c commit 6cd3575
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 101 deletions.
12 changes: 12 additions & 0 deletions paddle/fluid/operators/generator/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ class {to_pascal_case(op_name)}InferVarType : public framework::VarTypeInference
}}
}};
"""
elif op_name == "merge_selected_rows":
return f"""
class {to_pascal_case(op_name)}InferVarType
: public framework::PassInDtypeAndVarTypeToOutput {{
protected:
std::unordered_map<std::string, std::string>& GetInputOutputWithSameType()
const override {{
static std::unordered_map<std::string, std::string> m{{{{"X", /*->*/ "Out"}}}};
return m;
}}
}};
"""
else:
return None

Expand Down
93 changes: 0 additions & 93 deletions paddle/fluid/operators/merge_selected_rows_op.cc

This file was deleted.

8 changes: 0 additions & 8 deletions paddle/phi/api/yaml/legacy_ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1032,14 +1032,6 @@
func : mean_all
backward : mean_all_grad

- op : merge_selected_rows
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : merge_selected_rows {selected_rows -> selected_rows}

- op : merged_adam_
args : (Tensor[] param, Tensor[] grad, Tensor[] learning_rate, Tensor[] moment1, Tensor[] moment2, Tensor[] beta1_pow, Tensor[] beta2_pow, Tensor[] master_param, Scalar beta1, Scalar beta2, Scalar epsilon, bool multi_precision, bool use_global_beta_pow)
output : Tensor[](param_out){param.size()}, Tensor[](moment1_out){param.size()}, Tensor[](moment2_out){param.size()}, Tensor[](beta1_pow_out){param.size()}, Tensor[](beta2_pow_out){param.size()}, Tensor[](master_param_out){param.size()}
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 @@ -1253,6 +1253,12 @@
extra :
attrs : [bool use_mkldnn = false]

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

- op : meshgrid
backward : meshgrid_grad
inputs :
Expand Down
8 changes: 8 additions & 0 deletions paddle/phi/api/yaml/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,14 @@
optional : bias, cu_seqlens_q, cu_seqlens_k, causal_diagonal, seqlen_k
backward : memory_efficient_attention_grad

- op : merge_selected_rows
args : (Tensor x)
output : Tensor(out)
infer_meta :
func : UnchangedInferMeta
kernel :
func : merge_selected_rows {selected_rows -> selected_rows}

- op : meshgrid
args : (Tensor[] inputs)
output : Tensor[]{inputs.size()}
Expand Down

0 comments on commit 6cd3575

Please sign in to comment.