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


##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -4927,12 +4927,12 @@ def _impl_v10(cls, bb, inputs, attr, params):
             max_output_boxes_per_class = 0  # Default value
 
         if iou_threshold is not None and isinstance(iou_threshold, 
relax.Constant):
-            iou_threshold = float(iou_threshold.data.numpy())
+            iou_threshold = float(iou_threshold.data.numpy().item())
         else:
             iou_threshold = 0.5  # Default value

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The `iou_threshold` parameter is missing a `relax.Var` handling path, unlike 
`max_output_boxes_per_class` and `score_threshold`. If `iou_threshold` is 
provided as a `relax.Var` (for example, when `keep_params_in_input=True`), it 
will be silently ignored and overridden to the default value of `0.5`. We 
should add the `relax.Var` path to resolve it from `params` to ensure 
correctness and consistency.
   
   ```python
           if iou_threshold is not None and isinstance(iou_threshold, 
relax.Constant):
               iou_threshold = float(iou_threshold.data.numpy().item())
           elif iou_threshold is not None and isinstance(iou_threshold, 
relax.Var):
               var_name = iou_threshold.name_hint
               if var_name in params[1]:
                   _, param_value = params[1][var_name]
                   iou_threshold = float(param_value.numpy().item())
               else:
                   iou_threshold = 0.5  # Default value
           else:
               iou_threshold = 0.5  # Default value
   ```



##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -5016,12 +5016,12 @@ def _impl_v1(cls, bb, inputs, attr, params):
             max_output_boxes_per_class = 0  # Default value
 
         if iou_threshold is not None and isinstance(iou_threshold, 
relax.Constant):
-            iou_threshold = float(iou_threshold.data.numpy())
+            iou_threshold = float(iou_threshold.data.numpy().item())
         else:
             iou_threshold = 0.5  # Default value

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Similarly, in `AllClassNMS._impl_v1`, the `iou_threshold` parameter is 
missing a `relax.Var` handling path. We should add the `relax.Var` path here as 
well to resolve it from `params` for correctness and consistency.
   
   ```python
           if iou_threshold is not None and isinstance(iou_threshold, 
relax.Constant):
               iou_threshold = float(iou_threshold.data.numpy().item())
           elif iou_threshold is not None and isinstance(iou_threshold, 
relax.Var):
               var_name = iou_threshold.name_hint
               if var_name in params[1]:
                   _, param_value = params[1][var_name]
                   iou_threshold = float(param_value.numpy().item())
               else:
                   iou_threshold = 0.5  # Default value
           else:
               iou_threshold = 0.5  # Default value
   ```



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