onnxruntime
9f81e2df - Fix PRelu returning NaN for infinite inputs on CPU EP (#28750)

Commit
36 days ago
Fix PRelu returning NaN for infinite inputs on CPU EP (#28750) `PRelu` on the CPU EP returns `NaN` for `±inf` inputs. The two-tensor broadcast functors compute the activation as `mask*x + (1-mask)*x*slope` with `mask = (x > 0)`, which evaluates to `0 * inf = NaN` on either branch when `x` is infinite. ### Description - Replace the arithmetic mask in `PRelu<float>::Compute` with a direct branch in both the input1-scalar and two-tensor functors: ```cpp output[i] = input0[i] > 0 ? input0[i] : input0[i] * input1[/*scalar or [i]*/]; ``` - Add `ActivationOpTest.PRelu_Infinity` mirroring the issue repro (`[+inf, -inf, 5e30, -2.5]` with slope `[0.25, 0.5, 0.25, 0.25]`). ### Motivation and Context For `PRelu`, positive `x` should pass through unchanged and negative `x` should be multiplied by `slope`, so `+inf` must stay `+inf` and `-inf` with positive slope must stay `-inf`. The branch-free formulation silently breaks these cases by introducing `0 * inf`. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Author
Parents
Loading