Skip to content

feat(tensor): ONNX Resize coordinate transformations, rounding modes, and cubic options - #6154

Open
Sadik00789 wants to merge 10 commits into
tracel-ai:mainfrom
Sadik00789:feat/onnx-resize-modes
Open

Sadik00789 wants to merge 10 commits into
tracel-ai:mainfrom
Sadik00789:feat/onnx-resize-modes

Conversation

@Sadik00789

@Sadik00789 Sadik00789 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6147

Description

This PR implements comprehensive ONNX Resize operator semantics for burn::tensor::module::interpolate as requested in #6147.

Previously, InterpolateOptions relied solely on align_corners: bool, while scale_factor only calculated output shape without driving coordinate transformations. This prevented burn-onnx from expressing several ONNX Resize attributes and blocked 19 ONNX backend conformance tests (burn-onnx#546).

This change introduces full support for ONNX coordinate transformation modes, nearest rounding tie-breaking modes, scale-driven coordinate mapping, and bicubic convolution options across Burn's tensor stack, reference CPU implementation (burn-flex), IR, and dispatch pipeline.


Key Changes

1. Core Abstractions & Type Definitions (burn-std, burn-backend, burn-tensor)

  • CoordinateTransformMode: Added support for HalfPixel, AlignCorners, Asymmetric, PytorchHalfPixel, HalfPixelSymmetric, and TfCropAndResize { roi: [[f32; 2]; 2], extrapolation_value: f32 }.
  • NearestRoundingMode: Added RoundPreferFloor, RoundPreferCeil, Floor, and Ceil.
  • CubicOptions: Added configurable cubic spline parameter a (default -0.75, TensorFlow -0.5) and exclude_outside weight zeroing/renormalization.
  • InterpolateOptions Backward Compatibility:
    • Mode-dependent defaults configured in InterpolateOptions::new(mode) guarantee zero silent numerical regressions:
      • Nearest defaults to CoordinateTransformMode::Asymmetric and NearestRoundingMode::Floor.
      • NearestExact defaults to CoordinateTransformMode::HalfPixel and NearestRoundingMode::RoundPreferCeil (matching PyTorch nearest-exact symmetric upsampling).
      • Bilinear / Bicubic / Lanczos3 default to CoordinateTransformMode::AlignCorners and NearestRoundingMode::RoundPreferFloor.
    • Preserved with_align_corners(bool) without #[deprecated] to maintain compatibility with existing internal callers and benchmarks, while guarding it to prevent inadvertently overriding Nearest and NearestExact coordinate mappings.
  • Builder State Safety:
    • Added mutual exclusion between with_output_size and with_scale_factor so setting one explicitly clears the other.
    • Added input validation ensuring all components of scale_factor are strictly positive (> 0.0).

2. Reference CPU Implementation (burn-flex)

  • High-Precision Coordinate Mapping (f64):
    • Evaluates all coordinate mapping, scales, and ROI arithmetic strictly in f64, preventing single-precision boundary truncation (e.g. $14 \to 2$ downsampling selecting index 7 rather than 6).
    • Direct length arithmetic (x_out * l_in / l_out) used for size-based asymmetric mapping when scale_factor is omitted, eliminating division-order floating point drift (e.g. $14 \to 18$).
    • Prioritizes options.scale_factor when present over out_len / in_len, resolving non-integer downsampling coordinate drift.
  • Boundary & Edge-Case Protection:
    • Added explicit branches for single-pixel output (out_len == 1) under AlignCorners and TfCropAndResize to prevent division-by-zero.
    • Allowed inverted ROIs (r_start > r_end) in TfCropAndResize to support flipped-crop operations, checking extrapolation strictly against physical tensor bounds.
    • Early skip for zero-weight taps (weight == 0.0) in bicubic sampling and adjoint accumulation, preventing IEEE 754 NaN * 0.0 = NaN contamination when dummy clamped boundary indices read non-finite inputs.
    • Added fallback boundary clamping when valid tap weights sum to <= 1e-6 under bicubic exclude_outside = true to prevent NaN propagation.
  • Full Precision & Autodiff Coverage:
    • Forward operations implemented across f32, f64, f16, and bf16.
    • Backward gradient passes (interpolate_bilinear_backward_* and bicubic equivalents) mirror forward fractional coordinates and zero out gradient accumulation for extrapolated sample points.

3. High-Level Neural Network Modules (burn-nn)

  • Updated Interpolate1dConfig and Interpolate2dConfig to expose the new builders.
  • Forwarded both optional sizing fields in Interpolate1d so setting both triggers the shared mutual-exclusion validation check consistently with Interpolate2d.
  • Ensured 1D interpolation dummy height dimension (H = 1 -> 1) maintains neutral scaling (scale = 1.0, roi[0] = [0.0, 1.0]), preventing unintentional extrapolation.

4. IR, Routing, and GPU Scope Boundary (burn-ir, burn-router, burn-cubecl)

  • IR Float Hashing: Canonicalized signed zeros (+0.0 vs -0.0) to identical bit patterns prior to hashing roi, extrapolation_value, CubicOptionsIr::a, and scale_factor, maintaining PartialEq and Hash consistency for burn-fusion plan caching.
  • CubeCL Compatibility:
    • Permitted compatible scale_factor calls for AlignCorners (which depend only on tensor dimensions) as well as calls where scales match resolved output/input ratios in exact f64 precision.
    • Corrected backward dimension unpacking in interpolate_backward after permute_nchw_to_nhwc ([_, in_height, in_width, _]), ensuring backward scale checks evaluate physical spatial dimensions.
    • Actionable panic messages provided for extended modes pending upstream cubek integration.

Verification & Testing

  • burn-backend-tests:
    • nearest_interpolate.rs: Validated exact 0.5 coordinate tie-breaking across all 4 rounding modes, asymmetric vs. half-pixel shifts, f64 precision coordinate mapping ($14 \to 2$ downsample), size-based asymmetric precision ($14 \to 18$), and NearestExact symmetric upsampling.
    • bilinear_interpolate.rs: Validated scale-driven downsampling divergence, single-pixel output handling, HalfPixelSymmetric centering adjustment, normalized ROIs, inverted ROI flip-crops, and extrapolation value fill (inlined).
    • bicubic_interpolate.rs: Validated spline coefficients (a = -0.5 vs. a = -0.75), border tap zeroing under exclude_outside, and NaN skip protection on dummy zero-weight boundary taps.
    • autodiff/nearest_interpolate.rs: Validated backward scatter routing for precision coordinates ($14 \to 2$ and $14 \to 18$), bilinear crop extrapolation zero-gradients, non-integer scale gradient flows, and bicubic excluded boundary tap gradient skips.
  • Test Suite Status:
    • cargo check -p burn-backend-tests --benches: Passed (0 warnings, 0 errors)
    • cargo test-flex --test tensor interpolate: Passed (37 tests)
    • cargo test-flex --test autodiff interpolate: Passed (14 tests)
    • cargo test -p burn-tensor interpolate: Passed (8 tests)
    • cargo test -p burn-nn --features burn-core/flex interpolate: Passed (6 tests)
    • cargo test -p burn-ir interpolate: Passed
    • cargo test -p burn-flex interpolate: Passed (10 tests)
    • cargo check -p burn-cubecl --features wgpu --tests: Passed
    • cargo clippy --all-targets -- -D warnings: Passed (0 errors, 0 warnings)
    • cargo fmt --check: Clean

- Add CoordinateTransformMode, NearestRoundingMode, and CubicOptions to burn-std
- Implement scale-driven mapping, nearest tie-breaks, and bicubic edge renormalization in burn-flex
- Support inverted ROIs, single-pixel outputs, and extrapolation in TfCropAndResize
- Wire options through burn-ir, burn-router, burn-dispatch, and burn-nn
- Ensure builder mutual exclusion between output_size and scale_factor
- Add comprehensive unit, boundary, and regression tests in burn-backend-tests

Fixes tracel-ai#6147
@Sadik00789
Sadik00789 force-pushed the feat/onnx-resize-modes branch from 1834c8f to c43f7e8 Compare October 20, 2026 21:44
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.73529% with 262 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.39%. Comparing base (5965468) to head (b45e72b).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-ir/src/operation.rs 0.00% 100 Missing ⚠️
crates/burn-cubecl/src/kernel/interpolate/base.rs 0.00% 42 Missing ⚠️
crates/burn-flex/src/ops/interpolate.rs 93.15% 35 Missing ⚠️
...s/burn-nn/src/modules/interpolate/interpolate1d.rs 0.00% 18 Missing ⚠️
crates/burn-flex/src/ops/module.rs 39.28% 17 Missing ⚠️
...s/burn-nn/src/modules/interpolate/interpolate2d.rs 0.00% 15 Missing ⚠️
...ackend-tests/tests/autodiff/nearest_interpolate.rs 92.56% 9 Missing ⚠️
.../tests/tensor/float/module/bilinear_interpolate.rs 96.17% 8 Missing ⚠️
...s/tests/tensor/float/module/nearest_interpolate.rs 96.25% 6 Missing ⚠️
crates/burn-std/src/ops.rs 88.63% 5 Missing ⚠️
... and 3 more

❌ Your project check has failed because the head coverage (66.39%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6154      +/-   ##
==========================================
+ Coverage   65.87%   66.39%   +0.52%     
==========================================
  Files         874      878       +4     
  Lines      127237   128761    +1524     
==========================================
+ Hits        83818    85492    +1674     
+ Misses      43419    43269     -150     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sadik00789

Copy link
Copy Markdown
Contributor Author

@antimora take a look whenever you have a chance!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Confirmed sampling regressions and rejection of previously supported CubeCL calls block approval.

7 open issues
What changed in this PR

This PR extends Burn’s interpolation stack with ONNX Resize options needed by burn-onnx, addressing the coordinate mapping and sampling gaps described in #6147.

Changes:

  • Adds coordinate transformations, nearest rounding modes, cubic options, and scale-driven mapping.
  • Implements the options in Flex’s forward/backward paths and exposes them through neural-network modules and IR.
  • Adds shared forward tests and explicit CubeCL checks for unsupported options.

Agent-generated review. A standalone arithmetic check confirmed the coordinate-precision regression; project tests and builds were not run.

File Description
crates/​burn-tensor/​src/​tensor/​module.rs Re-exports options and validates positive scales.
crates/​burn-std/​src/​ops.rs Defines interpolation options, defaults, and builders.
crates/​burn-nn/​src/​modules/​interpolate/​interpolate2d.rs Exposes options through the 2D module.
crates/​burn-nn/​src/​modules/​interpolate/​interpolate1d.rs Exposes options while adapting the dummy spatial axis.
crates/​burn-ir/​src/​operation.rs Carries and hashes interpolation settings in IR.
crates/​burn-flex/​src/​ops/​module.rs Dispatches full options to typed implementations.
crates/​burn-flex/​src/​ops/​interpolate.rs Implements coordinate mapping, sampling, and gradients.
crates/​burn-cubecl/​src/​kernel/​interpolate/​base.rs Maps supported options and rejects unsupported combinations.
crates/​burn-backend/​src/​backend/​ops/​modules/​base.rs Re-exports the new backend option types.
crates/​burn-backend-tests/​tests/​tensor/​float/​module/​nearest_interpolate.rs Tests rounding modes and coordinate shifts.
crates/​burn-backend-tests/​tests/​tensor/​float/​module/​bilinear_interpolate.rs Tests scales, crop mapping, and single-pixel outputs.
crates/​burn-backend-tests/​tests/​tensor/​float/​module/​bicubic_interpolate.rs Tests cubic coefficients and excluded boundary taps.

Review effort: Balanced

Comment thread crates/burn-cubecl/src/kernel/interpolate/base.rs Outdated
Comment thread crates/burn-flex/src/ops/interpolate.rs Outdated
Comment thread crates/burn-flex/src/ops/interpolate.rs
Comment thread crates/burn-std/src/ops.rs
Comment thread crates/burn-std/src/ops.rs Outdated
Comment thread crates/burn-ir/src/operation.rs Outdated
Comment thread crates/burn-nn/src/modules/interpolate/interpolate1d.rs Outdated
…scales, and tap handling

- Support compatible scale factors in CubeCL for AlignCorners and exact ratios
- Perform coordinate mapping and tap accumulation in f64 in burn-flex
- Skip zero-weight taps in bicubic interpolation to avoid NaN poisoning
- Pair NearestExact defaults with RoundPreferCeil for symmetric upsampling
- Guard with_align_corners to preserve Asymmetric mapping on Nearest
- Canonicalize signed zero before bit-hashing float fields in burn-ir
- Forward both output_size and scale_factor in Interpolate1d to trigger mutual exclusion checks
- Add regression tests across burn-backend-tests, burn-ir, and burn-nn
@Sadik00789

Copy link
Copy Markdown
Contributor Author

All 7 items flagged by Copilot are resolved and backed by dedicated regression tests:

  1. CubeCL Compatible Scales: burn-cubecl now accepts scale_factor for AlignCorners mappings (which depend only on tensor dimensions) as well as HalfPixel/Nearest calls where the scale matches the resolved output/input ratio within tolerance. Only genuinely divergent scale-driven requests panic pending upstream cubek support.
  2. f64 Coordinate Math: map_coordinate and tap calculations in burn-flex now evaluate in f64, resolving the 14 -> 2 downsample truncation where index 6 was selected instead of 7.
  3. Bicubic Zero-Weight Tap Skip: Loops in burn-flex now skip taps with weight 0.0 before indexing, preventing NaN * 0.0 = NaN poisoning from dummy boundary reads when exclude_outside = true.
  4. NearestExact Defaults: Updated NearestExact defaults to (HalfPixel, RoundPreferCeil) so upsampling [10.0, 20.0] to length 4 produces symmetric [10.0, 10.0, 20.0, 20.0].
  5. with_align_corners Preservation: Guarded with_align_corners so it only modifies bilinear, bicubic, and lanczos modes, preserving Nearest's default Asymmetric mapping.
  6. IR Signed Zero Canonicalization: Normalized +0.0 and -0.0 to identical bit representations prior to hashing roi, extrapolation_value, and CubicOptionsIr::a, maintaining PartialEq and Hash consistency for burn-fusion plan caching.
  7. 1D Size and Scale Validation: Forwarded both sizing options in Interpolate1d so configuring both triggers the shared mutual-exclusion panic.

All unit, backend, and autodiff interpolation tests pass locally with clean formatting and zero clippy warnings.
Ready for another look @antimora whenever you get a chance.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Confirmed coordinate and compatibility errors can produce incorrect values and gradients or panic during CubeCL backward execution.

4 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Preserve and validate complete nearest interpolation semantics

crates/​burn-cubecl/​src/​kernel/​interpolate/​base.rs:199

[P2] These checks accept distinct nearest semantics but lower them to identical CubeK options. Resizing [10, 20] to width 4 with HalfPixel + Floor requires [10, 10, 10, 20], yet Nearest lowers it like Asymmetric + Floor, and NearestExact lowers it like HalfPixel + RoundPreferCeil; both require [10, 10, 20, 20]. NearestExact + Asymmetric is also accepted without preserving its transform. Validate the complete mode/transform/rounding tuple and reject unsupported combinations until CubeK can represent them.

Medium severity Normalize nonzero negative retained weight sums

crates/​burn-flex/​src/​ops/​interpolate.rs:672

[P2] A negative retained weight sum still needs normalization; the API does not restrict the cubic coefficient. For HalfPixel resizing [10, 20] to one pixel with a = 8 and exclude_outside = true, both valid weights are -0.5. Normalizing their sum of -1 gives 15, but this branch falls back to 20. Check the magnitude of the sum so nonzero negative sums are normalized in both forward and backward.

7 resolved since last review

Review effort: Balanced

Comment thread crates/burn-cubecl/src/kernel/interpolate/base.rs Outdated
Comment thread crates/burn-flex/src/ops/interpolate.rs Outdated
Comment thread crates/burn-cubecl/src/kernel/interpolate/base.rs Outdated
Comment thread crates/burn-flex/src/ops/interpolate.rs
@Sadik00789

Copy link
Copy Markdown
Contributor Author

All four follow-up review items have been resolved and verified:

  1. CubeCL Backward NHWC Indexing: Fixed dimension destructuring in crates/burn-cubecl/src/kernel/interpolate/base.rs from [_, _, in_height, in_width] to [_, in_height, in_width, _] after permute_nchw_to_nhwc, ensuring spatial dimensions are accurately read during backward scale checks.
  2. Exact Scale Equality in CubeCL: Replaced the float epsilon check with exact f64 ratio comparison before discarding scale factors, preventing unintended coordinate shifts near integer boundaries.
  3. Flex Asymmetric Precision ($14 \to 18$): Updated map_coordinate to compute x_out * l_in / l_out directly when no scale factor is provided, eliminating intermediate float division truncation and correctly mapping coordinate 9 to index 7.
  4. Autodiff Coverage: Added backward gradient tests inline for $14 \to 18$ scatter routing, bilinear crop extrapolation zero-gradients, non-integer scales, and bicubic excluded border tap gradients.

All 37 module interpolation tests and 14 autodiff interpolation tests pass locally with clean formatting and zero clippy warnings.
Ready for another look @antimora whenever you get a chance.

@Sadik00789

Sadik00789 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

All items from the latest review pass are resolved (2 previously missed issues):

  1. CubeCL Nearest Semantics: In crates/burn-cubecl/src/kernel/interpolate/base.rs, strictly validated the full (mode, coordinate_transform, nearest_mode) tuple. Only (Nearest, Asymmetric, Floor) and (NearestExact, HalfPixel, RoundPreferCeil) are permitted to lower to CubeK; all unsupported combinations panic with actionable guidance.
  2. Bicubic Retained Weight Normalization: In crates/burn-flex/src/ops/interpolate.rs, changed the tap sum check in bicubic_axis_taps to sum.abs() > 1e-6. Non-zero negative weight sums (such as with non-standard spline coefficients like $a = -8.0$ under exclude_outside) are now correctly normalized across forward and backward passes.
  3. Regression Tests: Added regression tests inline for negative weight sum normalization and CubeCL combination rejection, with zero modifications to test modules or extra files.

All 39 tensor and 14 autodiff interpolation tests pass locally with clean formatting and zero clippy warnings.

- Remove lazy-dependent integration test from shared backend test harness
- Pass options by reference in map_options to eliminate redundant clones
- Add direct unit tests for unsupported nearest option combinations in burn-cubecl
@Sadik00789

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts, have another look whenever you get a chance @antimora .

@laggui laggui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay!

Can you also update the changelog accordingly? This was just added in #6195 with instructions.

Comment on lines +207 to +210
CoordinateTransformMode::HalfPixel => {
let x_in = (x_out + 0.5) / s - 0.5;
MappedCoord::InBounds(x_in)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preserve half-pixel rounding ties when resizing by output size. Computing coordinates through a rounded scale ratio can select the wrong nearest neighbor.

Comment thread crates/burn-flex/src/ops/interpolate.rs Outdated
Comment on lines +675 to +678
if sum.abs() > 1e-6 {
for tap in taps.iter_mut() {
tap.weight /= sum;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we distinguish zero weight sums from small nonzero sums here? The cutoff appears to replace potentially valid interpolation weights with a boundary sample.

Comment on lines +182 to +189
let options = InterpolateOptions::new(InterpolateMode::Bilinear).with_scale_factor([1.5, 2.5]);

let output = burn_tensor::module::interpolate(input.clone(), options);
let grad = output.backward();
let input_grad = input.grad(&grad).unwrap();
let grad_values: Vec<f32> = input_grad.into_data().try_into_vec_as::<f32>().unwrap();
assert_eq!(grad_values.len(), 4);
assert!(grad_values.iter().all(|&g| g > 0.0 && g.is_finite()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses AlignCorners, which maps coordinates from tensor sizes, so it does not exercise scale-driven gradients.

The test should probably use scales where input_size * scale is nonintegral, and assert expected gradient values rather than only positivity and finiteness.

Comment thread crates/burn-flex/src/ops/interpolate.rs Outdated
Comment on lines +1993 to +2013
#[test]
fn test_nearest_downsample_f64_precision_backward() {
let x = FlexTensor::new(
Bytes::from_elems((0..14).map(|i| i as f32).collect::<Vec<_>>()),
Layout::contiguous(Shape::from(vec![1, 1, 1, 14])),
DType::F32,
);
let grad = FlexTensor::new(
Bytes::from_elems(vec![1.0f32, 1.0f32]),
Layout::contiguous(Shape::from(vec![1, 1, 1, 2])),
DType::F32,
);
let options = InterpolateOptions::new(InterpolateMode::Nearest)
.with_coordinate_transform(CoordinateTransformMode::Asymmetric)
.with_nearest_mode(NearestRoundingMode::Floor);
let result = interpolate_nearest_backward_f32(x, grad, [1, 2], &options);
let output = result.storage::<f32>();
assert_eq!(output[0], 1.0);
assert_eq!(output[6], 0.0);
assert_eq!(output[7], 1.0);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates test_nearest_downsample_f64_precision_backward in burn-backend-tests, which checks the same gradient routing through the public API. Please remove this local test.

Comment on lines +280 to +293
#[test]
fn test_interpolate_options_builder_mutual_exclusion() {
let opts1 = InterpolateOptions::new(InterpolateMode::Nearest)
.with_scale_factor([2.0, 2.0])
.with_output_size([10, 10]);
assert_eq!(opts1.scale_factor, None);
assert_eq!(opts1.output_size, Some([10, 10]));

let opts2 = InterpolateOptions::new(InterpolateMode::Nearest)
.with_output_size([10, 10])
.with_scale_factor([2.0, 2.0]);
assert_eq!(opts2.output_size, None);
assert_eq!(opts2.scale_factor, Some([2.0, 2.0]));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of burn-tensor::module::tests::interpolate_options_builder_mutual_exclusion.

- Add unreleased changelog entry for ONNX resize features
- Preserve half-pixel rounding ties when resizing by output size
- Normalize non-zero bicubic weight sums regardless of magnitude
- Remove duplicated unit/integration tests
- Verify scale-driven bilinear backward gradients against analytical weights
@Sadik00789

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @laggui! All 6 comments have been addressed:

  1. Changelog: Added an entry under ## Unreleased in burn-book/src/changelog.md detailing the ONNX Resize operator additions, coordinate transformation modes, rounding modes, cubic options, scale-driven mapping, and f64 precision improvements.
  2. Half-Pixel Rounding Ties: Updated CoordinateTransformMode::HalfPixel and PytorchHalfPixel to evaluate (x_out + 0.5) * l_in / l_out - 0.5 directly when resizing without scale factors, eliminating division ratio drift on exact half-pixel ties.
  3. Bicubic Normalization: Replaced sum.abs() > 1e-6 with if sum != 0.0 && sum.is_finite(), ensuring valid small non-zero weight sums are properly normalized and only true zeros fall back to boundary clamping.
  4. Scale-Driven Autodiff Gradients: Updated test_bilinear_backward_non_integer_scale_gradients to use CoordinateTransformMode::HalfPixel and non-integral scale [1.0, 0.6] on length 4, asserting exact analytical gradients [2/3, 1/3, 1.0, 0.0].
  5. Deduplication: Removed the redundant local backward unit test in burn-flex and the duplicate builder mutual exclusion test in burn-backend-tests.

All 37 module interpolation tests and 14 autodiff tests pass locally with clean formatting and zero clippy warnings.

@Sadik00789
Sadik00789 requested a review from laggui October 24, 2026 06:31
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.

tensor: ONNX Resize coordinate transformation and rounding modes for interpolate

3 participants