Skip to content

Conversation

@CuiYifeng
Copy link
Contributor

To fix #2473
This PR is to correct the early-exit condition for empty index tensor.

Copilot AI review requested due to automatic review settings December 10, 2025 01:22
Copy link
Contributor

Copilot AI left a comment

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 fixes the early-exit condition in the index_add kernel to properly handle empty index tensors, addressing issue #2473. The fix simplifies the logic by removing an unnecessary dimension check that prevented the early exit from working correctly for 1-dimensional tensors.

Key Changes:

  • Simplified the early-exit condition to check for empty index or self tensors regardless of dimensionality
  • Added regression test to verify index_add works correctly with empty index tensors

Reviewed changes

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

File Description
src/ATen/native/xpu/sycl/Indexing.cpp Simplified early-exit condition by removing dimension check, allowing proper handling of empty index tensors for all dimensions
test/regressions/test_index_and_index_put.py Added test case test_index_add_empty to verify correct behavior with empty index tensors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CuiYifeng CuiYifeng force-pushed the yifeng/fix_index_add branch from 1c29504 to 2d4b57a Compare December 15, 2025 05:43
@CuiYifeng CuiYifeng added this to the PT2.11 milestone Dec 17, 2025
@CuiYifeng CuiYifeng requested review from EikanWang and etaf December 17, 2025 08:24
@CuiYifeng CuiYifeng added this pull request to the merge queue Dec 23, 2025
Merged via the queue into main with commit 966876c Dec 23, 2025
96 of 100 checks passed
@CuiYifeng CuiYifeng deleted the yifeng/fix_index_add branch December 23, 2025 00:58
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.

index_add_ caused core dump when index and source tensor are empty

5 participants