Skip to content

Fixed type inferencing for nest sequences with no elements #697

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

Merged
merged 1 commit into from
Dec 1, 2021
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
1 change: 1 addition & 0 deletions dpctl/tensor/_ctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def _array_info_sequence(li):
)
if dim is None:
dim = tuple()
dt = float
device = _host_set
return (n,) + dim, dt, device

Expand Down
5 changes: 5 additions & 0 deletions dpctl/tests/test_tensor_asarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def test_asarray_from_sequence():
assert type(Y) is dpt.usm_ndarray
assert Y.shape == (0,)

X = [[], []]
Y = dpt.asarray(X, usm_type="device")
assert type(Y) is dpt.usm_ndarray
assert Y.shape == (2, 0)

X = [True, False]
Y = dpt.asarray(X, usm_type="device")
assert type(Y) is dpt.usm_ndarray
Expand Down