opencv/modules/core
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
..
3rdparty/SoftFloat
cmake/parallel core(parallel): plugins support 2021-02-15 17:07:36 +00:00
doc Merge branch 4.x 2023-07-05 15:51:10 +03:00
include/opencv2 Merge pull request #25796 from hanliutong:hfloat 2024-07-07 11:38:02 +03:00
misc Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
perf Merge branch '4.x' into '5.x' 2024-06-26 19:01:34 +03:00
src Added lut support for all new types in 5.x 2024-07-02 14:44:55 +03:00
test Merge pull request #25796 from hanliutong:hfloat 2024-07-07 11:38:02 +03:00
CMakeLists.txt Extended several core functions to support new types (#24962) 2024-02-11 10:42:41 +03:00