oneflow
oneflow copied to clipboard
[bug] `F.adaptive_max_pool2d` with `non-4D` input crashes the process (C++ CHECK abort) instead of raising a Python error
Summary
Calling oneflow.nn.functional.adaptive_max_pool2d with a 2D tensor (shape (10, 4)) — which is not a valid 4D image tensor — does not raise a Python-side argument/shape error. Instead, OneFlow proceeds and then aborts the process with a C++ CHECK failure:
-
The Python print shows
OK, got: oneflow.Size([10, 4])(suggesting the call “succeeds”), -
Immediately after, the runtime aborts with
Check failed: (2 < 2): Shape: (10,4) visit index: 2 > num_axes: 2andoneflow.ErrorProto.check_failed_error.
Code to reproduce bug
import oneflow as flow
import oneflow.nn.functional as F
print("oneflow version:", getattr(flow, "__version__", "unknown"))
# 2D input (10, 4) — typical for bounding boxes, but NOT a 4D image tensor.
x = flow.randn(10, 4)
# Call 2D adaptive max pool (expects 4D NCHW/NHWC). Many builds will abort in C++.
y = F.adaptive_max_pool2d(x, output_size=(1, 1))
print("OK, got:", y.shape) # Usually printed, then the process aborts right after
Output
oneflow version: 1.0.0.dev20250921+cpu
OK, got: oneflow.Size([10, 4])
terminate called after throwing an instance of 'oneflow::Exception'
what(): Check failed: (2 < 2): Shape: (10,4) visit index: 2 > num_axes: 2
...
Error Type: oneflow.ErrorProto.check_failed_error
...
Aborted (core dumped)
System Information
- OS: Ubuntu 22.04.4 LTS (x86_64)
- OneFlow version : 1.0.0.dev20250921+cpu
- Python version: 3.10.16