Repository navigation
Conversation
mshr-h
force-pushed
the
add-aten-complex-out
branch
from
October 30, 2026 09:21
f04e979 to
c2763d9
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking approval of the complex operator support.
No open issues 🎉
What changed in this PR
Enables torch.complex(real, imag) through default Edge export and CPU execution, addressing #24328 for matching FP16, FP32, and FP64 inputs.
Changes:
- Adds a portable
complex.outkernel with broadcasting, output resizing, and default dimension-order validation. - Registers the operator and adds complex32 dtype mapping plus a temporary Core ATen verifier exception.
- Adds kernel and Python integration tests covering supported types, broadcasting, and invalid inputs.
| File | Description |
|---|---|
shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl |
Adds the portable kernel build target and broadcast dependency. |
kernels/test/targets.bzl |
Registers complex tests for ATen and portable kernels. |
kernels/test/op_complex_test.cpp |
Tests types, broadcasting, special values, resizing, and validation. |
kernels/test/CMakeLists.txt |
Includes complex kernel tests in CMake builds. |
kernels/portable/functions.yaml |
Registers the portable complex.out implementation. |
kernels/portable/cpu/op_complex.cpp |
Implements complex tensor construction on CPU. |
kernels/aten/functions.yaml |
Registers complex.out for ATen builds. |
extension/pybindings/test/test_pybindings.py |
Adds end-to-end export and execution coverage. |
exir/verification/verifier.py |
Temporarily allows complex.default through Core ATen validation. |
exir/dialects/edge/dtype/supported.py |
Maps complex32 to ComplexHalf. |
Review effort: Balanced
Contributor
Author
|
@pytorchbot label "release notes: ops & kernels" |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Models using
torch.complex(real, imag)currently fail the defaultto_edge()Core ATen check. Allowing the operator through that check still leaves CPU execution blocked by a missingaten::complex.outkernel.This PR enables default export and CPU execution for matching FP16/32/64 inputs, producing complex32/64/128 outputs. The portable kernel supports broadcasting and output resizing, and requires default contiguous dimension order. Edge dtype mapping now includes complex32.
Note:
aten.complex.defaultis temporarily allowed by the verifier while keeping IR validation enabled. A separate PyTorch change is needed to formally include it in Core ATen. This exception can be removed once all supported PyTorch versions include that change.Fixes #24328
Test plan
Rebuild the native bindings and C++ tests from this branch, then
Result: Python unittest reported 24 tests passed; GoogleTest reported 21/21 complex kernel tests passed; CTest reported 1/1 test target passed. No failures.