gemini-code-assist[bot] commented on code in PR #20011:
URL: https://github.com/apache/tvm/pull/20011#discussion_r3591610542


##########
src/relax/analysis/well_formed.cc:
##########
@@ -167,7 +167,7 @@ class WellFormedChecker : public relax::ExprVisitor, public 
relax::TypeVisitor {
 
   void VisitExpr(const Expr& expr) final {
     if (!expr.as<OpNode>() && expr->ty.IsMissing()) {

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   If `expr` is an undefined `Expr` (i.e., `expr.defined()` is false), calling 
`expr.as<OpNode>()` will return `nullptr`, which makes `!expr.as<OpNode>()` 
evaluate to `true`. Consequently, the right-hand side of the `&&` operator 
(`expr->ty.IsMissing()`) will be evaluated, dereferencing the null pointer and 
causing a segmentation fault/crash. Adding a defensive check for 
`expr.defined()` prevents this crash.
   
   ```suggestion
       if (expr.defined() && !expr.as<OpNode>() && expr->ty.IsMissing()) {
   ```



##########
tests/python/relax/test_op_gradient_numeric.py:
##########
@@ -36,7 +36,6 @@ def relax_check_gradients(
     op_func: Callable,
     inputs_numpy: list[np.array],

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   `np.array` is a function, not a class/type, so using it as a type hint is 
incorrect and can cause issues with static type checkers. It should be replaced 
with `np.ndarray`.
   
   ```suggestion
       inputs_numpy: list[np.ndarray],
   ```



-- 
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]

Reply via email to