Skip to content

[ET-VK][unary] Compute vec4 leaky_relu with a single mix - #24824

Merged
SS-JIA merged 1 commit into
gh/SS-JIA/699/origfrom
gh/SS-JIA/700/orig
Nov 10, 2026
Merged

SS-JIA merged 1 commit into
gh/SS-JIA/699/origfrom
gh/SS-JIA/700/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: #24813 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/700/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/700/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/699/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/700/orig
Differential Revision: D130740220
@diff-train-skip-merge

Pull Request resolved: #24813

## Ulterior Motive

RIFE's conv + residual + LeakyReLU blocks now lower to `et_vk.conv2d.with_epilogue`, which replaces the explicit `conv2d_residual_lrelu` / `conv2d_lrelu` ops. On Galaxy S23, direct convs with the generic epilogue ran 5–10% slower than with hardcoded `leaky_relu(conv + residual)` math. The leaky_relu formula accounts for most of that gap.

## Rationale

**What**: `leaky_relu(vec4)` now selects between `x` and `x * slope` with one `mix`. The scalar overload, now unused, is removed.

**Why**: The old form evaluated `x * (float(x > 0) + slope * float(x <= 0))` once per component: two compares, two conversions and two multiplies per lane. The conv2d epilogue applies it to every output texel, and the unary operators share the header.

## Details

- Outputs are identical for finite slopes, including at ±0, ±inf and NaN.
- On the RIFE residual configuration, the conv2d SPIR-V drops to:
  - Adreno: about 96 ALU instructions;
  - Mali-G715: 0.5 arithmetic cycles, about 6%.

Differential Revision: [D130740220](https://our.internmc.facebook.com/intern/diff/D130740220/)
ghstack-source-id: 469036232
@pytorchbot
pytorchbot requested a review from SS-JIA as a code owner November 10, 2026 02:41
@pytorch-bot

pytorch-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 8 Pending

As of commit 54d587b with merge base e5ffebe (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 Nov 10, 2026
@SS-JIA
SS-JIA added this pull request to stack #24825 November 10, 2026 03:16
@SS-JIA
SS-JIA merged commit bffe24d into main Nov 10, 2026
223 of 229 checks passed
@SS-JIA
SS-JIA deleted the gh/SS-JIA/700/orig branch November 10, 2026 03:18

This branch was previously deployed

1 inactive deployment
cadence — 54d587b1 Deployed Nov 10, 2026 by pytorchbot via hifi-op-test / hifi4 #37526
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