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


##########
python/tvm/topi/image/resize.py:
##########
@@ -856,6 +881,8 @@ def compute_func(*indices):
             exclude_outside=bicubic_exclude,
             extrapolation_value=extrapolation_value,
             out_dtype=out_dtype,
+            scale_h = scale_h,
+            scale_w = scale_w,

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   According to PEP 8, there should be no spaces around the `=` sign when used 
to indicate a keyword argument.
   
   ```python
               scale_h=scale_h,\n            scale_w=scale_w,
   ```



##########
python/tvm/topi/image/resize.py:
##########
@@ -145,9 +145,13 @@ def get_inx(
     start_x=0,
     end_x=-1,
     use_int_div=False,
+    scale_x_override=None,
 ):
     """Infer input x from output x with various coordinate transformation 
methods"""
-    scale_x = te.div(image_width.astype("float"), target_width.astype("float"))
+    if scale_x_override is not None:
+        scale_x = sacle_x_override

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   There is a typo in the variable name here. `sacle_x_override` should be 
`scale_x_override`. This will cause a `NameError` at runtime when 
`scale_x_override` is provided.
   
   ```suggestion
           scale_x = scale_x_override
   ```



##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -3230,14 +3230,18 @@ def _impl_v18(cls, bb, inputs, attr, params):
 
         use_dynamic_roi = roi_dynamic_vec is not None
 
-        # Convert scales to sizes if needed.
+        # Convert scales to sizes if needed, preserving the orginal spatial 
scales so
+        # the coordinate transformation uses the exact ONNX scale value rather 
than the
+        # lossy ratio derived from floor(input * scale) / input.
+        original_spatial_scales = None
         if scales is not None:
             if isinstance(scales, relax.Constant):
                 scales = scales.data.numpy()
             elif isinstance(scales, relax.expr.ShapeExpr):
                 scales = [int(val.value) for val in scales.values]
             else:
                 raise ValueError(f"Type {type(scales)} for scale is currently 
unsupported.")
+            original_spatial_scales = list(scales[2:])

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The variable `original_spatial_scales` is defined and populated here but is 
never used or passed to any of the resize operators (`topi.image.resize1d`, 
`relax.op.image.resize2d`, or `relax.op.image.resize3d`).\n\n- For `ndims == 
3`, you should pass `scales=original_spatial_scales` to 
`bb.emit_te(topi.image.resize1d, ...)`.\n- For `ndims == 4` and `ndims == 5`, 
the Relax operators `relax.op.image.resize2d` and `relax.op.image.resize3d` do 
not accept a `scales` parameter. If `scales` is provided, you may need to 
fallback to emitting the TE operations directly via 
`bb.emit_te(topi.image.resize2d, ...)` and `bb.emit_te(topi.image.resize3d, 
...)` to ensure the scales are propagated, or update the Relax operators to 
support scales.



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