PaddlePaddle / PaddlePaddle/Paddle
[CPU/GPU] paddle.tile rejects repeat_times containing 0
@xuxinyi389 is already working on this.
Since Jul 14, 2026.
- Dominant language
- C++
- Stars
- 24.1k
- Forks
- 6k
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 60
Description
bug描述 Describe the Bug
paddle.tile rejects repeat_times values that contain 0. However, the documented output-size rule says that the size of each output dimension is x.shape[i] * repeat_times[i], which makes a zero repeat well-defined as a zero-sized output dimension.
Minimal reproducing example:
import traceback
import paddle
print("paddle:", paddle.__version__)
for device in ["cpu", "gpu:0"]:
paddle.device.set_device(device)
print("\nDevice:", device)
x = paddle.empty([0, 5], dtype="float32")
try:
out = paddle.tile(x, repeat_times=[1, 0])
print(out.shape, out.dtype, out.place)
except Exception:
traceback.print_exc()
Expected result:
Device: cpu
[0, 0] paddle.float32 Place(cpu)
Device: gpu:0
[0, 0] paddle.float32 Place(gpu:0)
The key point is that repeat_times=[1, 0] should produce a tensor whose second dimension is 5 * 0 == 0, instead of rejecting the repeat factor before shape construction.
Actual result:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File ".../site-packages/paddle/tensor/manipulation.py", line 3481, in tile
return _C_ops.tile(x, repeat_times)
ValueError: (InvalidArgument) Every element of the input 'repeat_times' for tile op must be greater than 0, but the value given is 0.
[Hint: Expected repeat_times_data[i] > 0, but received repeat_times_data[i]:0 <= 0:0.]
(at ../paddle/phi/infermeta/unary.cc:4424)
For reference, TensorFlow handles zero multiples and returns the expected empty shape:
import tensorflow as tf
with tf.device("/GPU:0"):
x = tf.zeros([0, 5], dtype=tf.float32)
out = tf.tile(x, multiples=[1, 0])
print(out.shape, out.dtype, out.device)
(0, 0) <dtype: 'float32'> /job:localhost/replica:0/task:0/device:GPU:0
其他补充信息 Additional Supplementary Information
Reproduced in fresh Python processes with CUDA_LAUNCH_BLOCKING=1.
Environment:
- Python: 3.10.20
- PaddlePaddle: 2.6.1
- GPU: NVIDIA GeForce RTX 3090
- NVIDIA driver: 595.58.03
- Paddle CUDA runtime: 11.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.