sequence_concat

paddle.static.nn. sequence_concat ( input, name=None ) [源代码]

注意:该OP的输入只能是LoDTensor,如果您需要处理的输入是Tensor类型,请使用 :ref:`paddle.concat <cn_api_tensor_concat>` .

该OP仅支持LoDTensor ,通过LoDTensor的LoD信息将输入的多个LoDTensor进行连接(concat),输出连接后的LoDTensor。

input是由多个LoDTensor组成的list:
    input = [x1, x2]
其中:
    x1.lod = [[0, 3, 5]]
    x1.data = [[1], [2], [3], [4], [5]]
    x1.shape = [5, 1]

    x2.lod = [[0, 2, 4]]
    x2.data = [[6], [7], [8], [9]]
    x2.shape = [4, 1]
且必须满足:len(x1.lod[0]) == len(x2.lod[0])

输出为LoDTensor:
    out.lod = [[0, 3+2, 5+4]]
    out.data = [[1], [2], [3], [6], [7], [4], [5], [8], [9]]
    out.shape = [9, 1]

参数

  • input (list of Variable) – 多个LoDTensor组成的list,要求每个输入LoDTensor的LoD长度必须一致。数据类型为float32,float64或int64。

  • name (str,可选) – 具体用法请参见 Name ,一般无需设置,默认值为None。

返回

Tensor, 输出连接后的LoDTensor,数据类型和输入一致。

代码示例

import paddle
paddle.enable_static()

x = paddle.static.data(name='x', shape=[-1, 10], dtype='float32', lod_level=1)
y = paddle.static.data(name='y', shape=[-1, 10], dtype='float32', lod_level=1)
out = paddle.static.nn.sequence_concat(input=[x, y])