@@ -34,8 +34,11 @@ class LookupTableOp : public framework::OperatorWithKernel {
3434 auto ids_dims = ctx->GetInputDim (" Ids" );
3535
3636 auto ids_var_type = ctx->GetInputsVarType (" Ids" ).front ();
37- // ids_var_types also can be LOD_TENSOR_ARRAY, it's used as concat_rows.
38- // Maybe near future we will add concat_rows op.
37+ // The type of Ids(Input) is SelectedRows or LoDTensor, when Ids's type
38+ // is LoDTensor, this tensor contains the ids to be looked up in W
39+ // and it must be a column vector with rank = 2 while the 2nd dimension
40+ // size must be 1, when Ids's type is SelectedRows, the rows of Ids
41+ // contains the ids to be looked up in W;
3942 if (ids_var_type == framework::proto::VarType::LOD_TENSOR) {
4043 PADDLE_ENFORCE_EQ (ids_dims.size (), 2 );
4144 PADDLE_ENFORCE_EQ (ids_dims[1 ], 1 );
@@ -59,17 +62,22 @@ class LookupTableOpMaker : public framework::OpProtoAndCheckerMaker {
5962 LookupTableOpMaker (OpProto* proto, OpAttrChecker* op_checker)
6063 : OpProtoAndCheckerMaker(proto, op_checker) {
6164 AddInput (" W" ,
62- " An input represents embedding tensors, "
65+ " (Tensor) The input represents embedding tensors, "
6366 " which is a learnable parameter." );
64- AddInput (" Ids" ,
65- " An input with type int32 or int64 "
66- " contains the ids to be looked up in W. "
67- " Ids must be a column vector with rank = 2. "
68- " The 2nd dimension size must be 1." );
69- AddOutput (" Out" , " The lookup results, which have the same type as W." );
67+ AddInput (
68+ " Ids" ,
69+ " (Tensor or SelectedRows) Ids's type can be Tensor or "
70+ " SelectedRows, when Ids's type is Tensor, this tensor contains "
71+ " the ids to be looked up in W and it must be a column vector with "
72+ " rank = 2 while the 2nd dimension size must be 1; when Ids's type is "
73+ " SelectedRows, the rows of Ids contains the ids to be looked up "
74+ " in W." );
75+ AddOutput (" Out" ,
76+ " (Tensor or SelectedRows) The lookup results, which have the "
77+ " same type as W." );
7078 AddAttr<bool >(" is_sparse" ,
7179 " (boolean, default false) "
72- " Sparse update" )
80+ " Sparse update. " )
7381 .SetDefault (false );
7482 AddAttr<int64_t >(" padding_idx" ,
7583 " (int64, default -1) "
@@ -81,10 +89,15 @@ class LookupTableOpMaker : public framework::OpProtoAndCheckerMaker {
8189Lookup Table Operator.
8290
8391This operator is used to perform lookups on the parameter W,
84- then concatenated into a dense tensor.
92+ then concatenated into a dense or sparse tensor.
93+
94+ The type of Ids(Input) is SelectedRows, Tensor or LoDTensor, when Ids's
95+ type is SelectedRows, the rows of Ids contains the ids to be looked up in W;
96+ when Ids's type is Tensor, this tensor contains the ids to be looked up in W
97+ and it must be a column vector with rank = 2 while the 2nd dimension size must be 1,
98+ at this time, Ids can carry the LoD (Level of Details) information, or not, and
99+ the output only shares the LoD information with input Ids.
85100
86- The input Ids can carry the LoD (Level of Details) information,
87- or not. And the output only shares the LoD information with input Ids.
88101
89102)DOC" );
90103 }
0 commit comments