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

add convenience wrapper for array updating with fancy index expressions #122

Closed
mattjj opened this issue Dec 16, 2018 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request

Comments

@mattjj
Copy link
Member

mattjj commented Dec 16, 2018

We should provide an update function that lets users write

A = lax.update(A, (slice(1, None, 2), Ellipsis, slice(None, -3)), value)

which would behave similarly to this kind of expression in regular NumPy

A[1::2, ...,  :-3] = value

except without the in-place mutation that would update any aliases.

This wrapper would be similar to the lax_numpy._rewriting_take function we already have for handling complex indexing expressions, and would ultimately call into primitives like lax.dynamic_update_slice and lax.index_untake. Better name suggestions welcome!

This is a separate issue from whether to provide more convenient syntax for this kind of operation.

@mattjj mattjj added the enhancement New feature or request label Dec 16, 2018
@mattjj mattjj self-assigned this Dec 16, 2018
@georgedahl
Copy link
Contributor

This is a really important operation for making it simple to express certain models. When using TF I have often had to spend a lot of time figuring out exactly how to use scatter_nd or whatever so making a clear correspondence with numpy syntax is useful.

@alexbw alexbw mentioned this issue Dec 20, 2018
21 tasks
hawkinsp added a commit to hawkinsp/jax that referenced this issue Mar 4, 2019
…NumPy-style indexed updates.

Create a new library `jax.ops` for user-facing ops that don't exist in NumPy or SciPy.

Progress on issue google#101. Fixes google#122.
hawkinsp added a commit to hawkinsp/jax that referenced this issue Mar 4, 2019
…NumPy-style indexed updates.

Create a new library `jax.ops` for user-facing ops that don't exist in NumPy or SciPy.

Progress on issue google#101. Fixes google#122.

Reenable some disabled TPU indexing tests that now pass.
@hawkinsp hawkinsp assigned hawkinsp and unassigned mattjj Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants