Skip to content

dpt.roll does not work with unsigned shift value #1857

Closed
@antonwolfy

Description

@antonwolfy

Below code results into an unexpected exception inside _copy_usm_ndarray_for_roll_nd call:

import numpy, dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.18.0+0.g786365ee72.dirty'

a = dpt.arange(10)
dpt.roll(a, numpy.uint64(1), axis=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[26], line 1
----> 1 dpt.roll(a, numpy.uint64(1), axis=0)

File ~/miniforge3/envs/dpnp_dev/lib/python3.11/site-packages/dpctl/tensor/_manipulation_functions.py:379, in roll(X, shift, axis)
    375 res = dpt.empty(
    376     X.shape, dtype=X.dtype, usm_type=X.usm_type, sycl_queue=exec_q
    377 )
    378 dep_evs = _manager.submitted_events
--> 379 ht_e, roll_ev = ti._copy_usm_ndarray_for_roll_nd(
    380     src=X, dst=res, shifts=shifts, sycl_queue=exec_q, depends=dep_evs
    381 )
    382 _manager.add_event_pair(ht_e, roll_ev)
    383 return res

TypeError: _copy_usm_ndarray_for_roll_nd(): incompatible function arguments. The following argument types are supported:
    1. (src: dpctl::tensor::usm_ndarray, dst: dpctl::tensor::usm_ndarray, shifts: list[int], sycl_queue: dpctl.SyclQueue, depends: list[dpctl.SyclEvent] = []) -> tuple[dpctl.SyclEvent, dpctl.SyclEvent]

Invoked with: kwargs: src=usm_ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), dst=usm_ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), shifts=[1.0], sycl_queue=<dpctl.SyclQueue at 0x7f646250d8c0>, depends=[]

# works with signed integer:
dpt.roll(a, numpy.int64(1), axis=0)
# Out: usm_ndarray([9, 0, 1, 2, 3, 4, 5, 6, 7, 8])

A similar issue was present in NumPy, but resolved in 2.1.2 version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions