Skip to content

jax.Array.view returns a copy rather than a view #20857

Answered by jakevdp
hirayaku asked this question in Q&A
Discussion options

You must be logged in to vote

Hi - thanks for the question! This is working as intended. Two JAX arrays can never share the same memory, and so there is no way for view to produce a second array that shares the same memory as the first.

Keep in mind, however, that within a jit context this restriction is lifted, and the compiler can (and generally will) choose a more memory-efficient approach when it is possible to do so without violating the semantics of the original program.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hirayaku
Comment options

@jakevdp
Comment options

Answer selected by hirayaku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants