Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion 3 dpctl/tensor/_copy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ def _nonzero_impl(ary):
mask_nelems, dtype=cumsum_dt, sycl_queue=exec_q, order="C"
)
mask_count = ti.mask_positions(ary, cumsum, sycl_queue=exec_q)
indexes_dt = ti.default_device_int_type(exec_q.sycl_device)
indexes = dpt.empty(
(ary.ndim, mask_count),
dtype=cumsum.dtype,
dtype=indexes_dt,
usm_type=usm_type,
sycl_queue=exec_q,
order="C",
Expand Down
12 changes: 12 additions & 0 deletions 12 dpctl/tests/test_usm_ndarray_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,3 +1345,15 @@ def test_nonzero_arg_validation():
dpt.nonzero(list())
with pytest.raises(ValueError):
dpt.nonzero(dpt.asarray(1))


def test_nonzero_dtype():
"See gh-1322"
get_queue_or_skip()
x = dpt.ones((3, 4))
idx, idy = dpt.nonzero(x)
# create array using device's
# default integral data type
ref = dpt.arange(8)
assert idx.dtype == ref.dtype
assert idy.dtype == ref.dtype
Morty Proxy This is a proxified and sanitized view of the page, visit original site.