Skip to content

discrepancy of results for dpctl.tensor.sin and dpt.tensor.expm1 for f4 and f8 data types on gpu #1439

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

Closed
vtavana opened this issue Oct 13, 2023 · 1 comment
Assignees

Comments

@vtavana
Copy link
Collaborator

vtavana commented Oct 13, 2023

For the following cases the results are different for float32 and float64 on gpu.

  • sin
>>> dpt.sin(dpt.asarray(-0.,dtype='f4',device='gpu'))
usm_ndarray(0., dtype=float32)

>>> dpt.sin(dpt.asarray(-0.,dtype='f8',device='gpu'))
usm_ndarray(-0.)
  • expm1
>>> dpt.expm1(dpt.asarray(-0.,dtype='f4',device='gpu'))
usm_ndarray(-0., dtype=float32)

>>> dpt.expm1(dpt.asarray(-0.,dtype='f8',device='gpu'))
usm_ndarray(0.)
@vtavana vtavana changed the title Array API and dpctl.tensor discrepancy for special cases of a few functions discrepancy of results for dpctl.tensor.sin and dpt.tensor.expm1 for f4 and f8 data types on gpu Oct 13, 2023
@ndgrigorian ndgrigorian self-assigned this Oct 13, 2023
@ndgrigorian
Copy link
Collaborator

The cause in both cases is std::sin, which does not preserve the sign bit of -0. on GPU.

Anywhere that std::sin is used, logic will need to be added to account for signed 0.

ndgrigorian added a commit that referenced this issue Nov 26, 2023
Adjusts logic in expm1 and sin for negative 0s inputs in real and complex cases
@coveralls coveralls mentioned this issue Nov 26, 2023
6 tasks
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

No branches or pull requests

2 participants