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: tracing ivy.set_item with Ellipsis/unbound slices #28771

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ivy/functional/ivy/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,21 @@ def set_item(
ivy.array([[ 0, -1, 20],
[10, 10, 10]])
"""
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
Loading