wrongtest commented on code in PR #11646:
URL: https://github.com/apache/tvm/pull/11646#discussion_r894075448


##########
src/arith/rewrite_simplify.cc:
##########
@@ -1640,13 +1640,27 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
CallNode* op) {
       // the operator overload will eagerly constant fold.
       return op->args[0] << op->args[1];
     }
+  } else if (op->op.same_as(Op::Get("tir.ceil"))) {
+    if (auto as_int = op->args[0].as<IntImmNode>()) {
+      return cast(op->dtype, IntImm(as_int->dtype, as_int->value));
+    } else if (auto as_float = op->args[0].as<FloatImmNode>()) {
+      return cast(op->dtype, FloatImm(as_float->dtype, 
std::ceil(as_float->value)));
+    }
+  } else if (op->op.same_as(Op::Get("tir.log2"))) {
+    if (auto as_int = op->args[0].as<IntImmNode>()) {
+      return cast(op->dtype, FloatImm(as_int->dtype, 
std::log2(as_int->value)));
+    } else if (auto as_float = op->args[0].as<FloatImmNode>()) {

Review Comment:
   
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#mathematical-functions-appendix
   Certain standard math functions have ulp errors on different devices, could 
the folding optimization be target aware?



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to