Skip to content

Commit 9160f49

Browse files
authored
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.
1 parent 51bf0df commit 9160f49

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

libclc/generic/lib/math/erf.cl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,16 @@ _CLC_OVERLOAD _CLC_DEF double erf(double y) {
399399

400400
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erf, double);
401401

402+
#ifdef cl_khr_fp16
403+
404+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
405+
406+
_CLC_OVERLOAD _CLC_DEF half erf(half h) {
407+
return (half)erf((float)h);
408+
}
409+
410+
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erf, half);
411+
412+
#endif
413+
402414
#endif

libclc/generic/lib/math/erfc.cl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,16 @@ _CLC_OVERLOAD _CLC_DEF double erfc(double x) {
410410

411411
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erfc, double);
412412

413+
#ifdef cl_khr_fp16
414+
415+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
416+
417+
_CLC_OVERLOAD _CLC_DEF half erfc(half h) {
418+
return (half)erfc((float)h);
419+
}
420+
421+
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erfc, half);
422+
423+
#endif
424+
413425
#endif

0 commit comments

Comments
 (0)