Skip to content

Commit 9cfa5ce

Browse files
authored
Merge pull request #7128 from pkuyym/fix-7024
Add doc for lod_rank_table.
2 parents 899a79c + 0d4fdce commit 9cfa5ce

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

python/paddle/v2/fluid/layers/control_flow.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,50 @@ def complete(self):
397397

398398

399399
def lod_rank_table(x, level=0):
400-
"""
401-
This function creates an operator for creating a LOD_RANK_TABLE
402-
using the input x.
400+
"""LoD Rank Table Operator. Given an input variable **x** and a level number
401+
of LoD, this layer creates a LodRankTable object. A LoDRankTable object
402+
contains a list of bi-element tuples. Each tuple consists of an index and
403+
a length, both of which are int type. Reffering to specified level of LoD,
404+
the index is the sequence index number and the length representes the
405+
sequence length. Please note that the list is ranked in descending order by
406+
the length. The following is an example:
407+
408+
.. code-block:: text
409+
410+
x is a LoDTensor:
411+
x.lod = [[0, 2, 3],
412+
[0, 5, 6, 7]]
413+
x.data = [a, b, c, d, e, f, g]
414+
415+
1. set level to 0:
416+
Create lod rank table:
417+
lod_rank_table_obj = lod_rank_table(x, level=0)
418+
419+
Get:
420+
lod_rank_table_obj.items() = [(0, 2), (1, 1)]
421+
422+
2. set level to 1:
423+
Create lod rank table:
424+
lod_rank_table_obj = lod_rank_table(x, level=1)
425+
426+
Get:
427+
lod_rank_table_obj.items() = [(0, 5), (1, 1), (2, 1)]
428+
429+
Args:
430+
x (Variable): Input variable, a LoDTensor based which to create the lod
431+
rank table.
432+
level (int): Specify the LoD level, on which to create the lod rank
433+
table.
434+
435+
Returns:
436+
Variable: The created LoDRankTable object.
437+
438+
Examples:
439+
.. code-block:: python
440+
441+
x = fluid.layers.data(name='x', shape=[10],
442+
dtype='float32', lod_level=1)
443+
out = layers.lod_rank_table(x=x, level=0)
403444
"""
404445
helper = LayerHelper("lod_rank_table", **locals())
405446
table = helper.create_variable(

0 commit comments

Comments
 (0)