Skip to content

Support linear Resize in candle-onnx#3671

Open
jesco-absolut wants to merge 1 commit into
huggingface:mainfrom
jesco-absolut:fix-3153
Open

Support linear Resize in candle-onnx#3671
jesco-absolut wants to merge 1 commit into
huggingface:mainfrom
jesco-absolut:fix-3153

Conversation

@jesco-absolut

Copy link
Copy Markdown

Summary

Closes #3153.

This adds linear mode support for the 4D Resize operator in candle-onnx's simple_eval path.

  • keeps the existing nearest path and its current constraints unchanged
  • maps mode="linear" + coordinate_transformation_mode="half_pixel" to Tensor::upsample_bilinear2d(..., align_corners=false)
  • maps mode="linear" + coordinate_transformation_mode="align_corners" to Tensor::upsample_bilinear2d(..., align_corners=true)
  • continues to reject unsupported linear coordinate transformation modes explicitly

Tests

Added focused ONNX op tests in candle-onnx/tests/ops.rs for:

  • Resize with mode="linear" and coordinate_transformation_mode="half_pixel"
  • Resize with mode="linear" and coordinate_transformation_mode="align_corners"

Before the source change, the half_pixel regression test failed with:

Unsupported resize mode: linear

After the change, the focused resize tests pass.

Validation

Passed:

cargo test --manifest-path candle-onnx/Cargo.toml --test ops resize_linear
cargo test --manifest-path candle-onnx/Cargo.toml --test ops -- --skip test_gelu_operation
cargo test --manifest-path candle-onnx/Cargo.toml --lib
cargo fmt --manifest-path candle-onnx/Cargo.toml -- --check
git --no-pager diff --check

Notes:

  • cargo test --manifest-path candle-onnx/Cargo.toml currently fails in unrelated test_gelu_operation due exact float equality (0.8413447 vs 0.8413448).
  • cargo clippy --manifest-path candle-onnx/Cargo.toml --tests -- -D warnings is currently blocked by pre-existing generated-code/test lints in candle-onnx, not by this patch.

Blast radius

This only changes the Resize arm in candle-onnx/src/eval.rs.

Existing nearest behavior remains constrained to the previous supported path (nearest_mode="floor", coordinate_transformation_mode="asymmetric"). The new behavior is limited to 4D linear resize using Candle's existing bilinear resize primitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsupported linear Resize node with candle_onnx

1 participant