bug描述 Describe the Bug
paddle.minimum raises PreconditionNotMet when the inputs are broadcastable and the resulting tensor has a zero-sized dimension. The same operation should be well-defined by broadcasting rules: [0, 5] and [1, 5] broadcast to [0, 5], and no element computation is required.
Minimal reproducing example:
import paddle
print("paddle:", paddle.__version__)
# This also fails on CPU if "gpu:0" is changed to "cpu".
paddle.device.set_device("gpu:0")
x = paddle.empty([0, 5], dtype="int64")
y = paddle.ones([1, 5], dtype="int64")
out = paddle.minimum(x, y)
print(out.shape, out.dtype, out.place)
Expected result:
[0, 5] paddle.int64 Place(gpu:0)
Actual result:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File ".../site-packages/paddle/tensor/math.py", line 1311, in minimum
return _C_ops.minimum(x, y)
RuntimeError: (PreconditionNotMet) The meta data must be valid when call the mutable data function.
[Hint: Expected valid() == true, but received valid():0 != true:1.]
(at ../paddle/phi/core/dense_tensor.cc:127)
For reference, PyTorch handles the same broadcasted zero-sized shape:
import torch
x = torch.empty((0, 5), device="cuda", dtype=torch.int64)
y = torch.ones((1, 5), device="cuda", dtype=torch.int64)
print(torch.minimum(x, y).shape)
其他补充信息 Additional Supplementary Information
Reproduced in a fresh Python process with CUDA_LAUNCH_BLOCKING=1.
The same error is observed on CPU and GPU.
Environment used for reproduction:
- Python: 3.10.20
- PaddlePaddle: 2.6.1
- GPU: NVIDIA GeForce RTX 3090
- NVIDIA driver: 595.58.03
- Paddle CUDA runtime: 11.7
bug描述 Describe the Bug
paddle.minimumraisesPreconditionNotMetwhen the inputs are broadcastable and the resulting tensor has a zero-sized dimension. The same operation should be well-defined by broadcasting rules:[0, 5]and[1, 5]broadcast to[0, 5], and no element computation is required.Minimal reproducing example:
Expected result:
Actual result:
For reference, PyTorch handles the same broadcasted zero-sized shape:
其他补充信息 Additional Supplementary Information
Reproduced in a fresh Python process with
CUDA_LAUNCH_BLOCKING=1.The same error is observed on CPU and GPU.
Environment used for reproduction: