tlopex commented on code in PR #18491:
URL: https://github.com/apache/tvm/pull/18491#discussion_r2570555092
##########
src/relax/backend/vm/vm_shape_lower.cc:
##########
@@ -399,6 +399,23 @@ class VMShapeLowerMutator
return ffi::GetRef<Expr>(op);
}
+ // Check if all expressions are computed if not mark variables as ready
and trigger computation
+ for (const PrimExpr& expr : op->values) {
+ if (!expr->IsInstance<IntImmNode>()) {
+ auto it = slot_map_.find(expr);
+ if (it != slot_map_.end() && !it->second->value_computed) {
+ // If it's a variable, mark it as ready for computation
+ if (expr.as<tir::VarNode>()) {
+ it->second->value_computed = true;
Review Comment:
Marking arbitrary tir::VarNode instances as `value_computed = true` in
`VisitExpr_` is incorrect. In VMShapeLower, only Relax ShapeVars (from function
parameters/match_cast) or IntImm constants can be safely marked as computed,
because only these have runtime values accessible to the VM.
I think correct way is to fix this earlier in the pipeline (shape
inference/canonicalization) by symbolizing composite PrimExpr (introduce Relax
ShapeVars) or simplifying them before VMShapeLower.
--
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]