Skip to content

fix: Add generate wrapper change#796

Open
baominghelly wants to merge 1 commit into
masterfrom
fix/generate_wrappers
Open

fix: Add generate wrapper change#796
baominghelly wants to merge 1 commit into
masterfrom
fix/generate_wrappers

Conversation

@baominghelly

Copy link
Copy Markdown

Summary

  • Fix scripts/generate_wrappers.py to prefer parsed base-header type spellings when libclang reports ambiguous or degraded parameter types.
  • Preserve generated signatures for vector-like parameters, including std::vector<Tensor>, std::vector<int64_t> and std::optional<std::vector<int64_t>>.
  • Normalize explicit Call / Make template instantiations and deduplicate repeated instantiation entries.
  • Add regression coverage in tests/test_generate_wrappers.py for the Histogram overload case where libclang can misreport reused parameter names as int.

Motivation

The wrapper generator could produce invalid C++ when libclang degraded some operator parameter types. In particular, Histogram overload generation could emit an incorrect template signature such as Tensor, Tensor, int, ... instead of preserving the base-header signature with int64_t and optional vector types.

The same issue also affected generated explicit instantiations for tensor-list style parameters, where types could be normalized incorrectly, leading to compile errors in generated wrapper code.

Type of Change

  • fix — bug fix
  • test — adding or fixing tests only

Platforms Affected

  • PyTorch C++ bindings (WITH_TORCH)
  • Python bindings / user-facing API
  • Build system / CMake / CI

Smoke Test Result

build and install passed.
屏幕截图 2026-07-10 180319

unit test passed.
屏幕截图 2026-07-10 180829

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA Yes Build passed locally on A100 with WITH_NVIDIA / WITH_TORCH tests/test_generate_wrappers.py: 11 passed
Iluvatar No N/A - not affected N/A
MetaX No N/A - not affected N/A
Cambricon No N/A - not affected N/A
Moore No N/A - not affected N/A
Ascend No N/A - not affected N/A

Benchmark / Performance Impact

N/A. This only changes wrapper code generation and regression tests.

Notes for Reviewers

This change is intentionally scoped to wrapper generation. The main invariant is that generated wrapper signatures should match the operator base headers when parameter names uniquely identify the overload, instead of relying only on libclang's reported type spelling.

@baominghelly baominghelly requested review from a team and voltjia July 10, 2026 10:25
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.

1 participant