Skip to content

[ET-VK][convolution] Nest convolution sources by route - #23492

Open
SS-JIA wants to merge 4 commits into
gh/SS-JIA/659/basefrom
gh/SS-JIA/659/head
Open

SS-JIA wants to merge 4 commits into
gh/SS-JIA/659/basefrom
gh/SS-JIA/659/head

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Ulterior Motive

Organize Vulkan operators by implementation family so operators with multiple routes can use clear, scalable directory layouts.

Rationale

What: Move convolution C++ implementations, GLSL templates, YAML variant definitions, and convolution-only shader headers under convolution/ in both impl/ and glsl/, split into conv1d/ and conv2d/. Split the monolithic Convolution.cpp and Q8taConv2d.{h,cpp} so each file holds either routing logic or a single implementation route.

Why: Convolution is implemented through several routes (direct, depthwise, pointwise, im2col/GEMM, transposed), and the q8ta quantized family repeats most of them. In the flat directories their sources were interleaved by name, and single files mixed routing with several route implementations. This prepares for adding further routes such as Winograd.

Details

  • Layout (impl/ and glsl/ mirror each other)
    • convolution/: Convolution.{h,cpp} registers aten.convolution and dispatches to conv1d or conv2d by input rank; it also holds prepack_biases and check_conv_args, used by both.
    • convolution/conv1d/: Conv1d.{h,cpp} (conv1d_impl routing), Conv1dDirect.{h,cpp}, Conv1dDW.cpp, Conv1dPW.cpp, and the conv1d shaders.
    • convolution/conv2d/: Conv2d.{h,cpp} (conv2d_impl routing, Conv2dMethod, resize_conv2d_node), Conv2dDirect.{h,cpp} (direct and transposed shader dispatch), Conv2dDW.cpp, Conv2dPW.cpp, ConvolutionUtils.h, conv2d_common.glslh, and the direct/depthwise/pointwise shaders.
    • convolution/conv2d/{im2col,transposed}/: im2col/GEMM sources and shaders; transposed shaders.
    • convolution/conv2d/q8ta/: Q8taConv2d.{h,cpp} (q8ta_conv2d routing and the im2col heuristic, formerly Q8taConv2dRoute), Q8taConv2dCommon.{h,cpp} (ActivationType, packed-dim checks), Q8taConv2dDirect.{h,cpp} (general route), Q8taConv2dDW.{h,cpp}, Q8taConv2dPW.{h,cpp}, plus im2col/ and transposed/. Each route has its own header; consumers include only what they use.
    • convolution/conv2d/quantized_legacy/: QuantizedConvolution.{h,cpp} and its shaders and headers.
    • Weight packing shaders sit in pack_weights/ subdirectories of the route that dispatches them (conv2d/, conv2d/im2col/, conv2d/q8ta/, conv2d/transposed/).
  • Naming
    • Functions that add a DynamicDispatchNode are named add_*_node(); functions that call add_*_node() to implement an operator are named *_impl(). Registered operator names are unchanged.
    • add_conv2d_node is folded into conv2d_impl. Its test-only force_direct flag is removed; the conv2d test's direct selector calls conv2d_direct_impl directly, which is equivalent for its sliding-window cases.
  • Includes
    • Route shaders include conv2d_common.glslh unchanged through ancestor include resolution.
    • Root shaders quantize_and_pack_4w4c and unpack_4w4c_and_dequantize include convolution/conv2d/conv2d_common.glslh.
    • Headers shared with other operator families (linear_*, conv2d_fp_input_tile_load.glslh, indexing headers) stay at the shader root.
  • Moved files are recorded as renames; files split from or merged into another file are recorded as copies of their source, so reviews show moved code as unchanged.
  • Moving code into new files exposes it to CLANGTIDY, so its findings there are fixed: utils::safe_downcast<int32_t> for narrowing, (void) for unused parameters, an anonymous namespace for the file-local Conv2dParams, and removal of an unused ShaderNameUtils.h include.

Generated shader names and runtime dispatch behavior are unchanged.

Differential Revision: D123450342

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23492

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 2d2348a with merge base bdb489e (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]

This branch was successfully deployed

1 active deployment
cadence — 2d2348a7 Deployed Oct 10, 2026 by SS-JIA via hifi-op-test / hifi4 #32855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant