[ExecuTorch][WebGPU] Port clamp + hardtanh (clamp-family unary ops)#21156
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21156
Note: Links to docs will display an error until the docs builds have been completed. ❌ 5 New FailuresAs of commit c57c0c5 with merge base 4a26c64 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
psiddh
left a comment
There was a problem hiding this comment.
Approving full WebGPU stack
9feadfe
into
gh/JCNTH/116/base
Pull Request resolved: #21156 Ports the Vulkan delegate's clamp-family activations. `clamp` and `hardtanh` share one `clamp(x, min, max)` shader (mirroring how Vulkan reuses its clamp shader for both), built on the shared unary helper. Bounds come from the op's scalar args, with `None -> +/-inf` matching Vulkan `get_val_or_inf` (`backends/vulkan/runtime/graph/ops/impl/UnaryOp.cpp:72`). Key changes: - `runtime/ops/unary/clamp.wgsl` (+ generated `_wgsl.h`) — `output[idx] = clamp(input[idx], params.minimum, params.maximum)`; the `minimum`/`maximum` member names mirror Vulkan `unary_op.glsl`. - `runtime/ops/unary/Activations.cpp` — `clamp_impl` / `hardtanh_impl` (args `[in, min, max, out]`) + `get_val_or_inf` (reads an Int/Double scalar, substitutes `+/-inf` for `None`, throws on any other type). - `runtime/ops/unary/UnaryOp.cpp` — the shared helper now rejects int operands (fail-loud): the fp32-only backend would otherwise reinterpret int bits as f32, and `clamp` is the one unary the Vulkan partitioner (`op_registry.py`) tags for integer tensors. `relu6` is excluded: the Vulkan partitioner does not tag it, so it cannot be delegated without a separate partitioner change. ghstack-source-id: 406360830 @exported-using-ghexport Differential Revision: [D112257672](https://our.internmc.facebook.com/intern/diff/D112257672/)
Pull Request resolved: #21156 Ports the Vulkan delegate's clamp-family activations. `clamp` and `hardtanh` share one `clamp(x, min, max)` shader (mirroring how Vulkan reuses its clamp shader for both), built on the shared unary helper. Bounds come from the op's scalar args, with `None -> +/-inf` matching Vulkan `get_val_or_inf` (`backends/vulkan/runtime/graph/ops/impl/UnaryOp.cpp:72`). Key changes: - `runtime/ops/unary/clamp.wgsl` (+ generated `_wgsl.h`) — `output[idx] = clamp(input[idx], params.minimum, params.maximum)`; the `minimum`/`maximum` member names mirror Vulkan `unary_op.glsl`. - `runtime/ops/unary/Activations.cpp` — `clamp_impl` / `hardtanh_impl` (args `[in, min, max, out]`) + `get_val_or_inf` (reads an Int/Double scalar, substitutes `+/-inf` for `None`, throws on any other type). - `runtime/ops/unary/UnaryOp.cpp` — the shared helper now rejects int operands (fail-loud): the fp32-only backend would otherwise reinterpret int bits as f32, and `clamp` is the one unary the Vulkan partitioner (`op_registry.py`) tags for integer tensors. `relu6` is excluded: the Vulkan partitioner does not tag it, so it cannot be delegated without a separate partitioner change. ghstack-source-id: 406360830 @exported-using-ghexport Differential Revision: [D112257672](https://our.internmc.facebook.com/intern/diff/D112257672/)
Pull Request resolved: #21156 Ports the Vulkan delegate's clamp-family activations. `clamp` and `hardtanh` share one `clamp(x, min, max)` shader (mirroring how Vulkan reuses its clamp shader for both), built on the shared unary helper. Bounds come from the op's scalar args, with `None -> +/-inf` matching Vulkan `get_val_or_inf` (`backends/vulkan/runtime/graph/ops/impl/UnaryOp.cpp:72`). Key changes: - `runtime/ops/unary/clamp.wgsl` (+ generated `_wgsl.h`) — `output[idx] = clamp(input[idx], params.minimum, params.maximum)`; the `minimum`/`maximum` member names mirror Vulkan `unary_op.glsl`. - `runtime/ops/unary/Activations.cpp` — `clamp_impl` / `hardtanh_impl` (args `[in, min, max, out]`) + `get_val_or_inf` (reads an Int/Double scalar, substitutes `+/-inf` for `None`, throws on any other type). - `runtime/ops/unary/UnaryOp.cpp` — the shared helper now rejects int operands (fail-loud): the fp32-only backend would otherwise reinterpret int bits as f32, and `clamp` is the one unary the Vulkan partitioner (`op_registry.py`) tags for integer tensors. `relu6` is excluded: the Vulkan partitioner does not tag it, so it cannot be delegated without a separate partitioner change. ghstack-source-id: 406360830 @exported-using-ghexport Differential Revision: [D112257672](https://our.internmc.facebook.com/intern/diff/D112257672/)
Stack from ghstack (oldest at bottom):
Ports the Vulkan delegate's clamp-family activations.
clampandhardtanhshare oneclamp(x, min, max)shader (mirroring how Vulkan reuses its clamp shader for both), built on the shared unary helper. Bounds come from the op's scalar args, withNone -> +/-infmatching Vulkanget_val_or_inf(backends/vulkan/runtime/graph/ops/impl/UnaryOp.cpp:72).Key changes:
runtime/ops/unary/clamp.wgsl(+ generated_wgsl.h) —output[idx] = clamp(input[idx], params.minimum, params.maximum); theminimum/maximummember names mirror Vulkanunary_op.glsl.runtime/ops/unary/Activations.cpp—clamp_impl/hardtanh_impl(args[in, min, max, out]) +get_val_or_inf(reads an Int/Double scalar, substitutes+/-infforNone, throws on any other type).runtime/ops/unary/UnaryOp.cpp— the shared helper now rejects int operands (fail-loud): the fp32-only backend would otherwise reinterpret int bits as f32, andclampis the one unary the Vulkan partitioner (op_registry.py) tags for integer tensors.relu6is excluded: the Vulkan partitioner does not tag it, so it cannot be delegated without a separate partitioner change.@exported-using-ghexport
Differential Revision: D112257672
Differential Revision: D112257672