[ExecuTorch][WebGPU] select_copy op test suite (cases.py op-test framework) by pytorchbot · Pull Request #20539 · pytorch/executorch · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[ExecuTorch][WebGPU] sigmoid op test suite (cases.py op-test framework)
Pull Request resolved: #20391

Registers `aten.sigmoid.default` in the `cases.py` op-test framework: a `_sigmoid_suite` (hard-coded shapes + a saturation case over a `linspace(-12, 12)` input) that `generate_op_tests` exports and compares to an fp64 torch golden on Dawn. Also adds `test/ops/sigmoid/test_sigmoid.py` (`SigmoidModule` + `N` + `_det_input` + an export-delegation/eager smoke test) and the `aten.sigmoid.default` partitioner-allowlist entry in `tester.py`.
ghstack-source-id: 397026520
@exported-using-ghexport

Differential Revision: [D108793159](https://our.internmc.facebook.com/intern/diff/D108793159/)
  • Loading branch information
JCNTH committed Jun 26, 2026
commit f704117396acd002e821f4f3e7d1dd9dd8c44dcf
31 changes: 31 additions & 0 deletions backends/webgpu/test/op_tests/cases.py
51 changes: 51 additions & 0 deletions backends/webgpu/test/ops/test_sigmoid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""`aten.sigmoid.default` module + input for the WebGPU op-test framework.

`SigmoidModule`, `N`, and `_det_input` are imported by `cases.py` to drive the
declarative op-test suite. `SigmoidTest` is the export-delegation
smoke test. Sigmoid is on the Llama critical path (`F.silu` -> `sigmoid` + `mul`); the
deterministic input spans the saturation tails.
"""

import unittest

import torch

from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner
from executorch.exir import to_edge_transform_and_lower

# Input length; the deterministic input spans the saturation tails.
N = 64


class SigmoidModule(torch.nn.Module):
def forward(self, x: torch.Tensor) -> torch.Tensor:
return torch.sigmoid(x)


def _det_input() -> torch.Tensor:
"""Deterministic fp32 input spanning negatives, zero, and large magnitudes."""
return torch.linspace(-12.0, 12.0, N, dtype=torch.float32)


def _export(m: torch.nn.Module, x: torch.Tensor):
ep = torch.export.export(m, (x,))
return to_edge_transform_and_lower(
ep, partitioner=[VulkanPartitioner()]
).to_executorch()


class SigmoidTest(unittest.TestCase):
def test_export_delegates(self) -> None:
et = _export(SigmoidModule().eval(), _det_input())
found = any(
d.id == "VulkanBackend"
for plan in et.executorch_program.execution_plan
for d in plan.delegates
)
self.assertTrue(found, "Expected a VulkanBackend delegate (sigmoid)")
1 change: 1 addition & 0 deletions backends/webgpu/test/tester.py