Skip to content

skip elimination when reshape_lazy - #5104

Draft
weizhu12-amd wants to merge 1 commit into
developfrom
eliminate-concat-reshape-lazy
Draft

skip elimination when reshape_lazy#5104
weizhu12-amd wants to merge 1 commit into
developfrom
eliminate-concat-reshape-lazy

Conversation

@weizhu12-amd

Copy link
Copy Markdown
Collaborator

Motivation

Prevent concat elimination by introducing a special operations checks. This issue caused YOLOv3 compilation to fail with: reshape_lazy on axis that is not packed

Technical Details

Concat elimination replaces an input's buffer with a non-packed slice of the super-buffer. reshape_lazy can only alias a packed input, so if the input feeds a reshape_lazy the elimination is illegal; force a copy instead.

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.

Follow the LLVM AI Tool Use Policy for contributions using AI.

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

gh-app-migraphx-bot-pr-write Bot commented Jul 30, 2026

Copy link
Copy Markdown
Test Batch New Rate (9f88e4) Old Rate (3a503c)* Diff Status
torchvision-resnet50 64 3,326.70 3,264.92 1.89%
torchvision-resnet50_fp16 64 7,881.40 7,548.67 4.41%
torchvision-densenet121 32 2,491.47 2,483.99 0.30%
torchvision-densenet121_fp16 32 5,035.82 5,004.24 0.63%
torchvision-inceptionv3 32 2,076.12 2,058.51 0.86%
torchvision-inceptionv3_fp16 32 4,497.17 4,416.99 1.82%
cadene-inceptionv4 16 820.66 820.61 0.01%
cadene-resnext64x4 16 782.90 782.78 0.02%
slim-mobilenet 64 8,387.89 8,386.36 0.02%
slim-nasnetalarge 64 228.79 228.86 -0.03%
slim-resnet50v2 64 3,237.34 3,180.91 1.77%
bert-mrpc-onnx 8 1,170.15 1,168.84 0.11%
bert-mrpc-tf 1 497.32 498.63 -0.26%
pytorch-examples-wlang-gru 1 530.44 473.35 12.06% 🔆
pytorch-examples-wlang-lstm 1 478.02 384.83 24.22% 🔆
torchvision-resnet50_1 1 1,051.96 1,046.63 0.51%
cadene-dpn92_1 1 442.58 437.32 1.20%
cadene-resnext101_1 1 364.61 365.89 -0.35%
onnx-taau-downsample 1 845.10 844.09 0.12%
dlrm-criteoterabyte 1 32.39 32.42 -0.08%
dlrm-criteoterabyte_fp16 1 51.83 51.80 0.05%
agentmodel 1 9,609.01 9,209.12 4.34%
unet_fp16 2 58.71 58.80 -0.15%
resnet50v1_fp16 1 1,372.07 1,366.11 0.44%
resnet50v1_int8 1 1,827.65 1,883.96 -2.99%
bert_base_cased_fp16 64 1,097.21 1,098.16 -0.09%
bert_large_uncased_fp16 32 345.49 345.59 -0.03%
bert_large_fp16 1 205.71 206.59 -0.43%
distilgpt2_fp16 16 2,086.49 2,092.89 -0.31%
yolov5s 1 558.36 558.33 0.01%
tinyllama 1 45.82 45.83 -0.03%
vicuna-fastchat 1 44.17 44.20 -0.07%
whisper-tiny-encoder 1 412.59 411.87 0.18%
whisper-tiny-decoder 1 408.12 408.48 -0.09%
llama2_7b 1 20.82 20.84 -0.08%
qwen1.5-7b 1 23.60 23.58 0.08%
phi3-3.8b 1 26.72 26.72 0.02%
llama3-8b 1 21.77 21.80 -0.14%
whisper-large-encoder 1 10.18 10.18 -0.00%
whisper-large-decoder 1 105.39 105.30 0.09%
mistral-7b 1 23.75 23.78 -0.12%
FLUX.1-schnell 1 778.79 755.22 3.12%

Check flagged results 🔆

* 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 Jul 30, 2026

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf PASSED: MIGraphX meets tolerance
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
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 PASSED: MIGraphX meets tolerance
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

@TedThemistokleous

Copy link
Copy Markdown
Collaborator

Do you have the test case to verify this and the original model for us to look at? Where is that located? Feel free to reach out on teams

Concat elimination replaces an input's buffer with a non-packed slice of
the super-buffer. reshape_lazy can only alias a packed input, so if the
input feeds a reshape_lazy the elimination is illegal; force a copy
instead.
@weizhu12-amd
weizhu12-amd force-pushed the eliminate-concat-reshape-lazy branch from 57ad672 to 9f88e48 Compare August 3, 2026 05:04
@weizhu12-amd

Copy link
Copy Markdown
Collaborator Author

Please download the YOLOv3 ONNX model from: https://github.com/onnx/models/raw/main/validated/vision/object_detection_segmentation/yolov3/model/yolov3-12.onnx,
Then run the following command:
migraphx-driver perf yolov3.onnx --input-dim @input_1 1 3 416 416 --input-dim @image_shape 1 2

The model runs successfully in my local environment with PRs #5103 and #5104 applied.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/eliminate_concat.cpp 97.92% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5104   +/-   ##
========================================
  Coverage    93.26%   93.26%           
========================================
  Files          623      623           
  Lines        32969    33007   +38     
========================================
+ Hits         30747    30783   +36     
- Misses        2222     2224    +2     
Files with missing lines Coverage Δ
src/eliminate_concat.cpp 96.75% <97.92%> (-0.72%) ⬇️

... and 1 file with indirect coverage changes

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

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