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 2021/04/19 16:01:05 UTC

[GitHub] [tvm] jwfromm commented on a change in pull request #7883: [ONNX][TOPI][RELAY] Resize refactor

jwfromm commented on a change in pull request #7883:
URL: https://github.com/apache/tvm/pull/7883#discussion_r615973599



##########
File path: python/tvm/relay/op/image/image.py
##########
@@ -58,6 +61,16 @@ def resize(
         Refer to the ONNX Resize operator specification for details.
         [half_pixel, align_corners, asymmetric]
 
+    rounding_method: string, optional
+        indicates how to find the "nearest" pixel in nearest_neighbor method
+        [round, floor, ceil]
+
+    bicubic_alpha: float
+        Spline Coefficient for Bicubic Interpolation
+
+    bicubic_exclude: int
+            Flag to exclude exterior of the image during bicubic interpolation

Review comment:
       should this be a bool rather than int?

##########
File path: python/tvm/topi/image/resize.py
##########
@@ -59,6 +59,33 @@ def get_2d_pixel(data, layout, boxes, image_height, image_width, n, c, y, x, cc,
     return data(n, c, y, x, cc).astype("float")
 
 
+def get_iny_inx(
+    y, x, image_height, image_width, target_height, target_width, coordinate_transformation_mode
+):
+    scale_y = te.div(image_height.astype("float"), target_height.astype("float"))
+    scale_x = te.div(image_width.astype("float"), target_width.astype("float"))
+    if coordinate_transformation_mode == "half_pixel":
+        in_y = (y + 0.5) * scale_y - 0.5
+        in_x = (x + 0.5) * scale_x - 0.5
+    elif coordinate_transformation_mode == "align_corners":
+        in_y = y * (image_height - 1).astype("float") / (target_height - 1)
+        in_x = x * (image_width - 1).astype("float") / (target_width - 1)
+    elif coordinate_transformation_mode == "asymmetric":
+        in_y = y * scale_y
+        in_x = x * scale_x
+    elif coordinate_transformation_mode == "pytorch_half_pixel":

Review comment:
       Do we need to update the pytorch and tf frontends to use these new modes?

##########
File path: python/tvm/topi/image/resize.py
##########
@@ -443,6 +476,7 @@ def resize_bicubic(
     target_width : integer
         The target resized image width
 
+

Review comment:
       this extra empty line probably isnt supposed to be there.




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