feat: build C API on functional operator API#617
Draft
voltjia wants to merge 2 commits into
Draft
Conversation
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
include/infini/ops.h.InfiniOpsTensorDescriptorand descriptor create/destroy APIs.InfiniOpsTensora direct C value struct that describes caller-owned memory: data pointer, byte size, dtype, device, rank, shape, and stride.InfiniOpsHandleandInfiniOpsConfigbecause they correspond to existing C++HandleandConfig.infini::ops::functional::Add.src/infini/ops.ccbuilds as normal C++ and no longer includes backend kernel headers.Motivation
This is the second PR in the public operator API split. After the public C++ functional API exists, the stable C ABI can be implemented on top of that layer instead of depending on private dispatch or backend kernel headers.
Target base branch:
feat/cpp-operator-api.Closes #N/A
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
pytestResulttests/test_c_api.py tests/test_cpp_api.py:4 passedssh nvidia, containeraccelerator-dev/nvidia:latest; build configured withWITH_CPU=ON,WITH_NVIDIA=ON.Full `pytest` output (optional)
Additional checks on
ssh nvidiawithaccelerator-dev/nvidia:latest:Verified build/link details:
Build emitted existing CUDA warnings around meaningless
constreturn qualifiers and partially overridden overloads.Benchmark / Performance Impact
N/A. This PR changes API wrapping and validation. It does not change operator kernels or dispatch selection.
Notes for Reviewers
feat/cpp-operator-api, notmaster, so the diff only shows the stable C ABI layer on top of the C++ functional API.InfiniOpsTensordoes not own caller buffers and is not destroyed by the library.InfiniOpsHandleandInfiniOpsConfigremain opaque handles because they map to existing C++HandleandConfig.infini::ops::functional::Addand no longer includes backend kernel headers.Checklist
Title, Branch, and Commits
feat: build C API on functional operator API.<type>/...form:feat/operator-c-api.feat: build C API on functional operator API.feat/cpp-operator-apiso reviewers see only the C ABI diff.fixup!/squash!/wipcommits remain.Scope and Design
General Code Hygiene
git diff --checkpassed.C++ Specific
clang-formatversion 21 was not run in this session; remote build andgit diff --checkpassed.clang-tidywas not run in this session.InfiniOpsStatus.InfiniOpsStatusand expose details throughinfiniOpsGetLastError.Python Specific
ruff check/ruff format --checkwere not run in this session.Testing
tests/test_c_api.py.tests/test_cpp_api.py.Build, CI, and Tooling
pip install .[dev]was not run.src/infini/ops.ccbuilds as CXX, not CUDA.libinfiniops.so.1.infiniOps*prefix.Documentation
include/infini/ops.hand covered by smoke tests.InfiniOpsTensorbeing a value struct for caller-owned buffers.Security and Safety