optimized matrix multiplication, bmm (#3343)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/3343 We extend the current implementation of `mm` in the following manner - if the input is `WIDTH_PACKED`, we use the current ET implementation by SS-JIA. The shader is renamed from `matmul` into `matmul_naive` - if the input is `CHANNEL_PACKED`, we port the [efficient 2d `mm` algorithm](https://github.com/pytorch/pytorch/pull/112918?fbclid=IwAR2wFuh--eEEkrFjG9qPWNE8wVU5hO9e7824XdWC1BdZMAk3f8xT8EpyhHc) by liuk22 and yipjustin into ExecuTorch where the shader is named as `matmul_optimed`. Moreover, we extend it into 3d input, therefore `bmm` is naturally supported. This simplified the LI implementation of `bmm` and reduces memory usage by about 75% (LI [reshapes the output into 4d and resort to slicing at the end](https://www.internalfb.com/code/fbsource/[4b3676629ea80c3c4b9de2d02290788a12a307ea]/fbcode/caffe2/aten/src/ATen/native/vulkan/ops/Mm.cpp?lines=817-825%2C871-872)). Reviewed By: SS-JIA Differential Revision: D56497832 fbshipit-source-id: ecf2cb8c9de4ad7fe7f7bcfeacf9462150348d2b
W
Wei Lu committed
7109df4b190ed75882ecbe3168fcb4eefaf18cd2
Parent: c001f59
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 5/7/2024, 10:29:28 PM