-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[ONNX] [Relay] Resize Opset 13 #9265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2697,6 +2697,40 @@ def _impl_v10(cls, inputs, attr, params): | |
|
|
||
| @classmethod | ||
| def _impl_v11(cls, inputs, attr, params): | ||
| scale = inputs[2] | ||
| scale_shape = infer_shape(scale) | ||
| if len(inputs) == 4: | ||
| assert ( | ||
| len(scale_shape) == 0 or scale_shape[0] == 0 | ||
| ), "One of scale or size should be passed, not both." | ||
| size = inputs[3] | ||
| else: | ||
| assert len(scale_shape) != 0, "One of scale or size should be passed." | ||
| size = _op.cast(shape_of(inputs[0]), infer_type(scale).checked_type.dtype) * scale | ||
| return cls.v11_13_common(inputs, size, attr, params) | ||
|
|
||
| @classmethod | ||
| def _impl_v13(cls, inputs, attr, params): | ||
| scale = inputs[2] | ||
| size = inputs[3] | ||
| if size is not None: | ||
| assert scale is None, "One of scale or size should be passed, not both." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the scales or sizes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both scale and size are singular (there is only one of them) and adding an 's' makes them plural. It's only one dog or cat, not dogs or cats 🐶 🐈 vs 🐶 🐶 🐶 🐈 🐈 🐈 |
||
| else: | ||
| scale_type = infer_type(scale) | ||
| scale_shape = scale_type.checked_type.shape | ||
| scale_dtype = scale_type.checked_type.dtype | ||
| assert len(scale_shape) != 0, "One of scale or size should be passed." | ||
| size = _op.cast(shape_of(inputs[0]), scale_dtype) * scale | ||
|
|
||
| return cls.v11_13_common(inputs, size, attr, params) | ||
|
|
||
| @classmethod | ||
| def v11_13_common(cls, inputs, size, attr, params): | ||
| """ | ||
| Resize v11 and Resize v13 are identical except in how | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resize v11 and resize
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi emijiayw, Thanks for your feedback! Resize v13 is specified for clarity since just resize could be misleading. :) |
||
| they handle the passing of scale and size. This utility | ||
| provides the implementation for both | ||
| """ | ||
| ndims = len(infer_shape(inputs[0])) | ||
| mode = attr.get("mode").decode("ascii") | ||
| if mode == "nearest": | ||
|
|
@@ -2715,16 +2749,6 @@ def _impl_v11(cls, inputs, attr, params): | |
| alpha = attr.get("cubic_coeff_a", -0.75) | ||
| exclude = attr.get("exclude_outside", 0) | ||
|
|
||
| scale = inputs[2] | ||
| scale_shape = infer_shape(scale) | ||
| if len(inputs) == 4: | ||
| assert ( | ||
| len(scale_shape) == 0 or scale_shape[0] == 0 | ||
| ), "One of scale or size should be passed, not both." | ||
| size = inputs[3] | ||
| else: | ||
| assert len(scale_shape) != 0, "One of scale or size should be passed." | ||
| size = _op.cast(shape_of(inputs[0]), infer_type(scale).checked_type.dtype) * scale | ||
| out_size = fold_constant(_op.strided_slice(size, [2], [4])) | ||
| out = None | ||
| if ndims == 3: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the scales or sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above!