Alexey-Yazev commented on code in PR #13645:
URL: https://github.com/apache/tvm/pull/13645#discussion_r1065533597
##########
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:
There are two patterns to support two cases:
a) when we can offload minimum + clip + qnn.requantize to NPU with one
operation ethosu_binary_elementwise if there are same scales
b) when we can offload minimum + clip + qnn.requantize to NPU with two
operations ethosu_binary_elementwise + ethosu_identity if there are different
scales
Since there is a hardware limitation, we cannot perform min or max operation
fused with requantize (please look at NPU_SET_OFM_SCALE
https://developer.arm.com/documentation/102420/0200/Programmers-model/Command-stream/cmd1-commands-)
when we have different scales.
--
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]