Generate API sources in the build directory#4961
Open
pfultz2 wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the C API build to generate migraphx.h and api.cpp into the build tree and compile/install from those generated outputs, rather than relying on the checked-in src/api copies.
Changes:
- Extend
tools/generate.pywith an--api-onlymode that writes C API outputs to caller-provided paths and can optionally skipclang-format. - Update
src/api/CMakeLists.txtto add a custom command/target that generates the C API into${CMAKE_CURRENT_BINARY_DIR}and buildsmigraphx_cfrom the generatedapi.cpp. - Install C API headers from the build-generated include directory rather than the source directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tools/generate.py | Adds --api-only generation path and makes formatting optional for build-only generation. |
| src/api/CMakeLists.txt | Generates C API sources/headers into the build dir and builds/installs migraphx_c from those outputs. |
|
|
||
| add_custom_command( | ||
| OUTPUT ${MIGRAPHX_API_GEN_HEADER} ${MIGRAPHX_API_GEN_SOURCE} | ||
| COMMAND ${Python_EXECUTABLE} ${MIGRAPHX_API_TOOLS_DIR}/generate.py |
| # tools/api. `make generate` still writes them into the source tree so the | ||
| # output can be reviewed, but migraphx_c is built from a freshly generated copy | ||
| # placed in the build directory instead of the checked-in src/api copies. | ||
| find_package(Python 3 COMPONENTS Interpreter REQUIRED) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4961 +/- ##
===========================================
+ Coverage 92.71% 93.01% +0.30%
===========================================
Files 589 592 +3
Lines 31160 31217 +57
===========================================
+ Hits 28888 29035 +147
+ Misses 2272 2182 -90 🚀 New features to boost your workflow:
|
Regressions detected 🔴 * No develop baseline was found for this PR's branch point; compared against the latest available develop run instead. |
|
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.
Motivation
This is to help enable conditional compilation of our API such as disabling TF or ONNX frontends.
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable