Print Op输出的Place错误
Created by: mapingshuo
复现代码:
import paddle.fluid as fluid
import paddle
import numpy as np
x = fluid.layers.data(name='x', shape=[1], dtype='float32', lod_level=1)
y = fluid.layers.data(name='y', shape=[1], dtype='float32', lod_level=2)
y2 = fluid.layers.Print(y, message="The content of y")
out = fluid.layers.sequence_expand(x=x, y=y, ref_level=0)
place = fluid.CUDAPlace(0)
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
x_d = fluid.create_lod_tensor(np.array([[1.1], [2.2],[3.3],[4.4]]).astype('float32'), [[1,3]], place)
y_d = fluid.create_lod_tensor(np.array([[1.1],[1.1],[1.1],[1.1],[1.1],[1.1]]).astype('float32'), [[1,3], [1,2,1,2]], place)
results = exe.run(fluid.default_main_program(),
feed={'x':x_d, 'y': y_d },
fetch_list=[out],return_numpy=False)
结果:
Variable: y
- message: The content of y
- lod: {{0, 1, 4}{0, 1, 3, 4, 6}}
- place: CPUPlace
- shape: [6, 1]
- layout: NCHW
- dtype: float
- data: [1.1 1.1 1.1 1.1 1.1 1.1]
期待结果:
Variable: y
- message: The content of y
- lod: {{0, 1, 4}{0, 1, 3, 4, 6}}
- place: CUDAPlace(0)
- shape: [6, 1]
- layout: NCHW
- dtype: float
- data: [1.1 1.1 1.1 1.1 1.1 1.1]