Skip to content

Commit

Permalink
fix: tracing ivy.set_item with Ellipsis/unbound slices (#28771)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam-Armstrong authored Jun 24, 2024
1 parent 855c25f commit d33939d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ivy/functional/ivy/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,23 @@ def set_item(
ivy.array([[ 0, -1, 20],
[10, 10, 10]])
"""

# TODO: we may be able to remove this logic by instead tracing _parse_query as a node in the graph??
if (
isinstance(query, (list, tuple)) and
any([
q is Ellipsis or (
isinstance(q, slice) and q.stop is None
) for q in query
])
):
# use numpy for item setting when an ellipsis or unbounded slice is present,
# as they would otherwise cause static dim sizes to be traced into the graph
# NOTE: this does however cause tf.function to be incompatible
np_array = x.numpy()
np_array[query] = np.asarray(val)
return ivy.array(np_array)

if copy:
x = ivy.copy_array(x)
if not ivy.is_array(val):
Expand Down

0 comments on commit d33939d

Please sign in to comment.