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


##########
python/tvm/relax/frontend/torch/fx_translator.py:
##########
@@ -523,13 +523,26 @@ def _interpolate(self, node: fx.Node) -> relax.Var:
         if size is None:
             shape = self.shape_of(data)
             assert isinstance(shape, relax.ShapeExpr)
+            # Determine spatial dimension indices based on layout
+            # NCHW: spatial dims are [2, 3, ...] (skip batch and channel)
+            # NHWC: spatial dims are [1, 2, ...] (skip batch, before channel)
+            if self.default_image_layout == "NHWC":
+                spatial_start = 1
+                spatial_end = len(shape) - 1
+            else:  # NCHW or other layouts
+                spatial_start = 2
+                spatial_end = len(shape)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The `else` branch currently covers "NCHW or other layouts". While NCHW is 
the default and likely the primary alternative, if only NCHW is explicitly 
supported besides NHWC, it might be clearer to make this condition `elif 
self.default_image_layout == "NCHW":` for explicitness. If other layouts are 
genuinely intended to fall into this category, a comment explaining this 
assumption would be beneficial for future maintainability.
   
   ```suggestion
               else:  # NCHW
                   spatial_start = 2
                   spatial_end = len(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