gemini-code-assist[bot] commented on code in PR #18631:
URL: https://github.com/apache/tvm/pull/18631#discussion_r2657711678
##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -3254,7 +3254,11 @@ def _impl_v1(cls, bb, inputs, attr, params):
alpha = relax.const(alpha, dtype=dtype)
beta = float(attr.get("beta", 0.5))
beta = relax.const(beta, dtype=dtype)
- return relax.op.clip(relax.op.add(relax.op.multiply(alpha, x), beta),
0, 1)
+ clipped = relax.op.clip(relax.op.add(relax.op.multiply(alpha, x),
beta), 0, 1)
+ # Preserve NaN values: where x is NaN, return NaN instead of clipped
value
+ is_nan = relax.op.isnan(x)
+ nan_val = relax.op.divide(relax.const(0.0, dtype=dtype),
relax.const(0.0, dtype=dtype))
Review Comment:

For creating a NaN scalar constant, it's more direct and readable to use
`relax.const(float('nan'), dtype=dtype)` instead of dividing zero by zero. This
also avoids creating intermediate `Constant` and `divide` operator nodes in the
graph, making the graph construction slightly more efficient.
```suggestion
nan_val = relax.const(float("nan"), dtype=dtype)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]