vinx13 commented on code in PR #12370:
URL: https://github.com/apache/tvm/pull/12370#discussion_r948370738


##########
src/tir/transforms/bf16_legalize.cc:
##########
@@ -88,6 +89,26 @@ DEFINE_BIOP_EXPR_MUTATE_WITH_TYPE_MATCH(LENode, operator<=, 
false)
 DEFINE_BIOP_EXPR_MUTATE_WITH_TYPE_MATCH(GTNode, operator>, false)
 DEFINE_BIOP_EXPR_MUTATE_WITH_TYPE_MATCH(GENode, operator>=, false)
 
+PrimExpr BF16PromoteRewriter::VisitExpr_(const CallNode* op) {
+  Array<PrimExpr> args;
+  for (auto& arg : op->args) {
+    PrimExpr x = this->VisitExpr(arg);
+    if (x.dtype().is_bfloat16()) {
+      DataType fp32_dtype(kDLFloat, 32, x.dtype().lanes());
+      args.push_back(Cast(fp32_dtype, {x}, op->span));
+    } else {
+      args.push_back(x);
+    }
+  }
+  if (op->dtype.is_bfloat16()) {
+    DataType fp32_dtype(kDLFloat, 32, op->dtype.lanes());
+    PrimExpr result_fp32 = Call(fp32_dtype, op->op, {args}, op->span);
+    return Cast(op->dtype, {result_fp32}, op->span);
+  } else {
+    return Call(op->dtype, op->op, {args}, op->span);

Review Comment:
   nit: brackets not needed
   ```suggestion
       return Call(op->dtype, op->op, args, op->span);
   ```



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