Skip to content

Harden Crop operator validation - #32157

Open
Edward Chen (edgchen1) wants to merge 2 commits into
mainfrom
edgchen1/fix_crop_validation
Open

Harden Crop operator validation#32157
Edward Chen (edgchen1) wants to merge 2 commits into
mainfrom
edgchen1/fix_crop_validation

Conversation

@edgchen1

Copy link
Copy Markdown
Contributor

Description

Reject negative and out-of-range border and scale attributes without overflow. Align DirectML validation, handle empty CUDA outputs, and add provider-wide regression coverage.

Motivation and Context

Fix Crop validation issues.

Reject negative and out-of-range border and scale attributes without overflow. Align DirectML validation, handle empty CUDA outputs, and add provider-wide regression coverage.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 18, 2026 18:51

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.

Pull request overview

Hardens Crop validation across CPU, CUDA, and DirectML while supporting empty CUDA outputs.

Changes:

  • Rejects invalid border and scale values without arithmetic overflow.
  • Aligns DirectML validation with shared Crop behavior.
  • Adds cross-provider regression tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
onnxruntime/contrib_ops/cpu/crop.h Adds overflow-safe attribute validation.
onnxruntime/contrib_ops/cuda/tensor/crop.cc Handles empty outputs and checked integer conversions.
onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp Adds DirectML bounds and sign validation.
onnxruntime/test/contrib_ops/crop_op_test.cc Expands invalid-input and edge-case coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/test/contrib_ops/crop_op_test.cc
Comment thread onnxruntime/contrib_ops/cpu/crop.h Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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