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

Add CHLO square operation. #2625

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Add CHLO square operation. #2625

merged 1 commit into from
Nov 18, 2024

Conversation

pearu
Copy link
Contributor

@pearu pearu commented Nov 13, 2024

As in the title.

Providing square as a CHLO operation enables fixing inaccuracy problems in jax.numpy.square for complex inputs with large real and imaginary parts.

This PR replaces #2623 and enables eliminating square lowering introduced in jax-ml/jax#24874

The details of square inaccuracies is given in pearu/functional_algorithms#52 . Roughly speaking, the source of inaccuracies in square(z).real is the usage of z.real ** 2 - z.imag ** 2 that terms will overflow when abs(z.real/imag) > sqrt(largest). The overflow does not happen when using (z.real - z.imag) * (z.real + imag) formula instead.

As a side-effect to using the 0.11.1 version of function_algorithms, several mlir test scripts for asin/asinh/acos/... functions are updated as well.

@pearu pearu marked this pull request as ready for review November 13, 2024 16:13
Copy link
Member

@GleasonK GleasonK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Update acos/asin/... tests.
@GleasonK GleasonK merged commit 1382949 into openxla:main Nov 18, 2024
10 checks passed
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.

2 participants