Solve error: ambiguous overload for ‘operator!=’ (operand types are ‘__half’ and ‘double’)#23948
Solve error: ambiguous overload for ‘operator!=’ (operand types are ‘__half’ and ‘double’)#23948jiapei100 wants to merge 2 commits intoopencv:4.xfrom
Conversation
… types are ‘__half’ and ‘double’)
|
@mshabunin could you take a look? |
|
@jiapei100 , our CI CUDA builds have failed: https://github.com/opencv/opencv/actions/runs/5489317969/jobs/10008696594?pr=23948 |
|
@mshabunin
????? BTW, are you building everything on your own OpenCV CI ?? Everything automatically?? |
…‘__half’ and ‘double’)
| * or we don't have to scale | ||
| */ | ||
| if (weight != (T)(1.0)) | ||
| if (weight != static_cast(T)(1.0)) |
There was a problem hiding this comment.
Wrong static_cast syntax, please refer to cppreference for more information about how it works.
static_cast<T>(1.0)|
Perhaps original issue is no caused by missing type case, but by ambiguous constant type. Try to change to |
The static cast fixes the issue with CUDA 12.2 but due to the ambiguous constant type you mentioned causes an issue with earlier versions of CUDA. The combination of both, i.e. or double works on Windows with Visual Studio 2022 for CUDA 12.1 (old math api) and CUDA 12.2. |
If I am not mistaken, ISO C++ is clear about default primitive types of constant literals. |
I think the use of the word ambiguous has itself become ambiguous! I may be wrong but my interpretation of the build error Ubuntu2004-x64-CUDA / BuildAndTest output
is that there is no conversion from |
@jiapei100 The CI uses an older version of CUDA, can you apply the changes suggested by @mshabunin in addition to your changes, e.g. to this PR to see if it compiles successfully so we can update OpenCV to be compatilble with CUDA 12.2 please. |
|
For what it's worth, when I tried manually applying the suggested changes to my copy of the source on my Ubuntu 22.04 box with Cuda 12.2, it did resolve the errors being generated by those lines, however I ran into other issues later in compilation with different files (looks like the python bindings). Different issue, so not including the details unless requested... |
|
@jiapei100 Kindly asking you to fix this PR so that OpenCV can support the latest version of CUDA. |
|
@VadimLevin, @mshabunin is it possilble for the maintainers to apply the fixes discussed here (also shown here on my forked branch) to see if this fixes the issue and passes all the relavent CI tests. CUDA 12.2 was released over a month ago with update 1 released yesterday and @jiapei100 seems to have gone awol. It seems a shame to let this fix go stale when 🤞 it should be such a simple fix. |
**Remove the error: error: ambiguous overload for ‘operator!=’ (operand types are ‘__half’ and ‘double’) **
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.