Skip to content

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

Closed
pytorchbot wants to merge 1 commit into
gh/SS-JIA/658/origfrom
gh/SS-JIA/659/orig
Closed

pytorchbot wants to merge 1 commit into
gh/SS-JIA/658/origfrom
gh/SS-JIA/659/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #23492 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/659/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/659/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/658/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/659/orig
Differential Revision: D123450342
@diff-train-skip-merge

Pull Request resolved: #23492

## 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.
ghstack-source-id: 446951717
@exported-using-ghexport

Differential Revision: [D123450342](https://our.internmc.facebook.com/intern/diff/D123450342/)
@pytorchbot
pytorchbot requested a review from SS-JIA as a code owner October 13, 2026 01:39
@pytorch-bot

pytorch-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 13, 2026
@SS-JIA SS-JIA closed this Oct 13, 2026

This branch was successfully deployed

1 active deployment
cadence — d312aeac Deployed Oct 13, 2026 by pytorchbot via hifi-op-test / hifi4 #33012
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants