metal : add CONV_2D_DW (depthwise convolution) support#21565
Conversation
|
Hi @Sou-ly, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
FWIW, I tested this locally on an Apple M1 iMac at PR head The dedicated backend op test looks good here: I also ran the full backend test suite on the PR head, and once more after a clean no-commit merge with current For my downstream ASR path, I tried a few local-only depthwise-conv shapes that show up in encoder-style workloads:
I also did a quick local check of the F16-weight Metal path by comparing Metal F16-kernel output against Metal F32-kernel output, using F16-representable weights. The 13 cases I tried all matched exactly ( One caveat: the large synthetic |
|
Thanks for the detailed testing @QuintinShaw! I reworked the Metal dispatch based on your feedback — 3D grid for the standard path, and a separate channel-tiled kernel for non-contiguous layouts (CWHN). Here are updated numbers on an M5:
The large |
|
I added some F16 tests that are failing. |
|
@ggerganov thanks for the F16 tests, the CPU backend was reading F16 kernel weights as float (casting raw bytes), fixed in 365c8c1. Metal side was already handling it via the TK template. All 8 tests pass now. |
|
@Sou-ly Could you take a look why these This is the branch: ggml-org/ggml#1558 |
Summary
GGML_OP_CONV_2D_DW(depthwise 2D convolution), used by MobileNet/EfficientNet-style architecturesPerformance (Apple M5)
[19,30,128,1][7,7,1,128][19,30,128,1][7,7,1,128][24,1,128,1][15,1,1,128][24,1,256,1][31,1,1,256][24,1,256,1][31,1,1,256][512,512,256,1][3,3,1,256][512,512,256,1][3,3,1,256][112,112,32,1][3,3,1,32][112,112,32,1][3,3,1,32][56,56,128,1][5,5,1,128][56,56,128,1][5,5,1,128]Test plan
test-backend-ops test -o CONV_2D_DW— 4/4 tests pass on Metal (both WHCN and CWHN layouts)AI usage disclosure
Yes: PR description (partial), code cleanup and template implementations for different data formats than FP32. Same as my implementation of ADD1 #21267