ONNX broken for identity function
System Information
OpenCV python version: 4.10.0.82 PyTorch version: 2.0.0+cu117 Operating System / Platform: Ubuntu 22.04 Python version: 3.10.6
Detailed description
I have been having some issues with ONNX files lately. Decided to check that the simplest function of them all works: the identity ...
Here is a script that shows for what input shapes ONNX is broken (0, 1 and 3 dimensional inputs). I redirect stdout when exporting the ONNX file to make the output more readable.
I suspect that this is the underlying error to https://github.com/opencv/opencv/issues/25762
Steps to reproduce
import torch
import cv2 as cv
from contextlib import redirect_stdout
class Identity(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, X):
return X
model = Identity()
shape = (2,3,5,7,11,13,17,19)
for i in range(1 + len(shape)):
X = torch.zeros(shape[:i])
with open('/dev/null', 'w') as f:
with redirect_stdout(f):
torch.onnx.export(model, X, '/tmp/model.onnx', output_names=['Y'])
Y = model(X)
ok = X.shape == Y.shape
print('OK ' if ok else 'ERROR', 'PyTorch', tuple(X.shape), '->', tuple(Y.shape))
net = cv.dnn.readNetFromONNX('/tmp/model.onnx')
X = X.numpy()
net.setInput(X)
Y = net.forward(['Y'])[0]
ok = X.shape == Y.shape
print('OK ' if ok else 'ERROR', 'OpenCV ', X.shape, '->', Y.shape)
which gives me the following output (format: Dimension, OK/ERROR, PyTorch/OpenCV, SourceShape, TargetShape)
0 OK PyTorch () -> ()
0 ERROR OpenCV () -> (1, 1)
1 OK PyTorch (2,) -> (2,)
1 ERROR OpenCV (2,) -> (2, 1)
2 OK PyTorch (2, 3) -> (2, 3)
2 OK OpenCV (2, 3) -> (2, 3)
3 OK PyTorch (2, 3, 5) -> (2, 3, 5)
3 ERROR OpenCV (2, 3, 5) -> (2, 3)
4 OK PyTorch (2, 3, 5, 7) -> (2, 3, 5, 7)
4 OK OpenCV (2, 3, 5, 7) -> (2, 3, 5, 7)
5 OK PyTorch (2, 3, 5, 7, 11) -> (2, 3, 5, 7, 11)
5 OK OpenCV (2, 3, 5, 7, 11) -> (2, 3, 5, 7, 11)
6 OK PyTorch (2, 3, 5, 7, 11, 13) -> (2, 3, 5, 7, 11, 13)
6 OK OpenCV (2, 3, 5, 7, 11, 13) -> (2, 3, 5, 7, 11, 13)
7 OK PyTorch (2, 3, 5, 7, 11, 13, 17) -> (2, 3, 5, 7, 11, 13, 17)
7 OK OpenCV (2, 3, 5, 7, 11, 13, 17) -> (2, 3, 5, 7, 11, 13, 17)
8 OK PyTorch (2, 3, 5, 7, 11, 13, 17, 19) -> (2, 3, 5, 7, 11, 13, 17, 19)
8 OK OpenCV (2, 3, 5, 7, 11, 13, 17, 19) -> (2, 3, 5, 7, 11, 13, 17, 19)
As you can see, it's broken for 0, 1 and 3 dimensional inputs.
Issue submission checklist
- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)
@Abdurrahheem could you take a look?
Error cases are:
0 ERROR OpenCV () -> (1, 1)
1 ERROR OpenCV (2,) -> (2, 1)
3 ERROR OpenCV (2, 3, 5) -> (2, 3)
Let me explain one by one.
-
0 ERROR OpenCV () -> (1, 1): OpenCVMatdoes not support 0d, 1d cases; that is to say, when a 0d/1d tensor is loaded into aMat, it is converted to aMatof shape(1, 1). -
1 ERROR OpenCV (2,) -> (2, 1): Similar above. In case of 1d tensor of shape (n,), it isMatof shape(n, 1)(so it breaks the rule of broadcasting) when converted. -
3 ERROR OpenCV (2, 3, 5) -> (2, 3): In the OpenCV Python interface, a three dimensional (a, b, c) tensor is loaded into aMatof shape(a, b)with channel equals toc. More details see https://github.com/opencv/opencv/issues/23242. This is a legacy problem which should be solved in 5.x I think.
Do you mean that the errors for 0 and 1 dimensions are expected? I feels like a very bad bug to me, and it will leave ONNX integration in a broken state until fixed. So I hope this is not considered expected by OpenCV devs.
OpenCV 4.10 is latest released version, so I am not sure how to test your hypothesis for 5.x without more help. Can you please confirm that this is fixed in 5.x? If that is the case I think it should be back-ported to 4.11 as well.
Do you mean that the errors for 0 and 1 dimensions are expected? I feels like a very bad bug to me, and it will leave ONNX integration in a broken state until fixed. So I hope this is not considered expected by OpenCV devs.
0d/1d mat support is introduced since 5.x. It was a big patch and breaks some existing things. So maybe not a good idea to do a backport.
@fengyuentau Ok good point. Is the fix for 3d input also not backwards compatible or can it be included in 4.x?
@fengyuentau Ok good point. Is the fix for 3d input also not backwards compatible or can it be included in 4.x?
The 3d issue is not handle yet in either branch.
@fengyuentau Ok good point. Is the fix for 3d input also not backwards compatible or can it be included in 4.x?
The 3d issue is not handle yet in either branch.
@cdeln 3d input issue has been solved in #25810.
@fengyuentau I will try out asap :)
@fengyuentau Can you point me to some instructions on how to build and test the pybindings please?
@cdeln Check below for instructions.
# Get opencv
git clone https://github.com/opencv/opencv
# Configure opencv
cmake -B build \
-S opencv \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=build/install \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3
# If you use conda, add the following two options as well
# -D PYTHON3_EXECUTABLE=/absolute/path/to/python \
# -D PYTHON3_INCLUDE=/absolute/path/to/Python.h/location \
# -D PYTHON3_LIBRARIES=/absolute/path/to/libpython/location
# Example:
# -D PYTHON3_EXECUTABLE=/Workspace/miniconda3/bin/python \
# -D PYTHON3_INCLUDE=/Workspace/miniconda3/include/python3.10 \
# -D PYTHON3_LIBRARIES=/Workspace/miniconda3/lib \
# Build opencv
cmake --build build --target install -j8
# Install python package. Make sure you uninstall opencv packages beforehand.
python3 -m pip install ./build/python_loader
@fengyuentau Thanks. Sorry to bother you about installation matters, please redirect me if there is a better place to get help, I really want to be able to test things!
Getting this error when I import cv2, what am I missing?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/cdeln/src/opencv/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/home/cdeln/src/opencv/lib/python3.10/site-packages/cv2/__init__.py", line 112, in bootstrap
load_first_config([
File "/home/cdeln/src/opencv/lib/python3.10/site-packages/cv2/__init__.py", line 109, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.10.py', 'config-3.py']. Check OpenCV installation.
Standing in /home/cdeln/src, I configured it like this
cmake -B build \
-S opencv \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=build/install \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-DPYTHON_DEFAULT_EXECUTABLE=$(which python3)
-D PYTHON3_EXECUTABLE=$(which python3)
I use pyenv for python3, and I install the OpenCV python lib into a fresh virtual env.
@cdeln Could you post the log when you run cmake -B .. command?
If you mean cmake -B build -S opencv (assuming I stand in /home/cdeln/src, cloned OpenCV into opencv and configuring into sibling directory build), then output is
-- Detected processor: x86_64
-- Looking for ccache - found (/usr/bin/ccache)
Cleaning INTERNAL cached variable: WEBP_LIBRARY
Cleaning INTERNAL cached variable: WEBP_INCLUDE_DIR
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.10.0-dev-openjp2-2.5.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
-- Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf-2_5.so
-- libva: missing va.h header (VA_INCLUDE_DIR)
-- found Intel IPP (ICV version): 2021.11.0 [2021.11.0]
-- at: /home/cdeln/src/build/3rdparty/ippicv/ippicv_lnx/icv
-- found Intel IPP Integration Wrappers sources: 2021.11.0
-- at: /home/cdeln/src/build/3rdparty/ippicv/ippicv_lnx/iw
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
-- Could NOT find JNI (missing: AWT)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Checking for module 'gtk+-3.0'
-- No package 'gtk+-3.0' found
-- Checking for module 'libavresample'
-- No package 'libavresample' found
-- Checking for module 'gstreamer-base-1.0'
-- No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-app-1.0'
-- No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
-- No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
-- No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-video-1.0'
-- No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-audio-1.0'
-- No package 'gstreamer-audio-1.0' found
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/cdeln/src/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_winograd_f63.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
-- highgui: using builtin backend: GTK2
-- Found 'misc' Python modules from /home/cdeln/src/opencv/modules/python/package/extra_modules
-- Found 'mat_wrapper;utils' Python modules from /home/cdeln/src/opencv/modules/core/misc/python/package
-- Found 'gapi' Python modules from /home/cdeln/src/opencv/modules/gapi/misc/python/package
--
-- General configuration for OpenCV 4.10.0-dev =====================================
-- Version control: 4.10.0-117-gc6ace77e21
--
-- Platform:
-- Timestamp: 2024-07-12T12:07:11Z
-- Host: Linux 6.5.0-41-generic x86_64
-- CMake: 3.26.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/gmake
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3
-- requested: SSE3
-- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_1 (18 files): + SSSE3 SSE4_1
-- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (38 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: /usr/bin/c++ (ver 11.4.0)
-- C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
-- Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
-- ccache: YES
-- Precompiled headers: NO
-- Extra dependencies: dl m pthread rt
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: java python2 python3
-- Applications: tests perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI: GTK2
-- GTK+: YES (ver 2.24.33)
-- GThread : YES (ver 2.72.4)
-- GtkGlExt: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.3.0)
-- JPEG 2000: build (ver 2.5.0)
-- OpenEXR: /usr/lib/x86_64-linux-gnu/libImath-2_5.so /usr/lib/x86_64-linux-gnu/libIlmImf-2_5.so /usr/lib/x86_64-linux-gnu/libIex-2_5.so /usr/lib/x86_64-linux-gnu/libHalf-2_5.so /usr/lib/x86_64-linux-gnu/libIlmThread-2_5.so (ver 2_5)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: YES (2.2.6)
-- FFMPEG: YES
-- avcodec: YES (58.134.100)
-- avformat: YES (58.76.100)
-- avutil: YES (56.70.100)
-- swscale: YES (5.9.100)
-- avresample: NO
-- GStreamer: NO
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2021.11.0 [2021.11.0]
-- at: /home/cdeln/src/build/3rdparty/ippicv/ippicv_lnx/icv
-- Intel IPP IW: sources (2021.11.0)
-- at: /home/cdeln/src/build/3rdparty/ippicv/ippicv_lnx/iw
-- VA: NO
-- Lapack: NO
-- Eigen: YES (ver 3.4.0)
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
-- Flatbuffers: builtin/3rdparty (23.5.9)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/cdeln/src/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /home/cdeln/.pyenv/versions/default/bin/python3 (ver 3.10.6)
-- Libraries: NO
-- Limited API: NO
-- numpy: /home/cdeln/.pyenv/versions/default/lib/python3.10/site-packages/numpy/core/include (ver 1.24.3)
-- install path: -
--
-- Python (for build): /home/cdeln/src/opencv/bin/python3
--
-- Java:
-- ant: NO
-- Java: YES (ver 17.0.11)
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /home/cdeln/src/build/install
-- -----------------------------------------------------------------
--
-- Configuring done (0.8s)
-- Generating done (0.2s)
-- Build files have been written to: /home/cdeln/src/build
-- Python 3:
-- Interpreter: /home/cdeln/.pyenv/versions/default/bin/python3 (ver 3.10.6)
-- Libraries: NO
-- Limited API: NO
-- numpy: /home/cdeln/.pyenv/versions/default/lib/python3.10/site-packages/numpy/core/include (ver 1.24.3)
-- install path: -
Looks like you either did not install numpy or need using the following options:
# Example:
# -D PYTHON3_EXECUTABLE=/Workspace/miniconda3/bin/python \
# -D PYTHON3_INCLUDE=/Workspace/miniconda3/include/python3.10 \
# -D PYTHON3_LIBRARIES=/Workspace/miniconda3/lib \
You will have to run a clean configure either way by removing the build.
Hmm, some questions
- Do I have to use miniconda? (I use pyenv currently)
- Doesn't this line mean that numpy is found?
/home/cdeln/.pyenv/versions/default/lib/python3.10/site-packages/numpy/core/include (ver 1.24.3)
No, you dont have to install miniconda. CMake’s find_package has some problems in finding Python headers and libraries if it is virtual environment like pyenv or conda. So you need to manually specify them.
发件人: Carl Dehlin @.> 发送时间: Tuesday, July 16, 2024 6:19:51 PM 收件人: opencv/opencv @.> 抄送: Yuantao Feng @.>; Mention @.> 主题: Re: [opencv/opencv] ONNX broken for identity function (Issue #25763)
Hmm, some questions
- Do I have to use miniconda? (I use pyenv currently)
- Doesn't this line mean that numpy is found? /home/cdeln/.pyenv/versions/default/lib/python3.10/site-packages/numpy/core/include (ver 1.24.3)
― Reply to this email directly, view it on GitHubhttps://github.com/opencv/opencv/issues/25763#issuecomment-2230539466, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEDL63QJLIYBJECX6HUNJ3TZMTXUPAVCNFSM6AAAAABJIP6RAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZQGUZTSNBWGY. You are receiving this because you were mentioned.Message ID: @.***>
@fengyuentau Is the issue still relevant? Could you post brief status here?
@asmorkalov Built 4.x on my side, tested with the Python snippet in the issue description and below is the results:
OK PyTorch () -> ()
ERROR OpenCV () -> (1, 1)
OK PyTorch (2,) -> (2,)
ERROR OpenCV (2,) -> (2, 1)
OK PyTorch (2, 3) -> (2, 3)
OK OpenCV (2, 3) -> (2, 3)
OK PyTorch (2, 3, 5) -> (2, 3, 5)
OK OpenCV (2, 3, 5) -> (2, 3, 5)
OK PyTorch (2, 3, 5, 7) -> (2, 3, 5, 7)
OK OpenCV (2, 3, 5, 7) -> (2, 3, 5, 7)
OK PyTorch (2, 3, 5, 7, 11) -> (2, 3, 5, 7, 11)
OK OpenCV (2, 3, 5, 7, 11) -> (2, 3, 5, 7, 11)
OK PyTorch (2, 3, 5, 7, 11, 13) -> (2, 3, 5, 7, 11, 13)
OK OpenCV (2, 3, 5, 7, 11, 13) -> (2, 3, 5, 7, 11, 13)
OK PyTorch (2, 3, 5, 7, 11, 13, 17) -> (2, 3, 5, 7, 11, 13, 17)
OK OpenCV (2, 3, 5, 7, 11, 13, 17) -> (2, 3, 5, 7, 11, 13, 17)
OK PyTorch (2, 3, 5, 7, 11, 13, 17, 19) -> (2, 3, 5, 7, 11, 13, 17, 19)
OK OpenCV (2, 3, 5, 7, 11, 13, 17, 19) -> (2, 3, 5, 7, 11, 13, 17, 19)
3D problem is solved. The 2D or 1D case is by design on OpenCV 4.x.