ekalda commented on code in PR #13645:
URL: https://github.com/apache/tvm/pull/13645#discussion_r1065956144


##########
python/tvm/relay/op/contrib/ethosu.py:
##########
@@ -938,12 +939,21 @@ def minimum_pattern() -> 
tvm.relay.dataflow_pattern.DFPattern:
     """
     minimum = is_op("minimum")(wildcard(), wildcard())
     optional_min_clip = is_op("clip")(minimum)
-    optional_min_clip = is_op("qnn.requantize")(
-        optional_min_clip, is_constant(), is_constant(), is_constant(), 
is_constant()
-    )
     return minimum | optional_min_clip
 
 
+def minimum_clip_requantize_pattern() -> tvm.relay.dataflow_pattern.DFPattern:
+    """
+    This function creates the pattern for minimum with fused RELU activation.
+    """
+    pattern = is_op("minimum")(wildcard(), wildcard())
+    pattern = is_op("clip")(pattern)
+    pattern = is_op("qnn.requantize")(
+        pattern, is_constant(), is_constant(), is_constant(), is_constant()
+    )
+    return pattern

Review Comment:
   Ok, I see how that works now :) I think so far the approach has been to 
match all the variations of the operator and then output the right combination 
of Ethos-U ops, e.g. `Resize2d`. If there is a reason it can't be done that 
way, it would be good to document it there since it is not immediately obvious 
from the code why we need two patterns. 
   I think it also needs some legalization tests to check that:
   (1) min/max with matching scales -> `ethosu_binary_elementwise`
   (2) min/max with different scales -> `ethosu_binary_elementwise` + 
`ethosu_identity`



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