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 jax backend set item with scalar values #27886

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

mattbarrett98
Copy link
Contributor

this fixes the jax backend for set_item when scalar values are used i.e.

import ivy
ivy.set_jax_backend()
x = ivy.array([[1., 2.], [3., 4.]])
query = ivy.array([[True, False], [True, True]])
val = 5.
print(ivy.set_item(x, query, val))

@Ishticode
Copy link
Contributor

Ishticode commented Jan 11, 2024

hey @mattbarrett98 . I think there are cases where expected_shape is undefined. lmc if can be fixed unless you have something
you will see in this case

import ivy
ivy.set_jax_backend()
x = ivy.array([[1., 2.], [3., 4.]])
query = ivy.array([[1, 0], [1, 1]])
val = ivy.array(5.)
print(ivy.set_item(x, query, val))

also the test case is linked below

Copy link
Contributor

@Ishticode Ishticode left a comment

Choose a reason for hiding this comment

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

leads to expected_shape being undefined in one test case (https://github.com/unifyai/ivy/actions/runs/7463291702/job/20307666791?pr=27886).
Indenting the new conditional seems to work but not sure entirely.

  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

@Ishticode Ishticode merged commit 9134ee3 into Transpile-AI:main Jan 11, 2024
127 of 141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants