Skip to content

Commit 3a25f21

Browse files
authored
Modify lod tensor doc based on new LoDTensor Python API (#11253)
* Modify lod_tensor.md and nn.py * Modify control_flow.py doc * undo change in lod_tensor.md
1 parent 609dccf commit 3a25f21

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

python/paddle/fluid/layers/control_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ def lod_rank_table(x, level=0):
746746
.. code-block:: text
747747
748748
x is a LoDTensor:
749-
x.lod = [[0, 2, 3],
750-
[0, 5, 6, 7]]
749+
x.lod = [[2, 1],
750+
[5, 1, 1]]
751751
x.data = [a, b, c, d, e, f, g]
752752
753753
1. set level to 0:

python/paddle/fluid/layers/nn.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,13 +1621,13 @@ def sequence_pool(input, pool_type):
16211621
.. code-block:: text
16221622
16231623
x is a 1-level LoDTensor:
1624-
x.lod = [[0, 2, 5, 7]]
1624+
x.lod = [[2, 3, 2]]
16251625
x.data = [1, 3, 2, 4, 6, 5, 1]
16261626
x.dims = [7, 1]
16271627
16281628
then output is a Tensor:
16291629
out.dim = [3, 1]
1630-
with condition len(x.lod[-1]) - 1 == out.dims[0]
1630+
with condition len(x.lod[-1]) == out.dims[0]
16311631
16321632
for different pool_type:
16331633
average: out.data = [2, 4, 3], where 2=(1+3)/2, 4=(2+4+6)/3, 3=(5+1)/2
@@ -1686,13 +1686,13 @@ def sequence_first_step(input):
16861686
.. code-block:: text
16871687
16881688
x is a 1-level LoDTensor:
1689-
x.lod = [[0, 2, 5, 7]]
1689+
x.lod = [[2, 3, 2]]
16901690
x.data = [1, 3, 2, 4, 6, 5, 1]
16911691
x.dims = [7, 1]
16921692
16931693
then output is a Tensor:
16941694
out.dim = [3, 1]
1695-
with condition len(x.lod[-1]) - 1 == out.dims[0]
1695+
with condition len(x.lod[-1]) == out.dims[0]
16961696
out.data = [1, 2, 5], where 1=first(1,3), 2=first(2,4,6), 5=first(5,1)
16971697
16981698
Args:
@@ -1719,13 +1719,13 @@ def sequence_last_step(input):
17191719
.. code-block:: text
17201720
17211721
x is a 1-level LoDTensor:
1722-
x.lod = [[0, 2, 5, 7]]
1722+
x.lod = [[2, 3, 2]]
17231723
x.data = [1, 3, 2, 4, 6, 5, 1]
17241724
x.dims = [7, 1]
17251725
17261726
then output is a Tensor:
17271727
out.dim = [3, 1]
1728-
with condition len(x.lod[-1]) - 1 == out.dims[0]
1728+
with condition len(x.lod[-1]) == out.dims[0]
17291729
out.data = [3, 6, 1], where 3=last(1,3), 6=last(2,4,6), 1=last(5,1)
17301730
17311731
Args:
@@ -2468,18 +2468,18 @@ def sequence_expand(x, y, ref_level=-1, name=None):
24682468
24692469
* Case 1
24702470
x is a LoDTensor:
2471-
x.lod = [[0, 2, 4]]
2471+
x.lod = [[2, 2]]
24722472
x.data = [[a], [b], [c], [d]]
24732473
x.dims = [4, 1]
24742474
24752475
y is a LoDTensor:
2476-
y.lod = [[0, 2, 4],
2477-
[0, 3, 6, 7, 8]]
2476+
y.lod = [[2, 2],
2477+
[3, 3, 1, 1]]
24782478
24792479
ref_level: 0
24802480
24812481
then output is a 1-level LoDTensor:
2482-
out.lod = [[0, 2, 4, 6, 8]]
2482+
out.lod = [[2, 2, 2, 2]]
24832483
out.data = [[a], [b], [a], [b], [c], [d], [c], [d]]
24842484
out.dims = [8, 1]
24852485
@@ -2489,7 +2489,7 @@ def sequence_expand(x, y, ref_level=-1, name=None):
24892489
x.dims = [3, 1]
24902490
24912491
y is a LoDTensor:
2492-
y.lod = [[0, 2, 2, 5]]
2492+
y.lod = [[2, 0, 3]]
24932493
24942494
ref_level: -1
24952495
@@ -3343,15 +3343,15 @@ def ctc_greedy_decoder(input, blank, name=None):
33433343
[0.2, 0.2, 0.1, 0.5],
33443344
[0.5, 0.1, 0.3, 0.1]]
33453345
3346-
input.lod = [[0, 4, 8]]
3346+
input.lod = [[4, 4]]
33473347
33483348
Then:
33493349
33503350
output.data = [[2],
33513351
[1],
33523352
[3]]
33533353
3354-
output.lod = [[0, 2, 3]]
3354+
output.lod = [[2, 1]]
33553355
33563356
Args:
33573357
@@ -3368,7 +3368,7 @@ def ctc_greedy_decoder(input, blank, name=None):
33683368
33693369
Returns:
33703370
Variable: CTC greedy decode result. If all the sequences in result were
3371-
empty, the result LoDTensor will be [-1] with LoD [[0]] and dims [1, 1].
3371+
empty, the result LoDTensor will be [-1] with LoD [[]] and dims [1, 1].
33723372
33733373
Examples:
33743374
.. code-block:: python
@@ -3458,15 +3458,15 @@ def sequence_reshape(input, new_dim):
34583458
.. code-block:: text
34593459
34603460
x is a LoDTensor:
3461-
x.lod = [[0, 2, 6]]
3461+
x.lod = [[2, 4]]
34623462
x.data = [[1, 2], [3, 4],
34633463
[5, 6], [7, 8], [9, 10], [11, 12]]
34643464
x.dims = [6, 2]
34653465
34663466
set new_dim = 4
34673467
34683468
then out is a LoDTensor:
3469-
out.lod = [[0, 1, 3]]
3469+
out.lod = [[1, 2]]
34703470
out.data = [[1, 2, 3, 4],
34713471
[5, 6, 7, 8], [9, 10, 11, 12]]
34723472
out.dims = [3, 4]
@@ -3737,7 +3737,7 @@ def im2sequence(input, filter_size=1, stride=1, padding=0, name=None):
37373737
37383738
output.dims = {8, 9}
37393739
3740-
output.lod = [[0, 4, 8]]
3740+
output.lod = [[4, 4]]
37413741
37423742
The simple usage is:
37433743
@@ -4133,47 +4133,47 @@ def lod_reset(x, y=None, target_lod=None):
41334133
* Example 1:
41344134
41354135
Given a 1-level LoDTensor x:
4136-
x.lod = [[ 0, 2, 5 6 ]]
4136+
x.lod = [[ 2, 3, 1 ]]
41374137
x.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41384138
x.dims = [6, 1]
41394139
4140-
target_lod: [0, 4, 6]
4140+
target_lod: [4, 2]
41414141
41424142
then we get a 1-level LoDTensor:
4143-
out.lod = [[ 0, 4, 6 ]]
4143+
out.lod = [[4, 2]]
41444144
out.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41454145
out.dims = [6, 1]
41464146
41474147
* Example 2:
41484148
41494149
Given a 1-level LoDTensor x:
4150-
x.lod = [[ 0, 2, 5 6 ]]
4150+
x.lod = [[2, 3, 1]]
41514151
x.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41524152
x.dims = [6, 1]
41534153
41544154
y is a Tensor:
4155-
y.data = [[0, 2, 6]]
4155+
y.data = [[2, 4]]
41564156
y.dims = [1, 3]
41574157
41584158
then we get a 1-level LoDTensor:
4159-
out.lod = [[ 0, 2, 6 ]]
4159+
out.lod = [[2, 4]]
41604160
out.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41614161
out.dims = [6, 1]
41624162
41634163
* Example 3:
41644164
41654165
Given a 1-level LoDTensor x:
4166-
x.lod = [[ 0, 2, 5 6 ]]
4166+
x.lod = [[2, 3, 1]]
41674167
x.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41684168
x.dims = [6, 1]
41694169
41704170
y is a 2-level LoDTensor:
4171-
y.lod = [[0, 2, 4], [0, 2, 5, 6]]
4171+
y.lod = [[2, 2], [2, 2, 1, 1]]
41724172
y.data = [[1.1], [2.1], [3.1], [4.1], [5.1], [6.1]]
41734173
y.dims = [6, 1]
41744174
41754175
then we get a 2-level LoDTensor:
4176-
out.lod = [[0, 2, 4], [0, 2, 5, 6]]
4176+
out.lod = [[2, 2], [2, 2, 1, 1]]
41774177
out.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
41784178
out.dims = [6, 1]
41794179

0 commit comments

Comments
 (0)