gemini-code-assist[bot] commented on code in PR #19937:
URL: https://github.com/apache/tvm/pull/19937#discussion_r3522945405
##########
python/tvm/relax/frontend/torch/base_fx_graph_translator.py:
##########
@@ -2619,6 +2619,16 @@ def _masked_select(self, node: fx.Node) -> relax.Var:
data_flat = self.block_builder.emit(relax.op.reshape(data, [-1]))
mask_flat = self.block_builder.emit(relax.op.reshape(mask, [-1]))
indices = self.block_builder.emit(relax.op.nonzero(mask_flat))
+ tensor_meta = node.meta.get("tensor_meta")
+ if tensor_meta is not None and len(tensor_meta.shape) == 1:
+ num_selected = tensor_meta.shape[0]
+ if not isinstance(num_selected, int):
+ num_selected = tirx.Var(str(num_selected), "int64")
+ else:
+ num_selected = tirx.Var(f"{node.name}_num_selected", "int64")
+ indices = self.block_builder.match_cast(
+ indices, relax.TensorType([1, num_selected], "int64")
+ )
Review Comment:

In TVM Relax, `match_cast` expects a `StructInfo` (such as
`TensorStructInfo`) rather than a `Type` (such as `TensorType`). Additionally,
`relax.TensorType`'s constructor takes `ndim` and `dtype` rather than a shape
list, so passing `[1, num_selected]` as the first argument is incorrect. Please
use `relax.TensorStructInfo` instead.
```suggestion
indices = self.block_builder.match_cast(
indices, relax.TensorStructInfo([1, num_selected], "int64")
)
```
--
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]