Skip to content

[AIMIGRAPHX-885] Add slice squeeze matcher clean#5004

Draft
TedThemistokleous wants to merge 3 commits into
developfrom
add_slice_squeeze_matcher_clean
Draft

[AIMIGRAPHX-885] Add slice squeeze matcher clean#5004
TedThemistokleous wants to merge 3 commits into
developfrom
add_slice_squeeze_matcher_clean

Conversation

@TedThemistokleous

Copy link
Copy Markdown
Collaborator

Motivation

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.

Port the find_slice_squeeze matcher from the MLP_prediction_towers branch.
This matcher rewrites slice->squeeze->pointwise/reduce into
slice->pointwise/reduce->squeeze (unsqueezing the other inputs), which lets
the squeeze propagate downstream and parallel slice branches merge back
together. Includes the associated unit tests.
Replace the brittle "not pointwise" check with the shared is_reduce helper
from find_op_shape_transform_op so reduce/argmin/argmax detection is precise
and consistent with the rest of the pass.
Delegate the reduce/argmin axis remapping in find_slice_squeeze to the shared
insert() helper by building a source->common axes map for the unsqueeze.
This removes the hand-rolled axis-shifting logic, keeps behavior consistent
with find_op_shape_transform_op, and additionally handles layout permutations
for free.
Comment thread src/simplify_reshapes.cpp
Comment on lines +1832 to +1834
auto squeeze_slice = match::name("squeeze")(
match::arg(0)(match::name("slice").bind("slice")))
.bind("squeeze");

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.

[format.py] reported by reviewdog 🐶

Suggested change
auto squeeze_slice = match::name("squeeze")(
match::arg(0)(match::name("slice").bind("slice")))
.bind("squeeze");
auto squeeze_slice =
match::name("squeeze")(match::arg(0)(match::name("slice").bind("slice")))
.bind("squeeze");

Comment thread src/simplify_reshapes.cpp
Comment on lines +1857 to +1858
input = m.insert_instruction(
op_ins, make_op("unsqueeze", {{"axes", {axis}}}), input);

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.

[format.py] reported by reviewdog 🐶

Suggested change
input = m.insert_instruction(
op_ins, make_op("unsqueeze", {{"axes", {axis}}}), input);
input =
m.insert_instruction(op_ins, make_op("unsqueeze", {{"axes", {axis}}}), input);

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5004      +/-   ##
===========================================
- Coverage    92.73%   92.71%   -0.02%     
===========================================
  Files          592      594       +2     
  Lines        31289    31493     +204     
===========================================
+ Hits         29015    29198     +183     
- Misses        2274     2295      +21     
Files with missing lines Coverage Δ
src/simplify_reshapes.cpp 98.02% <100.00%> (+0.06%) ⬆️

... and 19 files with indirect coverage changes

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

@TedThemistokleous TedThemistokleous added the bugfix Fixes a bug found in the code. label Jun 22, 2026
@gh-app-migraphx-bot-pr-write

Copy link
Copy Markdown
Test Batch New Rate (53e3c1) Old Rate (241f7a) Diff Status
torchvision-resnet50 64 2,857.31 3,158.05 -9.52% 🔴
torchvision-resnet50_fp16 64 2,091.14 6,678.10 -68.69% 🔴
torchvision-densenet121 32 2,609.90 2,705.33 -3.53%
torchvision-densenet121_fp16 32 4,469.61 4,480.31 -0.24%
torchvision-inceptionv3 32 1,768.12 1,772.37 -0.24%
torchvision-inceptionv3_fp16 32 2,742.57 2,613.31 4.95%
cadene-inceptionv4 16 821.80 444.89 84.72% 🔆
cadene-resnext64x4 16 772.40 412.50 87.25% 🔆
slim-mobilenet 64 7,675.79 8,419.17 -8.83% 🔴
slim-nasnetalarge 64 158.45 nan nan
slim-resnet50v2 64 3,309.53 1,641.82 101.58% 🔆
bert-mrpc-onnx 8 628.50 1,165.20 -46.06% 🔴
bert-mrpc-tf 1 491.35 492.10 -0.15%
pytorch-examples-wlang-gru 1 348.85 334.96 4.15%
pytorch-examples-wlang-lstm 1 468.32 469.54 -0.26%
torchvision-resnet50_1 1 775.16 760.64 1.91%
cadene-dpn92_1 1 453.23 457.65 -0.97%
cadene-resnext101_1 1 362.19 363.68 -0.41%
onnx-taau-downsample 1 383.08 401.93 -4.69%
dlrm-criteoterabyte 1 32.23 12.36 160.72% 🔆
dlrm-criteoterabyte_fp16 1 47.05 29.66 58.64% 🔆
agentmodel 1 7,762.11 10,523.13 -26.24% 🔴
unet_fp16 2 56.79 57.23 -0.76%
resnet50v1_fp16 1 955.18 959.87 -0.49%
resnet50v1_int8 1 569.59 942.92 -39.59% 🔴
bert_base_cased_fp16 64 1,098.38 1,092.47 0.54%
bert_large_uncased_fp16 32 201.30 345.19 -41.68% 🔴
bert_large_fp16 1 34.76 203.23 -82.90% 🔴
distilgpt2_fp16 16 2,095.26 2,096.77 -0.07%
yolov5s 1 558.49 564.74 -1.11%
tinyllama 1 45.98 46.00 -0.04%
vicuna-fastchat 1 43.95 44.04 -0.20%
whisper-tiny-encoder 1 257.71 419.55 -38.57% 🔴
whisper-tiny-decoder 1 406.75 414.85 -1.95%
llama2_7b 1 7.97 20.42 -60.94% 🔴
qwen1.5-7b 1 5.07 21.75 -76.68% 🔴
phi3-3.8b 1 10.00 26.81 -62.69% 🔴
llama3-8b 1 20.37 21.83 -6.69% 🔴
whisper-large-encoder 1 10.27 6.50 58.10% 🔆
whisper-large-decoder 1 11.95 106.80 -88.82% 🔴
mistral-7b 1 23.69 23.85 -0.67%
FLUX.1-schnell 1 753.68 763.88 -1.34%

Regressions detected 🔴

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

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
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-22 20:43:44.388671 [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

bugfix Fixes a bug found in the code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant