Skip to content

test(index_reduce): align with Paddle compat index_reduce behavior#70

Open
youge325 wants to merge 1 commit into
PFCCLab:masterfrom
youge325:test/index_reduce-20260530
Open

test(index_reduce): align with Paddle compat index_reduce behavior#70
youge325 wants to merge 1 commit into
PFCCLab:masterfrom
youge325:test/index_reduce-20260530

Conversation

@youge325
Copy link
Copy Markdown
Contributor

Summary

Add cross-framework compatibility tests for Tensor::index_reduce in the Paddle C++ compat layer.

Test Coverage (14 cases)

  • Reduce modes: prod, mean, amax, amin
  • Shape coverage: small, large, boundary, 1D, multi-dim
  • Dtype coverage: kFloat, kDouble, kInt, kLong
  • Options: include_self=true/false, in-place, non-member function
  • Edge case: invalid reduce type exception handling

Related

🤖 Generated with Claude Code

Add cross-framework compatibility tests for Tensor::index_reduce:
- 14 test cases covering prod/mean/amax/amin reduce modes
- Shape coverage: small/large/boundary/1D/multi-dim
- Dtype coverage: kFloat/kDouble/kInt/kLong
- include_self true/false, in-place, non-member function
- Invalid reduce type exception handling

Related: PaddlePaddle/Paddle#79195

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 30, 2026 09:35
Copy link
Copy Markdown
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

Adds a new compat-layer regression test file IndexReduceTest.cpp that exercises Tensor::index_reduce / index_reduce_ / at::index_reduce to compare Torch vs Paddle output. The test follows the project's output-diff harness conventions (createFile on first test, openAppend afterwards, label + shape + first/last/sum serialization, dtype dispatch, exception marker for invalid reduce type).

Changes:

  • New test file with 14 cases covering reduce modes (prod, mean, amax, amin), dtypes (float, double, int, long), shapes (1D/2D/large/dim=1), include_self=false, in-place, non-member, and invalid-reduce exception.
  • Local helpers: tensor_from_vector_i64 for index tensors and write_index_reduce_result_to_file for dtype-dispatched serialization.
  • Will be auto-picked up by the CMake glob to produce torch_IndexReduceTest and paddle_IndexReduceTest, then diffed by result_cmp.sh.

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

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