Skip to content

Commit

Permalink
Clear extra attrs of lookup_table_v2 in OpMaker (#46321)
Browse files Browse the repository at this point in the history
* clear extra attrs of look_up_table_v2 in opmaker

* fix bug
  • Loading branch information
zyfncg authored Sep 22, 2022
1 parent 213427e commit ffc697f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 35 deletions.
34 changes: 0 additions & 34 deletions paddle/fluid/operators/lookup_table_v2_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,46 +84,12 @@ class LookupTableV2OpMaker : public framework::OpProtoAndCheckerMaker {
"An input with type int64 "
"contains the ids to be looked up in W.");
AddOutput("Out", "The lookup results, which have the same type as W.");
AddAttr<bool>("is_sparse",
"(boolean, default false) "
"Sparse update.")
.SetDefault(false)
.AsExtra();
AddAttr<bool>("is_distributed",
"(boolean, default false) distributed lookup table.")
.SetDefault(false)
.AsExtra();
AddAttr<int64_t>("padding_idx",
"(int64, default -1) "
"If the value is -1, it makes no effect to lookup. "
"Otherwise the given value indicates padding the output "
"with zeros whenever lookup encounters it in Ids.")
.SetDefault(kNoPadding);

// for parameter prefetch
AddAttr<bool>("remote_prefetch", "").SetDefault(false).AsExtra();
AddAttr<int>("trainer_id", "trainer id from 0 ~ worker_num.")
.SetDefault(0)
.AsExtra();
AddAttr<int>("slot", "slot of id").SetDefault(0).AsExtra();
AddAttr<std::vector<int64_t>>("height_sections",
"Height for each output SelectedRows.")
.SetDefault(std::vector<int64_t>({}))
.AsExtra();
AddAttr<std::vector<std::string>>(
"epmap",
"(string vector, default 127.0.0.1:6164)"
"Server endpoints in the order of input variables for mapping")
.SetDefault({})
.AsExtra();
AddAttr<std::vector<std::string>>(
"table_names",
"(string vector, the split table names that will be fetched from "
"parameter server)"
"in the order of input variables for mapping")
.SetDefault({})
.AsExtra();

AddComment(R"DOC(
Lookup Table V2 Operator.
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/api/yaml/generator/ops_extra_info_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def map_code_template(attrs_str, attrs_checker_str):

def parse_attr(attr_str):
result = re.search(
r"(?P<attr_type>[a-z[\]]+)\s+(?P<name>[a-zA-Z0-9_]+)\s*=\s*(?P<default_val>\S+)",
r"(?P<attr_type>[a-zA-Z0-9_[\]]+)\s+(?P<name>[a-zA-Z0-9_]+)\s*=\s*(?P<default_val>\S+)",
attr_str)
return ATTR_TYPE_STRING_MAP[result.group('attr_type')], result.group(
'name'), result.group('default_val')
Expand Down
7 changes: 7 additions & 0 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@
extra :
attrs : [bool use_mkldnn = false]

- op : embedding (lookup_table_v2)
backward : embedding_grad (lookup_table_v2_grad)
extra :
attrs : [bool is_sparse = false, bool is_distributed = false, bool remote_prefetch = false,
int trainer_id = 0, int slot = 0, 'int64_t[] height_sections = {}', 'str[] epmap = {}',
'str[] table_names = {}']

- op : erf
inputs :
x : X
Expand Down

0 comments on commit ffc697f

Please sign in to comment.