Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Use operator.index instead of int
  • Loading branch information
oleksandr-pavlyk committed Oct 20, 2024
commit 4971d64a72ddbf8093597ba20e3fb4e904dac406
7 changes: 4 additions & 3 deletions dpctl/tensor/_manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def roll(x, /, shift, *, axis=None):
res = dpt.empty(
x.shape, dtype=x.dtype, usm_type=x.usm_type, sycl_queue=exec_q
)
sz = x.size
sz = operator.index(x.size)
shift = (shift % sz) if sz > 0 else 0
dep_evs = _manager.submitted_events
hev, roll_ev = ti._copy_usm_ndarray_for_roll_1d(
Expand All @@ -373,8 +373,9 @@ def roll(x, /, shift, *, axis=None):
] * x.ndim
shape = x.shape
for sh, ax in broadcasted:
n_i = shape[ax]
shifts[ax] = (int(shifts[ax] + sh) % int(n_i)) if n_i > 0 else 0
n_i = operator.index(shape[ax])
shifted = operator.index(shifts[ax]) + operator.index(sh)
shifts[ax] = (shifted % n_i) if n_i > 0 else 0
res = dpt.empty(
x.shape, dtype=x.dtype, usm_type=x.usm_type, sycl_queue=exec_q
)
Expand Down