icemelon9 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-tvm/pull/6373#discussion_r495102806



##########
File path: python/tvm/relay/op/image/_image.py
##########
@@ -40,6 +40,33 @@ def compute_resize(attrs, inputs, out_type):
 
 reg.register_injective_schedule("image.resize")
 
+@script
+def _resize_func(image_shape, size, height_axis, width_axis, channel_axis):

Review comment:
       change the name to `_resize_shape_func`.

##########
File path: python/tvm/relay/op/image/_image.py
##########
@@ -118,3 +162,19 @@ def compute_grid_sample(attrs, inputs, out_dtype):
     return [topi.image.grid_sample(inputs[0], inputs[1], method, layout)]
 
 reg.register_injective_schedule("image.grid_sample")
+
+@script
+def _grid_sample_func(data, grid):
+    out = output_tensor((4,), "int64")
+    out[0] = int64(data[0])
+    out[1] = int64(data[1])
+    out[2] = int64(grid[2])
+    out[3] = int64(grid[3])

Review comment:
       same question here. different layout?

##########
File path: python/tvm/relay/op/image/_image.py
##########
@@ -40,6 +40,33 @@ def compute_resize(attrs, inputs, out_type):
 
 reg.register_injective_schedule("image.resize")
 
+@script
+def _resize_func(image_shape, size, height_axis, width_axis, channel_axis):
+    out = output_tensor((4,), "int64")
+    out[0] = int64(image_shape[0])
+    out[height_axis] = int64(size[0])
+    out[width_axis] = int64(size[1])
+    out[channel_axis] = image_shape[channel_axis]
+    return out
+
[email protected]_shape_func("image.resize", False)
+def resize_func(attrs, inputs, _):

Review comment:
       change the name to `resize_shape_func`

##########
File path: python/tvm/relay/op/image/_image.py
##########
@@ -40,6 +40,33 @@ def compute_resize(attrs, inputs, out_type):
 
 reg.register_injective_schedule("image.resize")
 
+@script
+def _resize_func(image_shape, size, height_axis, width_axis, channel_axis):
+    out = output_tensor((4,), "int64")
+    out[0] = int64(image_shape[0])
+    out[height_axis] = int64(size[0])
+    out[width_axis] = int64(size[1])
+    out[channel_axis] = image_shape[channel_axis]
+    return out
+
[email protected]_shape_func("image.resize", False)
+def resize_func(attrs, inputs, _):
+    """
+    Shape function for resize op.
+    """
+    layout = attrs.layout
+    height_axis = width_axis = channel_axis = 1
+    for i, letter in enumerate(layout):
+        if letter == "H":
+            height_axis = i
+        if letter == "W":
+            width_axis = i
+        if letter == "C":
+            channel_axis = i
+    size = get_const_tuple(attrs.size)
+    return [_resize_func(inputs[0], convert(size), convert(height_axis),

Review comment:
       Could you also provide batch axis to the shape func as well?

##########
File path: python/tvm/relay/op/image/_image.py
##########
@@ -109,6 +136,23 @@ def compute_affine_grid(attrs, inputs, out_dtype):
 
 reg.register_injective_schedule("image.affine_grid")
 
+@script
+def _affine_grid_func(data, target_shape):
+    out = output_tensor((4,), "int64")
+    out[0] = int64(data[0])
+    out[1] = int64(2)
+    out[2] = int64(target_shape[0])

Review comment:
       do we support different layout for `affine_grid`?




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


Reply via email to