openxla / xla

A machine learning compiler for GPUs, CPUs, and ML accelerators
Apache License 2.0
2.39k stars 356 forks source link

PR #14166: Add kPower case to algsimp IsNonNegative #14269

Open copybara-service[bot] opened 3 days ago

copybara-service[bot] commented 3 days ago

PR #14166: Add kPower case to algsimp IsNonNegative

Imported from GitHub PR https://github.com/openxla/xla/pull/14166

if kPower op lhs (The bases) IsNonNegative the result is also non-negative

Test

import jax.numpy as jnp

x = jnp.array([0.0, -0.0, jnp.inf, -jnp.inf, 0.1, -0.1, 1.0, -1.0, 3, -3])
bases = [0.0, 0.1, 1.0, 1.1, 3, jnp.inf]

for base in bases:
  print("base:", base, ", isAllResultsNonNegative:", jnp.all(jnp.pow(base, x) >= 0.0))

base: 0.0 , isAllResultsNonNegative: True
base: 0.1 , isAllResultsNonNegative: True
base: 1.0 , isAllResultsNonNegative: True
base: 1.1 , isAllResultsNonNegative: True
base: 3 , isAllResultsNonNegative: True
base: inf , isAllResultsNonNegative: True

Copybara import of the project:

-- b0590cd88d0118f98fc66e01849740bbf4274216 by Alexander Pivovarov pivovaa@amazon.com:

Add kPower case to algsimp IsNonNegative

Merging this change closes #14166

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/14166 from apivovarov:pow_in_non_negative b0590cd88d0118f98fc66e01849740bbf4274216