You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/01/31 20:17:18 UTC

[GitHub] [incubator-tvm] huajsj commented on a change in pull request #4791: [TOPI] upsample operator 'NCHWinic' format support.

huajsj commented on a change in pull request #4791: [TOPI] upsample operator 'NCHWinic' format support.
URL: https://github.com/apache/incubator-tvm/pull/4791#discussion_r373667310
 
 

 ##########
 File path: topi/python/topi/image/resize.py
 ##########
 @@ -18,8 +18,37 @@
 """TVM operator input resize compute."""
 from __future__ import absolute_import
 import tvm
+from topi.util import nchw_pack_layout, nchw_xc_layout
 from .. import tag
 
+def get_2d_indices(indices, layout='NCHW'):
+    """ Get 2d indices """
+    (cc, inum, ic) = (0, 0, 0)
+    if layout == 'NHWC':
+        n, y, x, c = indices
+        cc = None
+    elif layout == 'NCHW':
+        n, c, y, x = indices
+        cc = None
+    elif nchw_pack_layout(layout):
+        n, c, y, x, inum, ic = indices
+    else:
+        n, c, y, x, cc = indices
+    return n, c, y, x, cc, inum, ic
+
+def get_2d_pixel(data, layout, boxes, image_height, image_width, n, c, y, x, cc, ib, ic):
+    """ Get 2d pixel """
+    if boxes is None:
+        y = tvm.max(tvm.min(y, image_height - 1), 0)
+        x = tvm.max(tvm.min(x, image_width - 1), 0)
+    if layout == 'NHWC':
+        return data(n, y, x, c).astype('float')
+    if layout == 'NCHW':
+        return data(n, c, y, x).astype('float')
+    if nchw_pack_layout(layout):
+        return data(n, c, y, x, ib, ic).astype('float')
+    # else must be NCHWxc
 
 Review comment:
   Hi @tmoreau89 , thanks for the follow up, sure, issue just 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:
users@infra.apache.org


With regards,
Apache Git Services