Implementing kernel
C++ engine symbols that back this Python API.Imaginary part of a complex tensor.
Returns the imaginary component of a complex input as a real tensor of the matching precision that is a view of the input's storage — writing into it changes the input, on Metal as on the CPU.
Parameters
inputTensorComplex input tensor.
Returns
TensorA view with the same shape as input.
Raises
NotImplementedErrorinput is not complex: a real tensor has no imaginary part to
view (a RuntimeError too, as the reference raises).Notes
Mathematical definition:
Gradient flows back as the imaginary part of the upstream cotangent.
Examples
>>> import lucid
>>> z = lucid.tensor([1 + 2j, 3 - 1j])
>>> lucid.imag(z)
tensor([2., -1.])