Skip to content

[SYCL][Doc] Add isnan to bfloat16 math doc #7958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 30, 2023

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Jan 9, 2023

Signed-off-by: jinge90 [email protected]

@jinge90 jinge90 requested a review from a team as a code owner January 9, 2023 07:15
@jinge90 jinge90 marked this pull request as draft January 9, 2023 07:15
@jinge90 jinge90 requested review from JackAKirk and gmlueck January 9, 2023 07:15
@jinge90
Copy link
Contributor Author

jinge90 commented Jan 9, 2023

Hi, @gmlueck and @JackAKirk
I added "isnan" for bfloat16 in https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/experimental/bfloat16_math.hpp#L36
This PR adds it in bfloat16 math doc. However, I didn't add "isnan" for sycl::marray<sycl::ext::oneapi::bfloat16, N> and wanted to consult you what the prototype should look like?
For bfloat16, isnan prototype is:
bool isnan(sycl::ext::oneapi::bfloat16);
For sycl::marray<sycl::ext::oneapi::bfloat16, N>, I expect the prototype to look like:
sycl::marray<bool, N> isnan(sycl::marray<sycl::ext::oneapi::bfloat16, N>);
Each bool value in return value corresponds each bf16 value in input param.

In CUDA math, NV has "hisnan2": https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____BFLOAT162__COMPARISON.html#group__CUDA__MATH____BFLOAT162__COMPARISON_1gf613f74f4c0220e6d85b91b086e2788a
hisnan2 return turn value is a __nv_bfloat162 with the corresponding nv_bfloat16 results set to 1.0 for NaN, 0.0 otherwise.

So, what's your idea? Do we need to align with NV math? If so, the return type should be sycl::marray<sycl::ext::oneapi::bfloat16, N>.

Thanks very much.

@JackAKirk
Copy link
Contributor

JackAKirk commented Jan 9, 2023

I expect the prototype to look like: sycl::marray<bool, N> isnan(sycl::marray<sycl::ext::oneapi::bfloat16, N>); Each bool value in return value corresponds each bf16 value in input param.

In CUDA math, NV has "hisnan2": https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____BFLOAT162__COMPARISON.html#group__CUDA__MATH____BFLOAT162__COMPARISON_1gf613f74f4c0220e6d85b91b086e2788a hisnan2 return turn value is a __nv_bfloat162 with the corresponding nv_bfloat16 results set to 1.0 for NaN, 0.0 otherwise.

So, what's your idea? Do we need to align with NV math? If so, the return type should be sycl::marray<sycl::ext::oneapi::bfloat16, N>.

Thanks very much.

Hmm well spotted. My guess is they have only done this because they don't have a corresponding __nv_bool2 to __nv_bfloat162. My instinct is to agree with you that in the SYCL case it should return sycl::marray<bool, N>.

@gmlueck
Copy link
Contributor

gmlueck commented Jan 9, 2023

My instinct is to agree with you that in the SYCL case it should return sycl::marray<bool, N>.

Yes, I agree too.

@jinge90 jinge90 marked this pull request as ready for review January 12, 2023 07:18
@JackAKirk
Copy link
Contributor

LGTM

@JackAKirk JackAKirk self-requested a review January 12, 2023 14:24
@jinge90
Copy link
Contributor Author

jinge90 commented Jan 14, 2023

Hi, @intel/dpcpp-specification-reviewers and @gmlueck
Kind ping~
Thanks very much.

@jinge90
Copy link
Contributor Author

jinge90 commented Jan 30, 2023

Hi, @gmlueck
Is there anything else in this PR which needs update?

Thanks very much.

@gmlueck
Copy link
Contributor

gmlueck commented Jan 30, 2023

Is there anything else in this PR which needs update?

No, LGTM!

@bader bader merged commit 23bf9c1 into intel:sycl Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants