Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorder_slice_add_mul matcher #3478

Open
wants to merge 83 commits into
base: develop
Choose a base branch
from

Conversation

aarushjain29
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.17%. Comparing base (45b59bc) to head (3950cd3).
Report is 46 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #3478    +/-   ##
=========================================
  Coverage    92.16%   92.17%            
=========================================
  Files          512      513     +1     
  Lines        21403    21684   +281     
=========================================
+ Hits         19726    19987   +261     
- Misses        1677     1697    +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aarushjain29 aarushjain29 marked this pull request as draft September 26, 2024 17:13
@aarushjain29 aarushjain29 force-pushed the 3432-improve-simplify_algebra-to-find-more-horizontal-fusion-opportunities branch from 381540b to 69457bd Compare October 3, 2024 17:18
@aarushjain29 aarushjain29 requested a review from pfultz2 October 3, 2024 17:19
@aarushjain29 aarushjain29 marked this pull request as ready for review October 3, 2024 19:03
src/simplify_reshapes.cpp Outdated Show resolved Hide resolved
@pfultz2
Copy link
Collaborator

pfultz2 commented Oct 3, 2024

Unit tests needs to be added.

src/simplify_algebra.cpp Outdated Show resolved Hide resolved
@aarushjain29 aarushjain29 requested a review from pfultz2 October 30, 2024 15:48
@aarushjain29 aarushjain29 requested a review from pfultz2 November 27, 2024 21:34
migraphx::shape s1{migraphx::shape::int8_type, {1, 768, 768}};
migraphx::shape s2{migraphx::shape::int8_type, {1, 77, 768}};

std::vector<std::pair<migraphx::shape, int>> literals_info = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this.

literals.reserve(literals_info.size());
for(const auto& literal_info : literals_info)
{
literals.push_back(m1.add_literal(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the literal generation to the loop below.

migraphx::shape s1{migraphx::shape::int8_type, {1, 768, 768}};
migraphx::shape s2{migraphx::shape::int8_type, {1, 77, 768}};

std::vector<std::pair<migraphx::shape, int>> literals_info = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this as well, just generate the literal directly.

auto dot_i = m1.add_instruction(migraphx::make_op("dot"), a, literals[i * 2]);
auto add_i = m1.add_instruction(migraphx::make_op("add"), dot_i, literals[i * 2 + 1]);
add_results.push_back(add_i);
}
Copy link
Collaborator

@pfultz2 pfultz2 Dec 2, 2024

Choose a reason for hiding this comment

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

Literals should be generated in the loop:

        for(int i = 0; i < 3; ++i)
        {
            auto lit1 = m1.add_literal(migraphx::generate_literal(s1, i));
            auto lit2 = m1.add_literal(migraphx::generate_literal(s2, i));
            auto dot_i = m1.add_instruction(migraphx::make_op("dot"), a, lit1);
            auto add_i = m1.add_instruction(migraphx::make_op("add"), dot_i, lit2);
            add_results.push_back(add_i);
        }

auto add_final =
m1.add_instruction(migraphx::make_op("add"), dot_i, literals[4 + i * 2]);
final_add_results.push_back(add_final);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generate literals in the loop:

        for(int i = 0; i < 3; ++i)
        {
            auto lit1 = m1.add_literal(migraphx::generate_literal(s2, i));
            auto lit2 = m1.add_literal(migraphx::generate_literal(s1, i));
            auto lit3 = m1.add_literal(migraphx::generate_literal(s2, i + 3));
            auto add_i = m1.add_instruction(migraphx::make_op("add"), a, lit1);
            auto dot_i = m1.add_instruction(migraphx::make_op("dot"), add_i, lit2);
            auto add_final =
                m1.add_instruction(migraphx::make_op("add"), dot_i, lit3);
            final_add_results.push_back(add_final);
        }

@aarushjain29 aarushjain29 requested review from pfultz2 and removed request for CharlieL7 and kahmed10 December 3, 2024 22:48
@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
0d99d2
Rate old
871fd5
Diff Compare
torchvision-resnet50 64 3,255.89 3,258.37 -0.08%
torchvision-resnet50_fp16 64 6,986.11 6,985.89 0.00%
torchvision-densenet121 32 2,435.59 2,434.83 0.03%
torchvision-densenet121_fp16 32 4,075.57 4,096.10 -0.50%
torchvision-inceptionv3 32 1,636.73 1,628.27 0.52%
torchvision-inceptionv3_fp16 32 2,757.43 2,743.48 0.51%
cadene-inceptionv4 16 776.22 765.47 1.40%
cadene-resnext64x4 16 810.14 808.90 0.15%
slim-mobilenet 64 7,533.63 7,462.01 0.96%
slim-nasnetalarge 64 211.53 208.42 1.49%
slim-resnet50v2 64 3,504.76 3,439.75 1.89%
bert-mrpc-onnx 8 1,144.61 1,150.01 -0.47%
bert-mrpc-tf 1 467.21 480.28 -2.72%
pytorch-examples-wlang-gru 1 534.67 417.96 27.92% 🔆
pytorch-examples-wlang-lstm 1 393.46 381.48 3.14% 🔆
torchvision-resnet50_1 1 788.10 785.76 0.30%
cadene-dpn92_1 1 398.61 436.17 -8.61% 🔴
cadene-resnext101_1 1 382.93 382.70 0.06%
onnx-taau-downsample 1 342.47 345.53 -0.88%
dlrm-criteoterabyte 1 33.34 33.33 0.02%
dlrm-criteoterabyte_fp16 1 52.72 52.73 -0.02%
agentmodel 1 9,410.44 8,218.68 14.50% 🔆
unet_fp16 2 58.83 58.88 -0.08%
resnet50v1_fp16 1 939.59 921.67 1.94%
resnet50v1_int8 1 1,035.51 1,011.55 2.37%
bert_base_cased_fp16 64 1,171.13 1,168.76 0.20%
bert_large_uncased_fp16 32 363.77 363.10 0.18%
bert_large_fp16 1 200.44 200.24 0.10%
distilgpt2_fp16 16 2,199.13 2,194.57 0.21%
yolov5s 1 544.28 530.30 2.64%
tinyllama 1 43.38 43.40 -0.05%
vicuna-fastchat 1 175.14 168.83 3.74% 🔆
whisper-tiny-encoder 1 416.41 417.90 -0.36%
whisper-tiny-decoder 1 436.98 427.53 2.21%

This build is not recommended to merge 🔴

@migraphx-bot
Copy link
Collaborator


     ✅ 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

     ✅ torchvision-resnet50_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-dpn92_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-resnext101_1: 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve simplify_algebra to find more horizontal fusion opportunities
7 participants