Skip to content

Generate API sources in the build directory#4961

Open
pfultz2 wants to merge 5 commits into
developfrom
generate-api
Open

Generate API sources in the build directory#4961
pfultz2 wants to merge 5 commits into
developfrom
generate-api

Conversation

@pfultz2

@pfultz2 pfultz2 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

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.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

Copilot AI review requested due to automatic review settings June 12, 2026 18:34
@pfultz2 pfultz2 requested a review from causten as a code owner June 12, 2026 18:34

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

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.py with an --api-only mode that writes C API outputs to caller-provided paths and can optionally skip clang-format.
  • Update src/api/CMakeLists.txt to add a custom command/target that generates the C API into ${CMAKE_CURRENT_BINARY_DIR} and builds migraphx_c from the generated api.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.

Comment thread src/api/CMakeLists.txt

add_custom_command(
OUTPUT ${MIGRAPHX_API_GEN_HEADER} ${MIGRAPHX_API_GEN_SOURCE}
COMMAND ${Python_EXECUTABLE} ${MIGRAPHX_API_TOOLS_DIR}/generate.py
Comment thread src/api/CMakeLists.txt
# 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

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

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     

see 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jun 13, 2026

Copy link
Copy Markdown
Test Batch New Rate (63d471) Old Rate (0043a5)* Diff Status
torchvision-resnet50 64 3,163.43 3,153.59 0.31%
torchvision-resnet50_fp16 64 6,663.85 6,635.99 0.42%
torchvision-densenet121 32 2,706.52 2,694.92 0.43%
torchvision-densenet121_fp16 32 4,551.28 4,513.21 0.84%
torchvision-inceptionv3 32 1,797.42 1,796.76 0.04%
torchvision-inceptionv3_fp16 32 2,822.32 2,812.91 0.33%
cadene-inceptionv4 16 825.24 824.94 0.04%
cadene-resnext64x4 16 784.22 784.29 -0.01%
slim-mobilenet 64 8,430.30 8,391.26 0.47%
slim-nasnetalarge 64 228.93 228.80 0.06%
slim-resnet50v2 64 3,326.11 3,314.14 0.36%
bert-mrpc-onnx 8 1,169.85 1,171.25 -0.12%
bert-mrpc-tf 1 500.59 496.75 0.77%
pytorch-examples-wlang-gru 1 389.00 327.37 18.83% 🔆
pytorch-examples-wlang-lstm 1 458.81 505.79 -9.29% 🔴
torchvision-resnet50_1 1 776.72 763.35 1.75%
cadene-dpn92_1 1 448.89 453.50 -1.02%
cadene-resnext101_1 1 363.16 363.65 -0.13%
onnx-taau-downsample 1 401.53 399.46 0.52%
dlrm-criteoterabyte 1 32.68 32.42 0.79%
dlrm-criteoterabyte_fp16 1 47.74 51.82 -7.87% 🔴
agentmodel 1 12,163.42 12,562.69 -3.18%
unet_fp16 2 39.09 56.86 -31.25% 🔴
resnet50v1_fp16 1 1,022.15 1,007.81 1.42%
resnet50v1_int8 1 939.18 927.24 1.29%
bert_base_cased_fp16 64 1,027.66 1,098.00 -6.41% 🔴
bert_large_uncased_fp16 32 347.41 346.68 0.21%
bert_large_fp16 1 101.02 203.83 -50.44% 🔴
distilgpt2_fp16 16 2,095.94 2,096.89 -0.04%
yolov5s 1 568.51 562.13 1.14%
tinyllama 1 46.00 45.95 0.12%
vicuna-fastchat 1 43.98 44.14 -0.36%
whisper-tiny-encoder 1 419.95 417.62 0.56%
whisper-tiny-decoder 1 415.76 412.86 0.70%
llama2_7b 1 20.45 20.35 0.49%
qwen1.5-7b 1 23.62 23.60 0.10%
phi3-3.8b 1 18.92 26.88 -29.64% 🔴
llama3-8b 1 4.54 21.81 -79.19% 🔴
whisper-large-encoder 1 10.02 10.28 -2.58%
whisper-large-decoder 1 106.83 106.05 0.74%
mistral-7b 1 22.47 23.79 -5.52% 🔴
FLUX.1-schnell 1 769.54 753.45 2.14%

Regressions detected 🔴

* No develop baseline was found for this PR's branch point; compared against the latest available develop run instead.

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jun 13, 2026

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 377, in
main()
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 313, in main
import tensorflow as tf
File "/usr/local/lib/python3.10/dist-packages/tensorflow/init.py", line 38, in
from tensorflow.python.tools import module_util as _module_util
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/init.py", line 36, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 26, in
self_check.preload_check()
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/platform/self_check.py", line 63, in preload_check
from tensorflow.python.platform import _pywrap_cpu_feature_guard
ImportError: libamdhip64.so.6: cannot open shared object file: No such file or directory
pytorch-examples-wlang-gru PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-lstm PASSED: MIGraphX meets tolerance
dlrm-criteoterabyte PASSED: MIGraphX meets tolerance
agentmodel PASSED: MIGraphX meets tolerance
unet PASSED: MIGraphX meets tolerance
resnet50v1 PASSED: MIGraphX meets tolerance
bert_base_cased_fp16 PASSED: MIGraphX meets tolerance
bert_large_uncased_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
bert_large PASSED: MIGraphX meets tolerance
yolov5s PASSED: MIGraphX meets tolerance
tinyllama PASSED: MIGraphX meets tolerance
vicuna-fastchat PASSED: MIGraphX meets tolerance
whisper-tiny-encoder PASSED: MIGraphX meets tolerance
whisper-tiny-decoder PASSED: MIGraphX meets tolerance
distilgpt2_fp16 PASSED: MIGraphX meets tolerance
llama2_7b PASSED: MIGraphX meets tolerance
qwen1.5-7b PASSED: MIGraphX meets tolerance
phi3-3.8b PASSED: MIGraphX meets tolerance
llama3-8b PASSED: MIGraphX meets tolerance
whisper-large-encoder ERROR - check error output
traceback
2026-06-16 12:51:05.492451 [WARN] [/data/src/onnx/onnx_parser.cpp:282] Model has unbound symbolic dimension(s): batch_size, encoder_sequence_length, feature_size. These default to 1 and may cause unexpected behavior. Try setting --dim-param @<name> <value> or --input-dim @<input> <dims> if program compilation fails.
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 377, in
main()
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 224, in main
model = migraphx.parse_onnx(model_name, default_dim_value=batch)
RuntimeError: /data/src/include/migraphx/op/convolution.hpp:113: normalize_compute_shape: CONVOLUTION: mismatched channel numbers: input channels (1) != weights channels (80) * group (1)
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

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