lod_append

paddle.fluid.layers.nn. 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. The data type should be int32, int64, float32 or float64.

  • level (list|tuple|Variable, optional) – The LoD level to be appended into LoD of x. If level is variable and its lod level>0, the data type can be any type. If level is variable and its lod level=0, the data type should be int32.

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])