libclc: generic: add half implementation for erf/erfc (#66901)

libclc does not have a half implementation for erf/erfc
Add one based on the float implementation by extending the input and
truncating the output.
This commit is contained in:
Romaric Jodin 2024-01-09 17:47:53 +01:00 committed by GitHub
parent 51bf0dff53
commit 9160f49e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -399,4 +399,16 @@ _CLC_OVERLOAD _CLC_DEF double erf(double y) {
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erf, double);
#ifdef cl_khr_fp16
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
_CLC_OVERLOAD _CLC_DEF half erf(half h) {
return (half)erf((float)h);
}
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erf, half);
#endif
#endif

View File

@ -410,4 +410,16 @@ _CLC_OVERLOAD _CLC_DEF double erfc(double x) {
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erfc, double);
#ifdef cl_khr_fp16
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
_CLC_OVERLOAD _CLC_DEF half erfc(half h) {
return (half)erfc((float)h);
}
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erfc, half);
#endif
#endif