Skip to content

Commit 1b4ac3a

Browse files
committed
[ExecuTorch][WebGPU] Glob runtime/ops sources in CMakeLists
Pull Request resolved: #21005 Replace the hand-maintained explicit `WEBGPU_SRCS` op-handler list with `file(GLOB WEBGPU_OP_SRCS CONFIGURE_DEPENDS runtime/ops/*/*.cpp)` so adding a new op no longer requires editing this file (addresses review feedback). The five `runtime/*.cpp` sources and `runtime/ops/OperatorRegistry.cpp` (which sits directly under `ops/`, not a per-op subdir) stay explicit. `CONFIGURE_DEPENDS` re-globs at build time when op sources are added or removed. The glob resolves to exactly the 40 op handlers the explicit list enumerated (verified set-equal) — no op added or dropped, and static-init registration is order-independent under `--whole-archive`. Co-authored-with: Claude Code. ghstack-source-id: 405026115 @exported-using-ghexport Differential Revision: [D112482039](https://our.internmc.facebook.com/intern/diff/D112482039/)
1 parent 975a306 commit 1b4ac3a

1 file changed

Lines changed: 10 additions & 46 deletions

File tree

backends/webgpu/CMakeLists.txt

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,18 @@ if(NOT TARGET vulkan_schema)
2626
endif()
2727

2828
set(WEBGPU_SRCS
29-
runtime/WebGPUBackend.cpp
30-
runtime/WebGPUGraph.cpp
31-
runtime/WebGPUDelegateHeader.cpp
32-
runtime/WebGPUDevice.cpp
33-
runtime/WebGPUQueryPool.cpp
34-
runtime/ops/OperatorRegistry.cpp
35-
runtime/ops/add/BinaryOp.cpp
36-
runtime/ops/rms_norm/RmsNorm.cpp
37-
runtime/ops/update_cache/UpdateCache.cpp
38-
runtime/ops/sdpa/Sdpa.cpp
39-
runtime/ops/select_as_symint/SelectAsSymint.cpp
40-
runtime/ops/quantized_linear/QuantizedLinear.cpp
41-
runtime/ops/quantized_linear/QuantizedLinearBackward.cpp
42-
runtime/ops/mul/BinaryOp.cpp
43-
runtime/ops/embedding_q4gsw/EmbeddingQ4gsw.cpp
44-
runtime/ops/rope/RotaryEmbedding.cpp
45-
runtime/ops/prepack/Prepack.cpp
46-
runtime/ops/view_copy/ViewCopy.cpp
47-
runtime/ops/select/Select.cpp
48-
runtime/ops/sigmoid/UnaryOp.cpp
49-
runtime/ops/squeeze/Squeeze.cpp
50-
runtime/ops/unsqueeze/Unsqueeze.cpp
51-
runtime/ops/slice/Slice.cpp
52-
runtime/ops/permute/Permute.cpp
53-
runtime/ops/cat/Cat.cpp
54-
runtime/ops/index/Index.cpp
55-
runtime/ops/sdpa_fd_decode/SdpaFdDecode.cpp
56-
runtime/ops/mm/Mm.cpp
57-
runtime/ops/fused_ce/FusedCe.cpp
58-
runtime/ops/log_softmax/LogSoftmax.cpp
59-
runtime/ops/softmax/Softmax.cpp
60-
runtime/ops/bmm/Bmm.cpp
61-
runtime/ops/reduce/Reduce.cpp
62-
runtime/ops/div/BinaryOp.cpp
63-
runtime/ops/sub/BinaryOp.cpp
64-
runtime/ops/where/Where.cpp
65-
runtime/ops/boolean_op/BooleanOp.cpp
66-
runtime/ops/gather/Gather.cpp
67-
runtime/ops/expand_copy/ExpandCopy.cpp
68-
runtime/ops/fill/Fill.cpp
69-
runtime/ops/dim_order/DimOrder.cpp
70-
runtime/ops/linear/Linear.cpp
71-
runtime/ops/embedding/Embedding.cpp
72-
runtime/ops/adamw/AdamwStep.cpp
73-
runtime/ops/quantized_linear/LinearDw.cpp
74-
runtime/ops/quantized_linear/QuantizedLinearRequant.cpp
29+
runtime/WebGPUBackend.cpp runtime/WebGPUGraph.cpp
30+
runtime/WebGPUDelegateHeader.cpp runtime/WebGPUDevice.cpp
31+
runtime/WebGPUQueryPool.cpp runtime/ops/OperatorRegistry.cpp
7532
)
7633

34+
# Op handlers: glob so adding an op needs no CMakeLists edit. CONFIGURE_DEPENDS
35+
# re-globs at build time when op sources are added or removed.
36+
file(GLOB WEBGPU_OP_SRCS CONFIGURE_DEPENDS
37+
"${CMAKE_CURRENT_SOURCE_DIR}/runtime/ops/*/*.cpp"
38+
)
39+
list(APPEND WEBGPU_SRCS ${WEBGPU_OP_SRCS})
40+
7741
add_library(webgpu_backend ${WEBGPU_SRCS})
7842

7943
# Verify committed *_wgsl.h match their *.wgsl (drift fails the build).

0 commit comments

Comments
 (0)