Skip to content

[Cpp API Compatibility] Add broadcast_to cross-framework test and update mapping doc#64

Open
youge325 wants to merge 9 commits into
PFCCLab:masterfrom
youge325:add/broadcast_to-20260528
Open

[Cpp API Compatibility] Add broadcast_to cross-framework test and update mapping doc#64
youge325 wants to merge 9 commits into
PFCCLab:masterfrom
youge325:add/broadcast_to-20260528

Conversation

@youge325

Copy link
Copy Markdown
Contributor

PR Category

Execute Infrastructure

PR Types

New features

Description

Add cross-framework compatibility test for at::broadcast_to and update API mapping documentation.

New file: test/ATen/ops/BroadcastToTest.cpp

  • 11 test cases covering:
    • Shape: small, large, boundary empty, boundary rank less
    • Dtype: kFloat, kDouble, kInt, kLong
    • Exception: invalid non-singleton, high rank to low rank
    • Function form: at::broadcast_to(t, size)

Modified: doc/cpp_api_mapping_cn.md

  • Moved at::broadcast_to from "功能缺失" (790) to "API 完全一致" (67)

Related: PaddlePaddle/Paddle#79173

是否引起精度变化

Copilot AI review requested due to automatic review settings May 28, 2026 10:54

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

Adds a cross-framework compatibility test for at::broadcast_to and reflects its newly-aligned status in the C++ API mapping documentation.

Changes:

  • New test file test/ATen/ops/BroadcastToTest.cpp with 11 GTest cases covering shape, dtype, exception, and function-form coverage, following the existing FileManerger create/append output pattern.
  • Moves at::broadcast_to from "功能缺失" to "API 完全一致" in doc/cpp_api_mapping_cn.md and updates the corresponding summary counts (66→67 and 790→789).

Reviewed changes

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

File Description
test/ATen/ops/BroadcastToTest.cpp New compatibility test exercising Tensor::broadcast_to and at::broadcast_to across shapes/dtypes/exceptions, serialized to the shared /tmp/paddle_cpp_api_test/ result file.
doc/cpp_api_mapping_cn.md Reclassifies at::broadcast_to as fully consistent and updates summary statistics; renumbering introduces a duplicate 22 in the consistent table and a 300 gap in the missing table.

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

Comment thread doc/cpp_api_mapping_cn.md Outdated
Comment on lines 56 to 58
| 21 | `at::broadcast_to` | `at::broadcast_to` (compat层) | API 完全一致 | - |
| 22 | `at::eye` | `at::eye` (compat层) | API 完全一致 | - |
| 22 | `at::flatten` | `at::flatten` (compat层) | API 完全一致 | - |
Comment thread doc/cpp_api_mapping_cn.md Outdated
Comment on lines 726 to 727
| 299 | `at::bucketize` | - | 功能缺失 | - |
| 301 | `at::can_cast` | - | 功能缺失 | - |
@youge325 youge325 force-pushed the add/broadcast_to-20260528 branch from 0d0c72c to b7881c3 Compare May 31, 2026 09:54
@youge325 youge325 force-pushed the add/broadcast_to-20260528 branch from 5b4b098 to a62ee39 Compare June 28, 2026 18:23
youge325 and others added 9 commits July 1, 2026 23:51
…ate mapping doc

- Add test/ATen/ops/BroadcastToTest.cpp with 11 test cases
  - Shape coverage: small, large, boundary empty, boundary rank less
  - Dtype coverage: kFloat, kDouble, kInt, kLong
  - Exception coverage: invalid non-singleton, high rank to low rank
  - Function form: at::broadcast_to(t, size)
- Update doc/cpp_api_mapping_cn.md: broadcast_to from 功能缺失 to API完全一致

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d strides diff

- Replace .contiguous() calls with strides-aware element access in
  BroadcastToTest.cpp, so strides differences between Paddle and PyTorch
  are preserved and detected by result_cmp.
- Add strides field to result output for layout comparison.
- Record the known mismatch (Paddle expand uses non-zero strides for
  broadcast dims vs PyTorch uses zero strides) in mismatch_api_record.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ate mapping doc

- Add test/ATen/ops/BroadcastToTest.cpp with 11 test cases
  - Shape coverage: small, large, boundary empty, boundary rank less
  - Dtype coverage: kFloat, kDouble, kInt, kLong
  - Exception coverage: invalid non-singleton, high rank to low rank
  - Function form: at::broadcast_to(t, size)
- Update doc/cpp_api_mapping_cn.md: broadcast_to from 功能缺失 to API完全一致

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ides diff

- Replace .contiguous() with strides-aware element access in ExpandTest.cpp.
- Add strides field to result output for layout comparison.
- Record expand strides mismatch alongside broadcast_to in
  mismatch_api_record.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- BroadcastToTest and ExpandTest now MATCH after compat layer fix
- Document the fix in Paddle expand.h (as_strided with stride=0)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…expand

- BroadcastToTest: add BroadcastToScalar (0-d tensor), BroadcastToNegativeOne
- ExpandTest: add ExpandScalar (0-d tensor), ExpandNegativeOne (-1 support),
  ExpandNegativeOneLeadingError (-1 in leading dim throws)
- Revert BroadcastToRejectsNegativeOne (PyTorch broadcast_to supports -1)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@youge325 youge325 force-pushed the add/broadcast_to-20260528 branch from a62ee39 to 16dbb98 Compare July 1, 2026 18:24
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