ashutosh-arm commented on code in PR #12353:
URL: https://github.com/apache/tvm/pull/12353#discussion_r942622944
##########
python/tvm/relay/op/contrib/cmsisnn.py:
##########
@@ -122,6 +130,25 @@ def check_qnn_conv2d(pattern):
conv2d_input = conv2d.args[0]
conv2d_weight = conv2d.args[1]
+ # check if sum of paddings from pad() and conv2d() satisfies CMSIS-NN
constraints
+ can_pad_be_fused = True
+ if isinstance(conv2d_input, tvm.relay.expr.Call) and
str(conv2d_input.op.name) == "nn.pad":
+ data_layout = conv2d.attrs.data_layout
+ conv2d_padding = conv2d.attrs.padding # (top, left, bottom, right)
+ pad = conv2d_input
+ pad_width = pad.attrs.pad_width
+ pad_width_w = pad_width[data_layout.find("W")] # (left, right)
+ pad_width_h = pad_width[data_layout.find("H")] # (top, bottom)
+ # calculate effective padding post pad fusion
+ pad_top = pad_width_h[0] + conv2d_padding[0]
+ pad_bottom = pad_width_h[1] + conv2d_padding[2]
+ pad_left = pad_width_w[0] + conv2d_padding[1]
+ pad_right = pad_width_w[1] + conv2d_padding[3]
+ # check if difference in the side paddings is 1 along each
dimension
+ pad_w_diff = int(pad_right - pad_left)
Review Comment:
No worries :+1:
--
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]