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


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -146,7 +146,7 @@ class SimplifyConsecutiveCast : public DFPatternRewrite {
       // BFloat cast cannot be omitted
       return false;
     }
-    if (origin.code() < cast.code()) {
+    if (origin.code() < cast.code() && origin.bits() <= cast.bits()) {

Review Comment:
   More general solution would be to calculate range of values dtypes 
represent. If moving to new dtype has range which is subset of old range it is 
a widen cast.
   
   This perhaps is too harsh as it would block casting with int64 --> float32 
or int32 --> float16 which may be relevant for quantization.



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