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

fix: reset broadcasting issues in jax backend setitem #27909

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
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
12 changes: 6 additions & 6 deletions ivy/functional/backends/jax/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def _mask_to_index(query, x):
raise ivy.exceptions.IvyException("too many indices")
elif not len(query.shape):
query = jnp.tile(query, x.shape[0])
expected_shape = x[query].shape
return jnp.where(query), expected_shape
return jnp.where(query)


def get_item(
Expand All @@ -75,7 +74,7 @@ def get_item(
return jnp.array([], dtype=x.dtype)
else:
return jnp.expand_dims(x, 0)
query, _ = _mask_to_index(query, x)
query = _mask_to_index(query, x)
elif isinstance(query, list):
query = (query,)
return x.__getitem__(query)
Expand All @@ -90,9 +89,10 @@ def set_item(
copy: Optional[bool] = False,
) -> JaxArray:
if ivy.is_array(query) and ivy.is_bool_dtype(query):
query, expected_shape = _mask_to_index(query, x)
if ivy.is_array(val):
val = _broadcast_to(val, expected_shape)._data
query = _mask_to_index(query, x)
expected_shape = x[query].shape
if ivy.is_array(val):
val = _broadcast_to(val, expected_shape)._data
ret = x.at[query].set(val)
if copy:
return ret
Expand Down
Loading