Skip to content
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

Fix complex sin and cos on inputs with small absolute value or large pure imaginary part #19823

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

pearu
Copy link
Collaborator

@pearu pearu commented Feb 15, 2024

As in the title.

In addition, a test testUfuncOnComplexPlane is introduced that validates jax implementations of complex ufuncs on the whole complex plane using numpy ufuncs as references.

Fixes #19753, #19754

In terms of the Validate complex functions in array libraries tool, the validity state of the sin function on complex plane is
before and after this PR.

Discussion: ideally, issues with sin/cos ought to be fixed upstream (https://github.com/openxla/stablehlo). This PR implements lowerings for complex sin and cos functions because it is the fastest way to enable the fix for the end-users.

@pearu pearu force-pushed the pearu/sin branch 5 times, most recently from aabca27 to 82adfb4 Compare February 15, 2024 12:39
@hawkinsp
Copy link
Member

@pearu It's definitely worth also fixing this upstream, although as you note that can be done in another PR (and then we can remove the custom lowering in JAX).

jax/_src/lax/lax.py Outdated Show resolved Hide resolved
tests/lax_numpy_test.py Outdated Show resolved Hide resolved
tests/lax_numpy_test.py Outdated Show resolved Hide resolved
@pearu pearu force-pushed the pearu/sin branch 2 times, most recently from c97526b to 3298dcb Compare February 20, 2024 14:34
@pearu pearu requested a review from jakevdp February 20, 2024 14:42
tests/lax_numpy_test.py Outdated Show resolved Hide resolved
@pearu pearu force-pushed the pearu/sin branch 6 times, most recently from a8571b3 to 3a75d41 Compare February 21, 2024 15:24
@pearu pearu requested a review from jakevdp February 21, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sin results are incorrect on complex inputs with small absolute value
4 participants