Skip to content

Use int64 loop counters in CPU Compress - #32008

Merged
Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/compress-int64-loop-counters
Aug 13, 2026
Merged

Use int64 loop counters in CPU Compress#32008
Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/compress-int64-loop-counters

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request updates several for-loop variable types in the Compress::Compute method to use int64_t instead of int. This improves consistency and prevents potential issues when handling large tensors with dimensions exceeding the range of int.

Type consistency and correctness:

  • Changed loop variable types from int to int64_t in all relevant for-loops within Compress::Compute to ensure proper handling of large tensor sizes and avoid integer overflow. [1] [2] [3] [4]

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

This PR updates loop counter types in the CPU Compress::Compute implementation to use int64_t instead of int, aligning iteration types with tensor shape/count types to better support large tensors.

Changes:

  • Switched multiple for-loop indices in Compress::Compute from int to int64_t to avoid int overflow on large shapes.
  • Updated nested loops in the axis-handling path (including the inner element loop) to iterate with int64_t.

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

Comment thread onnxruntime/core/providers/cpu/tensor/compress.cc
@apsonawane
Akshay Sonawane (apsonawane) merged commit 27414bb into main Aug 13, 2026
110 of 124 checks passed
@apsonawane
Akshay Sonawane (apsonawane) deleted the fix/compress-int64-loop-counters branch August 13, 2026 17:53
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.

3 participants