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


##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -2138,7 +2138,11 @@ def _impl_v9(cls, bb, inputs, attr, params):
             shape = relax.ShapeExpr(list(shape.data.numpy()))
 
         # Special case where requested shape are constant
-        if len(shape) == 1 and all([isinstance(x, tirx.IntImm) for x in 
shape]):
+        if (
+            isinstance(shape, relax.ShapeExpr)
+            and len(shape) == 1
+            and all([isinstance(x, tirx.IntImm) for x in shape])
+        ):

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using a list comprehension inside `all()` creates a temporary list in memory 
before evaluating. We can optimize this by using a generator expression 
instead, which allows short-circuiting and avoids unnecessary memory allocation.
   
   ```suggestion
           if (
               isinstance(shape, relax.ShapeExpr)
               and len(shape) == 1
               and all(isinstance(x, tirx.IntImm) for x in shape)
           ):
   ```



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