feat(bindings): support scalar default wrapper generation#601
Open
zhangyue207 wants to merge 1 commit into
Open
feat(bindings): support scalar default wrapper generation#601zhangyue207 wants to merge 1 commit into
zhangyue207 wants to merge 1 commit into
Conversation
455697b to
ca2c4d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/generate_wrappers.pyso scalar defaults from base headers are propagated into generatedpy::arg(...)declarations.tests/test_generate_wrappers.pyusing MHA-shaped fixture headers to verify required tensor outputs, optional tensor arguments, and scalar defaults.Motivation
Later attention operators need wrapper generation for signatures that combine required output tensors, optional tensor inputs, and scalar defaults such as
num_splits = 0. This PR keeps the generator change separate from the operator implementations so later PRs do not duplicate wrapper plumbing.N/A. No issue is linked.
Type of Change
feat— new feature / new operator / new platformfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Test Results on Supported Platforms
pytestResult2 passed in 0.65sinfiniops-ci/ascend:latestcontainer on Ascend 910B4.Full `pytest` output
Benchmark / Performance Impact
N/A. This PR changes wrapper generation only.
Notes for Reviewers
src/base/operator API is changed in this PR. The MHA-shaped headers in the tests are local fixtures for generator behavior only; public MHA API alignment remains in the MHA operator PR._BASE_DIR, which preserves the defaultsrc/basebehavior and lets tests provide focused temporary base headers.std::optional<Tensor>handling unchanged.Checklist
Title, Branch, and Commits
<type>/xxx-yyyy-zzzz.master— the branch is rebased cleanly on top of the currentmaster.fixup!/squash!/wipcommits remain.Scope and Design
printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.src/base/public API is changed.General Code Hygiene
C++ Specific
N/A. No C++ source files are changed.
Python Specific
ruff check scripts/generate_wrappers.py tests/test_generate_wrappers.pypasses.ruff format --check scripts/generate_wrappers.py tests/test_generate_wrappers.pypasses.Testing
pytest tests/test_generate_wrappers.py -v --tb=shortwas run in the project Ascend container.tests/.Build, CI, and Tooling
pip install .[dev] --no-build-isolation -C cmake.define.WITH_ASCEND=ON -C cmake.define.BUILD_ASCEND_CUSTOM=OFF -C cmake.define.AUTO_DETECT_DEVICES=OFF -C cmake.define.GENERATE_PYTHON_BINDINGS=ONpasses.compile_commands.jsonstill regenerates through the build.Documentation
Security and Safety