expand op 对第0维(size=-1)expand时,编译存在问题
Created by: zenghsh3
#!/usr/bin/env python
# coding=utf8
# File: test_expand.py
from paddle import fluid
import numpy as np
x = fluid.layers.data(name='x', shape=[1], dtype='float32')
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
expanded_x = fluid.layers.expand(x, expand_times=[3, 1])
output = fluid.layers.concat([expanded_x, y], axis=1)
place = fluid.CPUPlace()
exe = fluid.Executor(place=place)
exe.run(fluid.default_startup_program())
feed = {'x': np.array([[0]], dtype='float32'),
'y': np.array([[0], [0], [0]], dtype='float32')}
output_np = exe.run(feed=feed, fetch_list=[output])
print(output_np)
异常输出:
Traceback (most recent call last):
File "test_expand.py", line 11, in <module>
output = fluid.layers.concat([expanded_x, y], axis=1)
File "/home/disk1/zenghongsheng/tools/paddle_py3/lib/python3.5/site-packages/paddle/fluid/layers/tensor.py", line 192, in concat
attrs={'axis': axis})
File "/home/disk1/zenghongsheng/tools/paddle_py3/lib/python3.5/site-packages/paddle/fluid/layer_helper.py", line 50, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/home/disk1/zenghongsheng/tools/paddle_py3/lib/python3.5/site-packages/paddle/fluid/framework.py", line 1207, in append_op
op = Operator(block=self, desc=op_desc, *args, **kwargs)
File "/home/disk1/zenghongsheng/tools/paddle_py3/lib/python3.5/site-packages/paddle/fluid/framework.py", line 656, in __init__
self.desc.infer_shape(self.block.desc)
paddle.fluid.core.EnforceNotMet: Enforce failed. Expected out_dims[j] == ins[i][j], but received out_dims[j]:-3 != ins[i][j]:-1.
Input tensors should have the same elements except the specify axis. at [/paddle/paddle/fluid/operators/concat_op.cc:52]