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

Rewrite 1x1 convolutions to gemm #3568

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

Rewrite 1x1 convolutions to gemm #3568

wants to merge 19 commits into from

Conversation

pfultz2
Copy link
Collaborator

@pfultz2 pfultz2 commented Oct 29, 2024

This allows us to use rocblas for some gemms.

@pfultz2 pfultz2 requested a review from causten as a code owner October 29, 2024 14:31
@pfultz2 pfultz2 requested review from kahmed10, shivadbhavsar and CharlieL7 and removed request for causten October 29, 2024 14:31
if(not all_of(v.at("dilation"), [](const value& x) { return x.to<std::size_t>() == 1; }))
return false;
auto w = ins->inputs().at(1)->get_shape();
return std::all_of(w.lens().begin() + 2, w.lens().end(), [](std::size_t i) { return i == 1; });
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worthwhile to have a 1x1x1 test case too since its allowed here to make sure it generalizes to the 3D case

@pfultz2
Copy link
Collaborator Author

pfultz2 commented Oct 31, 2024

Need to investigate the nasnet failure.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (aeb2047) to head (0374a01).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3568      +/-   ##
===========================================
+ Coverage    92.18%   92.19%   +0.01%     
===========================================
  Files          513      515       +2     
  Lines        21596    21639      +43     
===========================================
+ Hits         19908    19951      +43     
  Misses        1688     1688              

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


🚨 Try these New Features:

Copy link
Collaborator

@CharlieL7 CharlieL7 left a comment

Choose a reason for hiding this comment

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

LGTM. Is this the only case where doing a convolution as a GEMM is beneficial? Technically any convolution can be done as a GEMM.

@pfultz2
Copy link
Collaborator Author

pfultz2 commented Nov 11, 2024

LGTM. Is this the only case where doing a convolution as a GEMM is beneficial? Technically any convolution can be done as a GEMM.

For other sizes, we need to do windowing(and possibly some padding) which will require an extra copy when we reshape to a gemm, with tensors that are larger then the original input.

@causten
Copy link
Collaborator

causten commented Nov 13, 2024

I cant merge this with the amount of perf regressions

@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
0374a0
Rate old
0ad807
Diff Compare
torchvision-resnet50 64 3,122.29 3,239.44 -3.62% 🔴
torchvision-resnet50_fp16 64 6,651.52 6,989.98 -4.84% 🔴
torchvision-densenet121 32 2,427.28 2,435.40 -0.33%
torchvision-densenet121_fp16 32 4,080.58 4,083.28 -0.07%
torchvision-inceptionv3 32 1,622.52 1,630.36 -0.48%
torchvision-inceptionv3_fp16 32 2,718.13 2,743.98 -0.94%
cadene-inceptionv4 16 749.03 765.72 -2.18%
cadene-resnext64x4 16 678.00 811.01 -16.40% 🔴
slim-mobilenet 64 7,401.44 7,471.20 -0.93%
slim-nasnetalarge 64 182.24 208.50 -12.60% 🔴
slim-resnet50v2 64 3,236.34 3,438.88 -5.89% 🔴
bert-mrpc-onnx 8 1,153.34 1,147.12 0.54%
bert-mrpc-tf 1 494.02 469.98 5.12% 🔆
pytorch-examples-wlang-gru 1 417.42 416.34 0.26%
pytorch-examples-wlang-lstm 1 386.63 463.26 -16.54% 🔴
torchvision-resnet50_1 1 713.48 770.23 -7.37% 🔴
cadene-dpn92_1 1 407.35 399.89 1.87%
cadene-resnext101_1 1 325.37 382.62 -14.96% 🔴
onnx-taau-downsample 1 345.82 345.09 0.21%
dlrm-criteoterabyte 1 33.34 33.34 -0.01%
dlrm-criteoterabyte_fp16 1 52.73 52.72 0.01%
agentmodel 1 8,196.05 10,261.49 -20.13% 🔴
unet_fp16 2 58.72 58.87 -0.26%
resnet50v1_fp16 1 867.75 982.51 -11.68% 🔴
resnet50v1_int8 1 1,008.79 1,007.17 0.16%
bert_base_cased_fp16 64 1,169.18 1,169.34 -0.01%
bert_large_uncased_fp16 32 355.07 363.46 -2.31%
bert_large_fp16 1 192.58 198.15 -2.81%
distilgpt2_fp16 16 2,198.25 2,201.47 -0.15%
yolov5s 1 525.41 536.48 -2.06%
tinyllama 1 43.38 43.38 0.01%
vicuna-fastchat 1 179.54 172.97 3.80% 🔆
whisper-tiny-encoder 1 418.61 418.04 0.14%
whisper-tiny-decoder 1 425.66 423.83 0.43%

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants