Skip to content

Commit 2e48ab6

Browse files
committed
add more detailed comment
1 parent 7ebef49 commit 2e48ab6

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

paddle/fluid/operators/merge_ids_op.cc

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,46 @@ class MergeIdsOpMaker : public framework::OpProtoAndCheckerMaker {
3030

3131
AddComment(R"DOC(
3232
Merge multi LoDTensor's into one according to Ids's shard num.
33-
The values in the input LoDTensor are lookuped from the output of split_ids_op
33+
34+
35+
split_ids_op -> prefetch_op -> merge_ids_op
36+
37+
38+
merge_ids_op should be used after split_ids_op and prefetch_op, split_ids_op
39+
will split input Ids into multiple tensors according to Id's shard number.
40+
prefetch_op will send them to parameter server to prefetch embedding value
41+
back. During split, the order of ids is disordered. In merge_ids_op we use
42+
the original Ids to restore the order of the fetched embedding value and
43+
also pass the lod information to the merged output.
44+
3445
3546
Example:
36-
Input:
37-
Ids = [1,2,3,4,5,6]
38-
X0 = [[0.1 0.2] # 3
39-
[0.2 0.3]] # 6
40-
X1 = [[0.3 0.4] # 1
41-
[0.4 0.5]] # 4
42-
X2 = [[0.5 0.6] # 2
43-
[0.6 0.7]] # 5
44-
45-
Output:
46-
Out = [[0.3 0.4] # 1
47-
[0.5 0.6] # 2
48-
[0.1 0.2] # 3
49-
[0.4 0.5] # 4
50-
[0.6 0.7] # 5
51-
[0.2 0.3]] # 6
47+
48+
Ids = [1,2,3,4,5,6] # 3 shared
49+
50+
split_ids_op ->
51+
52+
Id0 = [3, 6]
53+
Id1 = [1, 4]
54+
Id2 = [2, 5]
55+
56+
prefetch_op ->
57+
58+
X0 = [[0.3 0.3] # 3
59+
[0.6 0.6]] # 6
60+
X1 = [[0.1 0.1] # 1
61+
[0.4 0.4]] # 4
62+
X2 = [[0.2 0.2] # 2
63+
[0.5 0.5]] # 5
64+
65+
merge_ids_op ->
66+
67+
Out = [[0.1 0.1] # 1
68+
[0.2 0.2] # 2
69+
[0.3 0.3] # 3
70+
[0.4 0.4] # 4
71+
[0.5 0.5] # 5
72+
[0.6 0.6]] # 6
5273
)DOC");
5374
}
5475
};

0 commit comments

Comments
 (0)