PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
101 stars 26 forks source link

[Frontend] Cast returned numpy arrays to jax.Array #895

Closed erick-xanadu closed 4 days ago

erick-xanadu commented 5 days ago

Context: We should return jax.Array's instead of numpy.array's

Description of the Change: Call jax.numpy.asarray() before returning

Benefits: meets user expectations.

Possible Drawbacks: None.

Related GitHub Issues:

Should NOT be cherry picked to RC

codecov[bot] commented 5 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.97%. Comparing base (6c5032c) to head (ad6edbc).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #895 +/- ## ======================================= Coverage 97.97% 97.97% ======================================= Files 71 71 Lines 10449 10451 +2 Branches 948 949 +1 ======================================= + Hits 10237 10239 +2 Misses 169 169 Partials 43 43 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

erick-xanadu commented 4 days ago

Thanks for the fix @erick-xanadu! My only question is should we create the jax array from the get go, or do we have to do generate a numpy array first? If the latter this is good to merge :)

@dime10: I haven't found a good C++ API for creating JAX arrays. We use the Numpy C++ Array API for creating arrays to avoid creating copies of memref data.