Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tensorcircuit/backends/jax_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,16 @@

@jax.custom_vjp
def adaware_eigh(A: Array) -> Array:
return jnp.linalg.eigh(A)
result = jnp.linalg.eigh(A)
e = result.eigenvalues
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem of the change proposed here is that it is not compatible with older versions of Jax, where the result is just a tuple?
What about e, v = jnp.linalg.eigh(A); return e, v, will this change be compatible with both tuple and namedtuple?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, that would work! Shall I update it?

v = result.eigenvectors
return e, v


def jaxeigh_fwd(A: Array) -> Array:
e, v = jnp.linalg.eigh(A)
result = jnp.linalg.eigh(A)
e = result.eigenvalues
v = result.eigenvectors

Check warning on line 163 in tensorcircuit/backends/jax_ops.py

View check run for this annotation

Codecov / codecov/patch

tensorcircuit/backends/jax_ops.py#L161-L163

Added lines #L161 - L163 were not covered by tests
return (e, v), (A, e, v)


Expand Down
Loading