Skip to content

Commit 25a3813

Browse files
authored
[SYCL] Support bf16 isnan for sycl::marray<bfloat16, N> (#7990)
1 parent fee6eb7 commit 25a3813

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sycl/include/sycl/ext/oneapi/experimental/bfloat16_math.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ std::enable_if_t<std::is_same<T, bfloat16>::value, bool> isnan(T x) {
3838
return (((XBits & 0x7F80) == 0x7F80) && (XBits & 0x7F)) ? true : false;
3939
}
4040

41+
template <size_t N> sycl::marray<bool, N> isnan(sycl::marray<bfloat16, N> x) {
42+
sycl::marray<bool, N> res;
43+
for (size_t i = 0; i < N; i++) {
44+
res[i] = isnan(x[i]);
45+
}
46+
return res;
47+
}
48+
4149
template <typename T>
4250
std::enable_if_t<std::is_same<T, bfloat16>::value, T> fabs(T x) {
4351
#if defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__)

0 commit comments

Comments
 (0)