Skip to content

fix(detr): match reference resize rounding - #1281

Open
WenJing95 wants to merge 1 commit into
NVIDIA:mainfrom
WenJing95:fix-detr-resize-half-ties
Open

fix(detr): match reference resize rounding#1281
WenJing95 wants to merge 1 commit into
NVIDIA:mainfrom
WenJing95:fix-detr-resize-half-ties

Conversation

@WenJing95

Copy link
Copy Markdown
Contributor

Background

DETR resizes a 600x1200 image to 667x1333, while the reference produces 666x1333. This rejects inputs for an engine built at the reference dimensions.

Exit Criteria

Landscape and portrait inputs fit their reference-sized engine inputs.

Implementation

Round exact halves to the nearest even integer in the DETR preprocessor.

Change categories

  • Model or runtime behavior

Validation

Commands and Results

Native regression passed (21 checks); source-quality passed (164 tests).

g++ -std=c++17 -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Wno-unused-function -I. -Ithird_party/stb families/detr/tests/cpp/test_image_preprocess_seam.cpp families/detr/runtime/image_preprocess_seam.cpp -o /tmp/trtmc-four-detr-test
/tmp/trtmc-four-detr-test
python -m tools.community_ci source-quality --base 714f1fc0d567213a7b79a488e9dcfdf405279c6a

Hardware, Environment, and Revisions

e853c2c: Ubuntu CPU, GCC 13.3; Transformers 5.2.0 reference.

Not Run / Remaining Gaps

Checkpoint inference and full CMake suite: TensorRT environment unavailable.

Contributor Self-Review

  • I have completed a self-review of this change.

Notes For Future Readers

Half ties follow Python's round().

Risk level

  • Low

Only DETR resize dimensions change.

Signed-off-by: wj <126436871+WenJing95@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8ca0fb2c-c7b7-4945-bf31-81dd735b75b2

📥 Commits

Reviewing files that changed from the base of the PR and between 714f1fc and e853c2c.

📒 Files selected for processing (2)
  • families/detr/runtime/image_preprocess_seam.cpp
  • families/detr/tests/cpp/test_image_preprocess_seam.cpp

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary

DETR preprocessing now matches reference resize behavior. hf_round uses ties-to-even rounding for exact half values. This changes a 600×1200 input resize from 667×1333 to 666×1333.

Tests cover half-tie and non-tie rounding for landscape and portrait inputs. They also verify engine-dimension compatibility.

Validation

  • PASS: Native regression tests, 21 checks.
  • PASS: Source-quality validation, 164 tests.
  • BLOCK: Checkpoint inference and the full CMake suite were not run because TensorRT was unavailable.

Architecture impact

  • Family-owned files remain within families/detr.
  • No public or exported declarations changed.
  • No shared implementation or new dependency direction was identified.
  • DETR preprocessing consumers are affected by the corrected resize dimensions.
  • HUMAN REVIEW REQUIRED: TensorRT-backed inference and full CMake validation remain unresolved.

Walkthrough

The DETR resize helper now matches Python’s ties-to-even rounding. Tests cover half-tie and non-tie dimensions for landscape and portrait inputs, plus preprocessing output dimensions.

Changes

DETR resize rounding

Layer / File(s) Summary
Rounding implementation and resize validation
families/detr/runtime/image_preprocess_seam.cpp, families/detr/tests/cpp/test_image_preprocess_seam.cpp
hf_round now rounds half-ties to the even integer. Tests cover tie and non-tie resize values, landscape and portrait inputs, preprocessing dimensions, and test registration.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: husizhtu

Merge Risk: ⚪ Minimal · up to e853c

The resize rounding update is covered by tie, non-tie, orientation, and preprocessing tests; no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 8 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (8 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: updating DETR resize rounding to match the reference behavior.
Description check ✅ Passed The description covers the background, exit criteria, implementation, change category, validation results, environment, remaining gaps, self-review, and risk. It is sufficiently complete for the chang…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Family Ownership Boundary ✅ Passed PASS. The authoritative diff changes only two files under families/detr. The runtime change at families/detr/runtime/image_preprocess_seam.cpp:40-44 uses the existing <cmath> dependency and does…
Shared Semantic Neutrality ✅ Passed PASS. The pull request changes only families/detr/runtime/image_preprocess_seam.cpp and its C++ test. The semantic change is DETR-specific rounding in family-owned runtime preprocessing. The test ad…
Benchmark Validation Integrity ✅ Passed PASS. The PR changes DETR resize rounding and adds validation for landscape, portrait, tie, and non-tie cases. The changed code does not add benchmark timing, synchronization, device-to-host transfer,…
Shared Change Blast Radius ✅ Passed PASS: The pull request changes only DETR-family code and its DETR-local C++ tests. The modified hf_round is in an anonymous namespace, and the changed header/API is consumed by DETR pipeline.cpp, …

Comment @coderabbitai help to get the list of available commands.

@WenJing95
WenJing95 marked this pull request as ready for review September 12, 2026 09:41
@yifeif-nv

Copy link
Copy Markdown
Collaborator

PR direction looks good. But community CI seems to be broken on this one. Let me retrigger

@yifeif-nv yifeif-nv closed this Sep 14, 2026
@yifeif-nv yifeif-nv reopened this Sep 14, 2026
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.

2 participants