jikechao commented on code in PR #15682:
URL: https://github.com/apache/tvm/pull/15682#discussion_r1319294898


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -326,6 +326,56 @@ static std::vector<int> GetTransposeAxisOrder(const Call& 
call, int ndim) {
   return std::move(attr_axes);
 }
 
+/*!
+ * \brief SimplifyClipCastClip matches the pattern clip->cast->clip and fuse 
clips based on Clip
+ *    min/max values.
+ *
+ * Example:
+ *   %1 = clip(%0, a_min=0f, a_max=255f) [type=int32]
+ *   %2 = cast(%1, dtype="uint8") [type=uint8]
+ *   %3 = clip(%2, a_min=20f, a_max=66f) [type=uint8]
+ *
+ * Optimized to (fuse Clips):
+ *   %1 = clip(%0, a_min=20f, a_max=66f) [type=uint8]
+ *   %2 = cast(%1, dtype="uint8") [type=uint8]
+ */

Review Comment:
   Thanks for the PR! @youxiudeshouyeren. This optimization behavior seems not 
thorough enough; It can be further optimized to  `%1 = clip(%0, a_min=20f, 
a_max=66f) [type=uint8]`.



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