From 57f92f321676d802948e7d3a421ec85de9408f1d Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:45:39 +0100 Subject: [PATCH] fix(ivy): fixed value errors of ivy.scatter_nd paddle backend, occurring in cases where the indices contain duplicates --- ivy/functional/backends/paddle/general.py | 5 +++++ ivy_tests/test_ivy/test_functional/test_core/test_general.py | 1 + 2 files changed, 6 insertions(+) diff --git a/ivy/functional/backends/paddle/general.py b/ivy/functional/backends/paddle/general.py index 4f3d5563dab70..7d0176b332935 100644 --- a/ivy/functional/backends/paddle/general.py +++ b/ivy/functional/backends/paddle/general.py @@ -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: diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_general.py b/ivy_tests/test_ivy/test_functional/test_core/test_general.py index 848aebf804098..90fc5aab7c587 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_general.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_general.py @@ -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,