-
Notifications
You must be signed in to change notification settings - Fork 66
AddOp(upsample_bicubic2d) | feat(torchlib) #1208
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 16 commits
918250e
2950096
cf8ecba
4d2b17e
0831914
2d6f55c
9083b65
d06f807
06ae926
9b728fa
0d2eb44
67fe7a9
3005273
ed0c2ef
e547331
6e231e5
d45abfe
4c9d9c0
4858062
ca6931e
8222049
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 |
---|---|---|
|
@@ -2197,16 +2197,85 @@ def aten_unflatten_dense_tensors( | |
raise NotImplementedError() | ||
|
||
|
||
@torch_op("aten::upsample_bicubic2d", trace_only=True) | ||
def aten_upsample_bicubic2d( | ||
self: TensorType, | ||
self: TReal, | ||
output_size: INT64, | ||
align_corners: bool, | ||
scales_h: Optional[float] = None, | ||
scales_w: Optional[float] = None, | ||
) -> TensorType: | ||
"""upsample_bicubic2d(Tensor self, SymInt[2] output_size, bool align_corners, float? scales_h=None, float? scales_w=None) -> Tensor""" | ||
scales: TFloat = None, | ||
xiaowuhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> TReal: | ||
"""upsample_bicubic2d.vec(Tensor input, SymInt[]? output_size, bool align_corners, float[]? scale_factors) -> Tensor""" | ||
"""upsample_bicubic2d(Tensor self, SymInt[2] output_size, bool align_corners, float? scales_h=None, float? scales_w=None) -> Tensor""" # pylint: disable=pointless-string-statement | ||
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. Should we split them into two functions? 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. Onnx.Resize() only accept either output_size or scales, it is error if both provided. 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. Do we handle when 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. Didn't handled.
xiaowuhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
raise NotImplementedError() | ||
if output_size is not None: | ||
result = _aten_upsample_output_size(self, output_size, align_corners, "cubic") | ||
|
||
else: | ||
|
||
result = _aten_upsample_scales(self, scales, align_corners, "cubic") | ||
|
||
return result | ||
|
||
|
||
@torch_op("aten::upsample_bicubic2d", private=True) | ||
def _aten_upsample_output_size( | ||
self: TReal, | ||
output_size: INT64, | ||
align_corners: bool, | ||
str_mode: str, | ||
) -> TReal: | ||
self_shape = op.Shape(self) | ||
starts = op.Constant(value_ints=[0]) | ||
ends = op.Constant(value_ints=[2]) | ||
batch_channel = op.Slice(self_shape, starts, ends) | ||
output_size = op.Concat(batch_channel, output_size, axis=0) | ||
if align_corners: | ||
result = op.Resize( | ||
self, | ||
None, | ||
None, | ||
output_size, | ||
mode=str_mode, | ||
coordinate_transformation_mode="align_corners", | ||
) | ||
else: | ||
result = op.Resize( | ||
self, | ||
None, | ||
None, | ||
output_size, | ||
mode=str_mode, | ||
coordinate_transformation_mode="pytorch_half_pixel", | ||
) | ||
|
||
return result | ||
|
||
|
||
@torch_op("aten::upsample_bicubic2d", private=True) | ||
def _aten_upsample_scales( | ||
self: TReal, | ||
scales: TFloat, | ||
align_corners: bool, | ||
str_mode: str, | ||
) -> TReal: | ||
scales = op.Cast(scales, to=FLOAT.dtype) | ||
scales = op.Concat(op.Constant(value_floats=[1.0, 1.0]), scales, axis=0) | ||
if align_corners: | ||
result = op.Resize( | ||
self, | ||
None, | ||
scales, # format should be: [1.0, 1.0, scale_h, scale_w] | ||
None, | ||
mode=str_mode, | ||
coordinate_transformation_mode="align_corners", | ||
) | ||
else: | ||
result = op.Resize( | ||
self, | ||
None, | ||
scales, # format should be: [1.0, 1.0, scale_h, scale_w] | ||
None, | ||
mode=str_mode, | ||
coordinate_transformation_mode="pytorch_half_pixel", | ||
) | ||
return result | ||
|
||
|
||
def aten_upsample_bicubic2d_backward( | ||
|
Uh oh!
There was an error while loading. Please reload this page.