masahi commented on code in PR #13710:
URL: https://github.com/apache/tvm/pull/13710#discussion_r1063891653
##########
src/tir/ir/data_type_rewriter.cc:
##########
@@ -107,6 +107,26 @@ Stmt DataTypeLegalizer::VisitStmt_(const AttrStmtNode* op)
{
return StmtExprMutator::VisitStmt_(op);
}
+Stmt DataTypeLegalizer::VisitStmt_(const LetStmtNode* op) {
+ PrimExpr value = this->VisitExpr(op->value);
+ Stmt body = this->VisitStmt(op->body);
+ if (value.same_as(op->value) && body.same_as(op->body)) {
+ return GetRef<Stmt>(op);
+ } else if (value.dtype() == op->var->dtype) {
+ auto n = CopyOnWrite(op);
+ n->value = std::move(value);
+ n->body = std::move(body);
+ return Stmt(n);
+ } else {
+ auto new_var = op->var.copy_with_dtype(value.dtype());
+ Map<Var, PrimExpr> vmap{{op->var, new_var}};
+ auto new_body = SubstituteWithDataTypeLegalization(
+ std::move(body), [&](const Var& var) { return vmap.Get(var); });
+ // We need to visit the body again to insert additional casts
Review Comment:
done
--
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]