DivideNoNanΒΆ

Computes a safe divide which returns 0 if y (denominator) is zero.

Abstract Signature:

DivideNoNan(x: Tensor, y: Tensor)

PyTorch

API: β€”
Strategy: Macro 'torch.where({y} == 0, torch.zeros_like({x}), {x} / {y})'

JAX (Core)

API: β€”
Strategy: Macro 'jnp.where({y} == 0, 0, {x} / {y})'

Keras

API: β€”
Strategy: Macro 'keras.ops.where({y} == 0, 0, {x} / {y})'

TensorFlow

API: tf.math.divide_no_nan
Strategy: Direct Mapping

Apple MLX

API: β€”
Strategy: Macro 'mx.where({y} == 0, 0, {x} / {y})'

Flax NNX

API: β€”
Strategy: Macro 'jnp.where({y} == 0, 0, {x} / {y})'

PaxML / Praxis

API: β€”
Strategy: Macro 'jnp.where({y} == 0, 0, {x} / {y})'