opencv/modules
HAN Liutong 1d9ca7160b
Merge pull request #25796 from hanliutong:hfloat
Use hfloat instead of __fp16. #25796

Related: #25743

Currently, the type for the half-precision floating point data in the OpenCV source code is `__fp16`, which is a unique(?) type supported by the ARM compiler. Other compilers have very limited support for `__fp16`, so in order to introduce more backends that support FP16 (such as RISC-V), we may need a the more general FP16 type.

In this patch, we use `hfloat` instead of `__fp16` in non-ARM code blocks, mainly affected parts are:
- `core/hal/intrin.hpp`: Type Traits, REG Traits and `vx_` interface.
- `core/hal/intrin_neon.hpp`: Universal Intrinsic API for FP16 type.
- `core/test/test_intrin_utils.hpp`: Usage of Univseral Intrinsic
- `core/include/opencv2/core/cvdef.h`: Definition of class `hfloat`

If I understand correctly, class `hfloat` acts as a wrapper around FP16 types in different platform (`__fp16` for ARM and `_Float16` for RISC-V). Any OpenCV generic interface/source code should use `hfloat`, while platform-specific FP16 types only used in macro-guarded code blocks.

/cc @fengyuentau  @mshabunin 

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] 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
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-07-07 11:38:02 +03:00
..
3d Fixed 23-bit build with some GCC versions. 2024-07-03 14:13:34 +03:00
calib Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
core Merge pull request #25796 from hanliutong:hfloat 2024-07-07 11:38:02 +03:00
dnn Merge branch 4.x 2024-07-01 15:59:43 +03:00
features2d Merge branch 4.x 2024-04-22 11:08:39 +03:00
flann Prevent signed integer overflow in LshTable 2024-05-24 23:47:36 +02:00
gapi Merge branch 4.x 2024-07-01 15:59:43 +03:00
highgui Merge branch 4.x 2024-07-01 15:59:43 +03:00
imgcodecs Merge branch 4.x 2024-07-01 15:59:43 +03:00
imgproc Merge branch 4.x 2024-07-01 15:59:43 +03:00
java Merge branch 4.x 2024-04-02 16:39:54 +03:00
js Fixed failed JavaScript tests in 5.x 2024-07-03 16:15:36 +03:00
objc Merge branch 4.x 2024-01-19 17:32:22 +03:00
objdetect Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
photo Merge branch 4.x 2024-04-22 11:08:39 +03:00
python Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
stereo Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
stitching Merge pull request #25075 from mshabunin:cleanup-imgproc-1 2024-03-05 12:18:31 +03:00
ts Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
video Merge branch 4.x 2024-07-01 15:59:43 +03:00
videoio Merge branch 4.x 2024-07-01 15:59:43 +03:00
world cmake: use /INCREMENTAL:NO with MSVS 2015 2023-12-07 19:46:27 +00:00
CMakeLists.txt Merge pull request #25017 from kaingwade:ml_to_contrib 2024-02-27 15:54:08 +03:00