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

PR #14158: Add kExp op to algsimp IsNonNegative #70538

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

copybara-service[bot]
Copy link

PR #14158: Add kExp op to algsimp IsNonNegative

Imported from GitHub PR openxla/xla#14158

kExp result is always non-negative (similar to kAbs).
We can add kExp to IsNonNegative() util function in algsimp

Test:

import jax.numpy as jnp                                                                                                                                                                                                                 
x = jnp.array([0.0, -0.0, jnp.inf, -jnp.inf, jnp.nan, 0.1, -0.1, 3, -3]) 

jnp.abs(x)
# Array([0. , 0. , inf, inf, nan, 0.1, 0.1, 3. , 3. ], dtype=float32)

jnp.exp(x)
# Array([ 1. , 1. , inf, 0. , nan, 1.105171, 0.9048374, 20.085537, 0.04978707], dtype=float32)

Adrian, what you think? @akuegel
Copybara import of the project:

--
401c3e90a1bac7ef4594ad5b6faee5fab4e21871 by Alexander Pivovarov [email protected]:

Add kExp op to algsimp IsNonNegative

and add IsNonNegative tests

Merging this change closes #14158

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14158 from apivovarov:exp_is_non_negative 401c3e90a1bac7ef4594ad5b6faee5fab4e21871

Imported from GitHub PR openxla/xla#14158

`kExp` result is always non-negative (similar to `kAbs`).
We can add `kExp` to `IsNonNegative()` util function in algsimp

Test:
```python
import jax.numpy as jnp
x = jnp.array([0.0, -0.0, jnp.inf, -jnp.inf, jnp.nan, 0.1, -0.1, 3, -3])

jnp.abs(x)
# Array([0. , 0. , inf, inf, nan, 0.1, 0.1, 3. , 3. ], dtype=float32)

jnp.exp(x)
# Array([ 1. , 1. , inf, 0. , nan, 1.105171, 0.9048374, 20.085537, 0.04978707], dtype=float32)
```
Adrian, what you think? @akuegel
Copybara import of the project:

--
401c3e90a1bac7ef4594ad5b6faee5fab4e21871 by Alexander Pivovarov <[email protected]>:

Add kExp op to algsimp IsNonNegative

and add IsNonNegative tests

Merging this change closes #14158

PiperOrigin-RevId: 647502602
@copybara-service copybara-service bot merged commit c2aa36e into master Jun 28, 2024
1 check passed
@copybara-service copybara-service bot deleted the exported_pr_647411876 branch June 28, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant