tlopex commented on code in PR #17707:
URL: https://github.com/apache/tvm/pull/17707#discussion_r1982656400


##########
python/tvm/relax/frontend/torch/base_fx_graph_translator.py:
##########
@@ -921,6 +936,16 @@ def _stack(self, node: fx.Node) -> relax.Var:
                 s_shape.append(s)
         return self.block_builder.emit(relax.op.reshape(cat, s_shape))
 
+    def _take(self, node: fx.Node, axis: Optional[int] = None) -> relax.Var:
+        x = self.env[node.args[0]]
+        indices = self.env[node.args[1]]
+        indices = self.block_builder.emit(relax.op.astype(indices, "int32"))
+        if axis is not None:
+            raise NotImplementedError(
+                "Relax's relax.op.take() does not fully support PyTorch's 
torch.take()."

Review Comment:
   Relax's take() requires an explicit axis and does not flatten automatically, 
but PyTorch's take() flattens the input before indexing. If axis is not None, 
users might expect PyTorch's flattening behavior, but Relax only indexes along 
the specified axis, which can lead to incorrect results I think.



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

Reply via email to