Copilot commented on code in PR #18170:
URL: https://github.com/apache/tvm/pull/18170#discussion_r2245127133
##########
src/relax/transform/fuse_ops.cc:
##########
@@ -427,9 +427,7 @@ class FunctionCreator : public ExprMutator {
}
for (const Expr& arg : call->args) {
- if (GetStructInfoAs<TupleStructInfoNode>(arg) != nullptr) {
- // The argument is fully referenced. Thus we remove it from the
mapping.
- partially_used_tuple_params_.erase(arg.get());
+ if (arg.as<TupleNode>()) {
const Tuple& tup_args = Downcast<Tuple>(arg);
for (const Expr& tup_arg : tup_args->fields) {
Review Comment:
The condition `arg.as<TupleNode>()` only checks if the argument is a
TupleNode, but the subsequent code unconditionally downcasts to Tuple. This
could cause a runtime error if the argument has TupleStructInfo but is not
actually a TupleNode. Consider using `if (auto tuple = arg.as<TupleNode>())`
and use the tuple variable directly.
```suggestion
if (auto tuple = arg.as<TupleNode>()) {
for (const Expr& tup_arg : tuple->fields) {
```
--
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]