AbstractDifferentiation.jl icon indicating copy to clipboard operation
AbstractDifferentiation.jl copied to clipboard

Complex pullback support

Open sethaxen opened this issue 4 years ago • 4 comments

I realized that if the _dot function introduced in #21 is wrapped with real, then pullback_function works for complex arrays as well, whenever gradient supports complex inputs for a given backend. But at least in the scalar case, the real dot product can be computed twice as efficiently as real(_dot(x, y)).

sethaxen avatar Oct 11 '21 10:10 sethaxen

Not certain if this package wants to support complex AD (with Jacobians as the primitive, complex support is a little awkward), but to me it seems like, if the AD supports complex numbers, then at least for pushforwards, pullbacks, and gradients, it'd be nice if we did too.

sethaxen avatar Oct 11 '21 13:10 sethaxen

I agree. Even Jacobians can be supported as long as either the inputs or outputs are real.

mohdibntarek avatar Oct 12 '21 01:10 mohdibntarek

That's right, and even with both complex inputs and outputs, it can be supported by interleaving the real and imaginary parts into one real vector, but having the eltype be dependent on the real-ness of input and output starts to feel messy.

sethaxen avatar Oct 12 '21 13:10 sethaxen

ya complex input and output is messy, let's stick to the simple cases

mohdibntarek avatar Oct 12 '21 13:10 mohdibntarek