Skip to content

Slice over dynamic dimension#5015

Open
CharlieL7 wants to merge 8 commits into
developfrom
slice_over_dyn_dim
Open

Slice over dynamic dimension#5015
CharlieL7 wants to merge 8 commits into
developfrom
slice_over_dyn_dim

Conversation

@CharlieL7

@CharlieL7 CharlieL7 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Need to slice over a dynamic dimension for handling instructions after NMS for RCNN and SSD models.

Technical Details

  • 1 arg slice over a dynamic dimension makes it go to {0, interval.max}

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.

@CharlieL7 CharlieL7 self-assigned this Jun 26, 2026
@CharlieL7 CharlieL7 requested a review from causten as a code owner June 26, 2026 17:30
Copilot AI review requested due to automatic review settings June 26, 2026 17:30

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 updates MIGraphX’s slice op shape inference to support slicing over non-fixed dynamic dimensions (notably needed for post-NMS workloads), by relaxing sliced axes to {0, interval.max} for the 1-input/attribute-only slice form, and it expands the shape-test coverage accordingly.

Changes:

  • Allow 1-arg slice on non-fixed dynamic (range) axes by returning an over-approximated output dynamic dimension {0, max}.
  • Keep rejecting the same case for symbolic shapes (explicit throw).
  • Update and add slice dynamic-shape tests to reflect and validate the new behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/op_shape_test.cpp Updates expectations for non-fixed dynamic slicing and adds several new shape tests around the relax behavior.
src/include/migraphx/op/slice.hpp Changes 1-arg slice shape inference to relax sliced non-fixed dynamic axes (and throws for symbolic).

Comment on lines 276 to +280
if(input_shape.dynamic() and std::any_of(axes.begin(), axes.end(), [&](auto axis) {
return not input_shape.dyn_dims()[axis].is_fixed();
}))
{
MIGRAPHX_THROW("SLICE 1_arg: slicing is not allowed on non-fixed dynamic input axis ");
if(input_shape.symbolic())

@CharlieL7 CharlieL7 Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, there is no at() for dynamic_dimensions.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5015      +/-   ##
===========================================
+ Coverage    92.71%   92.72%   +0.01%     
===========================================
  Files          594      596       +2     
  Lines        31482    31739     +257     
===========================================
+ Hits         29187    29427     +240     
- Misses        2295     2312      +17     
Files with missing lines Coverage Δ
src/include/migraphx/op/slice.hpp 95.65% <100.00%> (+0.15%) ⬆️

... and 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 27, 2026

Copy link
Copy Markdown
Test Batch New Rate (738864) Old Rate (329ef6)* Diff Status
torchvision-resnet50 64 3,139.21 3,143.14 -0.13%
torchvision-resnet50_fp16 64 6,628.55 6,637.41 -0.13%
torchvision-densenet121 32 2,695.83 2,699.01 -0.12%
torchvision-densenet121_fp16 32 4,521.31 4,543.28 -0.48%
torchvision-inceptionv3 32 1,796.70 1,799.41 -0.15%
torchvision-inceptionv3_fp16 32 2,820.78 2,829.91 -0.32%
cadene-inceptionv4 16 824.10 825.10 -0.12%
cadene-resnext64x4 16 783.13 784.56 -0.18%
slim-mobilenet 64 8,391.62 8,397.73 -0.07%
slim-nasnetalarge 64 228.35 229.43 -0.47%
slim-resnet50v2 64 3,314.04 3,165.14 4.70%
bert-mrpc-onnx 8 1,171.35 1,171.26 0.01%
bert-mrpc-tf 1 489.18 487.89 0.26%
pytorch-examples-wlang-gru 1 342.05 337.82 1.25%
pytorch-examples-wlang-lstm 1 449.14 451.89 -0.61%
torchvision-resnet50_1 1 742.52 760.88 -2.41%
cadene-dpn92_1 1 450.57 452.85 -0.50%
cadene-resnext101_1 1 363.57 366.12 -0.70%
onnx-taau-downsample 1 400.40 399.97 0.11%
dlrm-criteoterabyte 1 32.44 32.45 -0.02%
dlrm-criteoterabyte_fp16 1 51.86 51.82 0.08%
agentmodel 1 9,865.63 9,075.15 8.71% 🔆
unet_fp16 2 56.92 57.00 -0.15%
resnet50v1_fp16 1 935.16 1,004.11 -6.87% 🔴
resnet50v1_int8 1 936.89 937.38 -0.05%
bert_base_cased_fp16 64 1,098.01 1,098.97 -0.09%
bert_large_uncased_fp16 32 346.54 346.79 -0.07%
bert_large_fp16 1 205.15 203.89 0.62%
distilgpt2_fp16 16 2,089.11 2,093.62 -0.22%
yolov5s 1 566.37 596.36 -5.03% 🔴
tinyllama 1 45.97 46.01 -0.08%
vicuna-fastchat 1 44.05 44.08 -0.09%
whisper-tiny-encoder 1 417.16 418.47 -0.31%
whisper-tiny-decoder 1 413.88 413.94 -0.01%
llama2_7b 1 20.34 20.36 -0.09%
qwen1.5-7b 1 23.59 23.61 -0.09%
phi3-3.8b 1 26.77 26.70 0.25%
llama3-8b 1 21.76 21.78 -0.10%
whisper-large-encoder 1 10.28 10.28 -0.03%
whisper-large-decoder 1 105.75 106.27 -0.49%
mistral-7b 1 23.76 23.81 -0.21%
FLUX.1-schnell 1 751.02 761.81 -1.42%

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 27, 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
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-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

CharlieL7 and others added 2 commits June 29, 2026 12:08
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants