Paddle Print Op输出的Place错误

pod7payv  于 2021-11-30  发布在  Java
关注(0)|答案(0)|浏览(245)

复现代码:

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]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题