lod_append

paddle.fluid.layers.lod_append(x, level)[source]

Append level to LoD of x.

* Example 1:

    given a 1-level LoDTensor x:
        x.lod =  [[ 2,           3,                   1 ]]
        x.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
        x.dims = [6, 1]

    level: [1, 1, 1, 1, 1, 1, 1]

    then we get a 2-level LoDTensor:
        x.lod =  [[ 2, 3, 1 ], [1, 1, 1, 1, 1, 1]]
        x.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
        x.dims = [6, 1]
Parameters
  • x (Variable) – Input variable which could be a tensor or LoDTensor.

  • level (list|tuple|Variable) – The LoD level to be appended into LoD of x.

Returns

Output variable with new LoD level.

Return type

Variable

Raises

ValueError – If y is None or and level is not Iterator.

Examples

import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[6, 10], lod_level=1)
out = fluid.layers.lod_append(x, [1,1,1,1,1,1])