Skip to content
class

RealBackward

RealBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Extract the real part of a complex tensor as a real tensor.

The result dtype is the corresponding real dtype (C64 → F32, C128 → F64); the shape and device are unchanged.

Math

yk=ℜ(zk) y_k = \Re(z_k)

See Also

imag_op, complex_op, conj_op Backward for the complex projections.

None of them had one. real, imag and conj built their output and returned it, so a complex tensor was where every gradient stopped:

real(fft(x)).sum().backward()   ->  x.grad is None

with no error raised. fft is wired correctly; the chain broke one step later, which meant any loss written through a frequency-domain transform trained on nothing at all. abs on a complex input is a composite of real and imag, so it was unreachable for the same reason and becomes differentiable with them.

The header above used to say this belonged to "the Python autograd layer". There was no such layer.

The conventions are the reference's, measured rather than derived:

d/dz real(z) = g + 0i        d/dz imag(z) = 0 + g i
d/dz conj(z) = conj(g)       d/dz |z|     = g z / |z|

Each is expressible with ops that already exist, so the backward is a storage-level call rather than a new kernel.

Parameters

aTensorImplPtr
Complex-dtype input tensor (C64; CPU also supports C128).

Raises

DtypeMismatch
If a is not a complex dtype.