From ffc697ff8a91003bb4b8ef4c6dd9bbe7f5b4bb43 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 22 Sep 2022 16:56:18 +0800 Subject: [PATCH] Clear extra attrs of lookup_table_v2 in OpMaker (#46321) * clear extra attrs of look_up_table_v2 in opmaker * fix bug --- paddle/fluid/operators/lookup_table_v2_op.cc | 34 ------------------- .../api/yaml/generator/ops_extra_info_gen.py | 2 +- paddle/phi/api/yaml/op_compat.yaml | 7 ++++ 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/paddle/fluid/operators/lookup_table_v2_op.cc b/paddle/fluid/operators/lookup_table_v2_op.cc index 7baf76a1e1080..5f023fbad6a02 100644 --- a/paddle/fluid/operators/lookup_table_v2_op.cc +++ b/paddle/fluid/operators/lookup_table_v2_op.cc @@ -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("is_sparse", - "(boolean, default false) " - "Sparse update.") - .SetDefault(false) - .AsExtra(); - AddAttr("is_distributed", - "(boolean, default false) distributed lookup table.") - .SetDefault(false) - .AsExtra(); AddAttr("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("remote_prefetch", "").SetDefault(false).AsExtra(); - AddAttr("trainer_id", "trainer id from 0 ~ worker_num.") - .SetDefault(0) - .AsExtra(); - AddAttr("slot", "slot of id").SetDefault(0).AsExtra(); - AddAttr>("height_sections", - "Height for each output SelectedRows.") - .SetDefault(std::vector({})) - .AsExtra(); - AddAttr>( - "epmap", - "(string vector, default 127.0.0.1:6164)" - "Server endpoints in the order of input variables for mapping") - .SetDefault({}) - .AsExtra(); - AddAttr>( - "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. diff --git a/paddle/phi/api/yaml/generator/ops_extra_info_gen.py b/paddle/phi/api/yaml/generator/ops_extra_info_gen.py index 6f234e494f52d..b862d8bfe0a85 100644 --- a/paddle/phi/api/yaml/generator/ops_extra_info_gen.py +++ b/paddle/phi/api/yaml/generator/ops_extra_info_gen.py @@ -59,7 +59,7 @@ def map_code_template(attrs_str, attrs_checker_str): def parse_attr(attr_str): result = re.search( - r"(?P[a-z[\]]+)\s+(?P[a-zA-Z0-9_]+)\s*=\s*(?P\S+)", + r"(?P[a-zA-Z0-9_[\]]+)\s+(?P[a-zA-Z0-9_]+)\s*=\s*(?P\S+)", attr_str) return ATTR_TYPE_STRING_MAP[result.group('attr_type')], result.group( 'name'), result.group('default_val') diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index 7720bb5d2e2f4..2ccbdc1c383e7 100644 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -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