-
Notifications
You must be signed in to change notification settings - Fork 104
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
[BUG]CoreML模型转换双线差值上采样问题 #126
Comments
from coremltools.converters.mil import register_torch_op
from coremltools.converters.mil.frontend.torch.ops import _get_inputs, _get_scales_from_output_size
from coremltools.converters.mil.mil import Builder as mb
@register_torch_op(override=True)
def upsample_bilinear2d(context, node):
inputs = _get_inputs(context, node)
_input = inputs[0]
output_size = inputs[1]
align_corners = bool(inputs[2].val)
if len(inputs) == 5:
# For torch==1.5.0, upsample_bilinear2d has 5 inputs.
scales_h = inputs[3]
scales_w = inputs[4]
scales = _get_scales_from_output_size(output_size, _input.shape)
if scales:
scales_h, scales_w = scales
upsample_bilinear = mb.resize_bilinear(
x=_input,
target_size_height=output_size.val[0],
target_size_width=output_size.val[1],
name=node.name,
sampling_mode="STRICT_ALIGN_CORNERS",
)
context.add(upsample_bilinear)
######################################################################
### line 12
######################################################################
h, w = x.shape[2:]
return F.interpolate(x, size=(2*h, 2*w), mode="bilinear", align_corners=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bug描述
在转化coreml过程中,如果代码中存在pytorch双线差值上采样,在ios13上会报错,在ios14上可以顺利执行。
如何复现
复现步骤:
错误信息
环境
The text was updated successfully, but these errors were encountered: