Skip to content

Commit

Permalink
fix(ivy): fixed value errors of ivy.scatter_nd paddle backend, occurr…
Browse files Browse the repository at this point in the history
…ing in cases where the indices contain duplicates
  • Loading branch information
AnnaTz committed Aug 23, 2023
1 parent 25be143 commit 57f92f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/backends/paddle/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ def scatter_nd(
)
updates = _broadcast_to(updates, expected_shape)._data

if indices.ndim > 1:
indices, unique_idxs = ivy.unique_all(indices, axis=0)[:2]
indices, unique_idxs = indices.data, unique_idxs.data
updates = ivy.gather(updates, unique_idxs, axis=0).data

# implementation
target_given = ivy.exists(out)
if target_given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def test_set_item(
on_device=on_device,
backend_to_test=backend_fw,
fn_name=fn_name,
rtol_=1e-03, # needed only for the paddle backend
x=x,
query=query,
val=val,
Expand Down

0 comments on commit 57f92f3

Please sign in to comment.