Skip to content
class

ComplexBackward

ComplexBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Combine two real tensors into a complex tensor.

The result is C64 for F32 parts or C128 for CPU F64 parts, on the input device. Both inputs must be real-floating; half formats widen to F32. The resulting interleaved storage holds a+b ia + b\,i element-wise.

Math

zk=ak+bk i z_k = a_k + b_k\,i

See Also

real_op, imag_op, conj_op Backward for complex — see RealBackward. The inverse of the two projections: each operand takes the lane it supplied.

Parameters

reTensorImplPtr
Real part. Must be a real-floating dtype.
imTensorImplPtr
Imaginary part. Broadcastable shape, same device and widened dtype as re.

Raises

DtypeMismatch
If either input is not a real-floating dtype.
ShapeMismatch
If re and im cannot broadcast.
DeviceMismatch
If re and im live on different devices.

Notes

Native backward extracts both lanes of the incoming complex gradient. Graph mode uses the same projections to preserve higher derivatives.

Instance methods

2
fn

apply

int apply(int grad_out)

Returns (real(g), imag(g)), one per operand.

fn

apply_for_graph

int apply_for_graph(const int & grad_out)