-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename remaining float16_t for future proof #25387
Rename remaining float16_t for future proof #25387
Conversation
#if !defined(OPENCV_HIDE_FLOAT16_T) | ||
typedef hfloat float16_t; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add c++ version check with __cplusplus
macro. See https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In original comment there is complete guard condition to avoid using of float16_t
in OpenCV code.
__cplusplus
That could be added to C too. No need to make conditions near C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maksim's solution #25210 (comment):
#if !(defined __STDCPP_FLOAT16_T__) && !(defined __ARM_NEON)
typedef our_pod_fp16_struct float16_t;
#endif
also looks good. Macro __STDCPP_FLOAT16_T__
stands for the existing of std::float16_t
in C++23.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want to see __OPENCV_BUILD
condition here to avoid usage in OpenCV completely (to avoid mistakes like recent issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want to see
__OPENCV_BUILD
condition here to avoid usage in OpenCV completely (to avoid mistakes like recent issue).
Added.
const float16_t* a = (const float16_t*)_a; | ||
const float16_t* b = (const float16_t*)_b; | ||
float16_t* c = (float16_t*)_c; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still need this float16_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because vdupq_n_f16
at line 505 is an macro defined in Clang arm_neon.h
(details in #25210 (comment)). In this macro, float16_t
is used, so this typedef has to be saved to make vdupq_n_f16
works unless we undo typedef hfloat float16_t
in this file.
Note that vdupq_n_f16
in GCC arm_neon.h
is an function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maksim's solution may also work, which is to drop typedef hfloat float16_t
for ARM platform: #25210 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They all are dropped now.
#if !defined(OPENCV_HIDE_FLOAT16_T) | ||
typedef hfloat float16_t; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In original comment there is complete guard condition to avoid using of float16_t
in OpenCV code.
__cplusplus
That could be added to C too. No need to make conditions near C++.
eb4a8f1
to
567bcff
Compare
* rename remaining internal float16_t to hfloat;
4268ca2
to
e20c569
Compare
…enaming Rename remaining float16_t for future proof opencv#25387 Resolves comment: opencv#25217 (comment). `std::float16_t` and `std::bfloat16_t` are introduced since c++23: https://en.cppreference.com/w/cpp/types/floating-point. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Resolves comment: #25217 (comment).
std::float16_t
andstd::bfloat16_t
are introduced since c++23: https://en.cppreference.com/w/cpp/types/floating-point.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.