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/07/12 23:48:29 UTC
[GitHub] [tvm] trevor-m commented on a change in pull request #8455: [Relay] Support resize in the ONNX conversion
trevor-m commented on a change in pull request #8455:
URL: https://github.com/apache/tvm/pull/8455#discussion_r668329230
##########
File path: tests/python/contrib/test_onnx.py
##########
@@ -655,6 +655,26 @@ def verify_cast(dshape, dtype):
verify_cast(i, o_dtype)
+def test_resize():
+ """Resize unit test."""
+
+ def verify_resize(dshape, outsize, method=None, dtype="float32"):
+ x = relay.var("x", relay.ty.TensorType(dshape, dtype))
+ y = relay.image.resize2d(x, outsize, layout="NCHW", method=method)
+ func = relay.Function([x], y)
+ x_data = np.random.uniform(size=dshape).astype(dtype)
+ verify_results(func, [x_data], "test_resize", rtol=1e-4, atol=1e-4)
+
+ isize = [(1, 3, 480, 640)]
+ osize = [(240, 320), (960, 1280)]
+ method = ["nearest_neighbor", "linear", "cubic"]
Review comment:
Could you also test the various options for rounding_method and coordinate_transformation_mode?
##########
File path: python/tvm/contrib/target/onnx.py
##########
@@ -662,6 +662,86 @@ def convert_attributes(cls, attrs):
return {"to": getattr(TensorProto, attrs.dtype.upper())}
+class Resize(OpConverter):
+ """Operator converter for Resize."""
+
+ @classmethod
+ def convert_attributes(cls, attrs):
+ method = attrs.get_str("method")
+ if method == "nearest_neighbor":
+ mode = b"nearest"
+ elif "linear" in method: # linear / bilinear
+ mode = b"linear"
+ elif "cubic" in method: # cubic / bicubic
+ mode = b"cubic"
Review comment:
It might be good to add an `else` to raise an error for unsupported values.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org