Skip to content

[Converter:Bugfix] Honor ONNX Resize's default nearest mode - #4985

Merged
wangzhaode merged 2 commits into
alibaba:masterfrom
vera-rubin:fix/onnx-resize-default
Oct 19, 2026
Merged

wangzhaode merged 2 commits into
alibaba:masterfrom
vera-rubin:fix/onnx-resize-default

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

A Resize-13 node without mode converts to bilinear interpolation. With float32 NCHW x=[[[[0,10]]]] and int64 sizes=[1,1,1,4], we get [0,2.5,7.5,10]. ONNX Resize-13 defaults to nearest, so the output should be [0,0,10,10].

We initialize the mode to nearest.

Validation: before the fix, the 4 cases without mode gave the bilinear result and 4 explicit-nearest controls matched. After it, all 8 give [0,0,10,10], explicit nearest and linear modes are unchanged, and the 12 existing CPU Resize tests pass.

Module

Which module does this PR affect? e.g. LLM, CPU, Metal, CUDA, OpenCL, Core, Infra

Converter.

Type

  • Bugfix

Checklist

  • Commit message follows [Module:Type] Description format
  • Code compiles without errors
  • Tested on relevant platform(s)
  • No unrelated format or style changes included

— ChipLab

@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wangzhaode wangzhaode self-assigned this Oct 19, 2026
@wangzhaode wangzhaode added module:converter 模型转换工具 type:bug 功能缺陷 labels Oct 19, 2026
@wangzhaode

Copy link
Copy Markdown
Collaborator

Thanks for identifying and fixing the default ONNX Resize mode! The core change looks good.

Could you please remove tools/script/testOnnxResize.py from this PR and keep only the one-line fix in tools/converter/source/onnx/ResizeOnnx.cpp? The script is useful for local validation, but we do not need a separate, narrowly scoped test script for this change. Keeping the reproduction and validation results in the PR description is sufficient.

Thanks!

@wangzhaode wangzhaode added the awaiting contributor Waiting for contributor to address review comments or rebase label Oct 19, 2026
@vera-rubin

Copy link
Copy Markdown
Contributor Author

Done: the script is removed, so the PR now has only the one-line fix in ResizeOnnx.cpp, and the reproduction and validation results are in the description.

— ChipLab

@wangzhaode
wangzhaode merged commit 45a002a into alibaba:master Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting contributor Waiting for contributor to address review comments or rebase module:converter 模型转换工具 type:bug 功能缺陷

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants