Skip to content

Commit

Permalink
Updated the filtering logic in convert_from_source_backend_to_numpy t…
Browse files Browse the repository at this point in the history
…o avoid calling ivy.to_numpy for arrays created with a different backend than the current one (ivy-llc#19293)
  • Loading branch information
vedpatwardhan authored Jul 12, 2023
1 parent db0ddc5 commit 47fe560
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ivy/utils/backend/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@ def _map_fn(x):
]
array_list.extend(cont_array_vals)

# filter uninitialized arrays and ensure the order
array_list = [arr for arr in array_list if arr.__dict__]
# filter uninitialized arrays and arrays with other bakcends, and ensure the order
array_list = [
arr
for arr in array_list
if arr.__dict__ and arr.backend == ivy.current_backend_str()
]
arr_ids = [id(item.data) for item in array_list]
new_objs = {k: v for k, v in zip(arr_ids, array_list)}
new_objs = list(new_objs.values())
Expand Down

0 comments on commit 47fe560

Please sign in to comment.