You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/07 16:03:09 UTC

[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #10922: [FIX][FQ2I] Add abs to FQ2I, fix abs implementation for int

AndrewZhaoLuo commented on code in PR #10922:
URL: https://github.com/apache/tvm/pull/10922#discussion_r845307339


##########
src/tir/op/op.cc:
##########
@@ -653,7 +653,27 @@ PrimExpr abs(PrimExpr x, Span span) {
     if (px) {
       return IntImm(x.dtype(), std::abs(px->value), px->span);
     }
-    return tir::Select(x >= make_zero(x.dtype()), x, -x, span);
+

Review Comment:
   Hmm honestly I'm not sure if I like this change since it actually is a change in the semantics of abs. 
   
   E.g. abs(-128) = 128 which should overflow to -128 with only 8 bits. 
   
   IMO two solutions:
   1. For integers, make it return uint version so it never overflows.
   2. Just handle the edge case manually in fq2i 
   
   If I understand this is only important to handle the -128 --> 127 case in quantized models so I say just put it in 2.



-- 
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-unsubscribe@tvm.apache.org

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