Repository: opencv
Issue: opencv4.9.0  Huawei CANN support error: CANN check failed in function 'forward'
Labels: bug,category: dnn

### System Information

![image](https://github.com/user-attachments/assets/fdc4864f-8aa0-4843-a211-93f47305a1c3)


### Detailed description

编译cann版本opencv4.9.0后，在推理yolov8代码时经常会出现以下错误(有时又不会出现)：
[ INFO:0@51.135] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Add_1@NaryEltwise@361 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Add_2@NaryEltwise@362 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer /model.22/Constant_11_output_0@Const@363 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Div_1@NaryEltwise@364 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Sub_1@NaryEltwise@365 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Concat_4@Concat@366 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer /model.22/Constant_12_output_0@Const@367 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Mul_2@NaryEltwise@368 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Sigmoid@Sigmoid@369 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer onnx_node!/model.22/Concat_5@Concat@370 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:204 initBackend DNN/CANN: converting layer output0@Identity@371 to CANN operator
[ INFO:0@51.136] global net_cann.cpp:225 initBackend DNN/CANN: done converting layers to CANN operators
[ INFO:0@51.136] global net_cann.cpp:228 initBackend DNN/CANN: building ge::Graph
[ INFO:0@51.139] global net_cann.cpp:233 initBackend DNN/CANN: done building ge::Graph
[ INFO:0@51.139] global net_cann.cpp:236 initBackend DNN/CANN: converting ge::Graph to OM buffer
[ERROR:0@51.215] global net_cann.cpp:311 compileCannGraph CANN graph check failed, ret = 4294967295
OpenCV(4.9.0) Error: Unspecified error (CANN graph check failed) in compileCannGraph, file /root/data/opencv-4.9.0/modules/dnn/src/net_cann.cpp, line 311
compileCannGraph OpenCV(4.9.0) /root/data/opencv-4.9.0/modules/dnn/src/net_cann.cpp:311: error: (-2:Unspecified error) CANN graph check failed in function 'compileCannGraph'

Model infer Failed!
--- >> img path: /ubuntu_test/zz_bj_meter_read_value/images/108_20240514_result_result_result.jpg
[ERROR:0@51.556] global op_cann.cpp:211 forward CANN check failed, ret = 507899
OpenCV(4.9.0) Error: Unspecified error (CANN check failed) in forward, file /root/data/opencv-4.9.0/modules/dnn/src/op_cann.cpp, line 211
forward OpenCV(4.9.0) /root/data/opencv-4.9.0/modules/dnn/src/op_cann.cpp:211: error: (-2:Unspecified error) CANN check failed in function 'forward'

### Steps to reproduce

编译命令：
cmake  -D BUILD_opencv_world=ON -D CMAKE_BUILD_TYPE=Debug -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/root/data/opencv-4.9.0/install -D OPENCV_EXTRA_MODULES_PATH=/root/data/opencv-4.9.0/opencv_contrib-4.9.0/modules -D BUILD_opencv_wechat_qrcode=ON -D WITH_CANN=ON -D BUILD_DOCS=ON -D BUILD_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D WITH_GSTREAMER=OFF -D OPENCV_ENABLE_NONFREE=ON -D BUILD_opencv_python3=OFF -D WITH_LAPACK=ON -D WITH_EIGEN=ON -D WITH_OPENGL=ON -D WITH_FFMPEG=ON -D WITH_FREETYPE=ON -D BUILD_opencv_freetype=ON -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF -D BUILD_opencv_gapi=OFF ..

### 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)