huajsj commented on a change in pull request #4887: [VTA] YoloV3 Support
URL: https://github.com/apache/incubator-tvm/pull/4887#discussion_r384730458
##########
File path: vta/python/vta/top/graphpack.py
##########
@@ -55,6 +57,46 @@ def _unpack_batch_channel(data, old_shape):
return data
+def _const_shape_match(data, dshape, cfactor_out):
+ """ Pad the constant if the shape[0] not divisible by cfactor_out.
+ """
+ pad_width = int(dshape[0]) % cfactor_out
+ if pad_width != 0:
+ pad_width = cfactor_out -pad_width
+ data = op.nn.pad(data, [[0, pad_width], [0, 0], [0, 0]])
+ dshape = tuple([dshape[0] + pad_width, dshape[1], dshape[2]])
+ return data, dshape
+
+def _weight_shape_match(data, dshape, channels, cfactor_out, transpose=False):
+ """ Pad the weight if the shape[0] not divisible by cfactor_out.
+ """
+ pad_width = int(dshape[0]) % cfactor_out
+ channels_pad = int(channels) % cfactor_out
+ if pad_width != 0:
+ pad_width = cfactor_out - pad_width
+ data = op.nn.pad(data, [[0, pad_width], [0, 0], [0, 0], [0, 0]])
+ dshape = tuple([dshape[0] + pad_width, dshape[1], dshape[2],
dshape[3]])
+
+ if channels_pad != 0:
+ channels = channels + (cfactor_out - channels_pad)
+
+ return data, dshape, channels
+
+def _weight_shape_match_transpose(data, dshape, channels, cfactor_out):
+ """ Pad the weight if the shape[1] not divisible by cfactor_out.
Review comment:
fixed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services