Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reshape jacobian of real input and complex output to ensure complex output #594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mduschenes
Copy link
Contributor

@mduschenes mduschenes commented Apr 24, 2023

Reshape jacobian of real input and complex output to ensure complex output

  • Currently jacobian() _make_vjp(fun,x) for real inputs and complex outputs yields grads with shape (ans.size*2,x.size), which is unable to be reshaped into jacobian_shape = (*ans.shape,*x.shape)
  • jacobian() to include checks for real inputs and complex outputs (other combinations of input/output dtypes to be included)
  • reshapes and transposes are done on grads to extract real and imaginary components of complex fun grads
  • grads are recombined into complex number: grads.real - 1j*grads.imag (where the -1j convention is believed to be due to the form of the vjp)
  • Tested personally on fun(x) with arbitrary x and fun shape
  • CI unit tests to be conducted by admins, to include holomorphic/non-holomorphic checks etc. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant