Skip to content

Commit e76953e

Browse files
array_info_sequence should handle empty sequences as host data
Added a test for this input
1 parent 29c2cbc commit e76953e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

dpctl/tensor/_ctors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def _array_info_sequence(li):
6363
raise ValueError(
6464
"Inconsistent dimensions, {} and {}".format(dim, el_dim)
6565
)
66+
if dim is None:
67+
dim = tuple()
68+
device = _host_set
6669
return (n,) + dim, dt, device
6770

6871

dpctl/tests/test_tensor_asarray.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def test_asarray_from_sequence():
8080
Y = dpt.asarray(X, usm_type="device")
8181
assert type(Y) is dpt.usm_ndarray
8282
assert Y.ndim == 2
83+
assert Y.shape == (len(X), 2)
84+
85+
X = []
86+
Y = dpt.asarray(X, usm_type="device")
87+
assert type(Y) is dpt.usm_ndarray
88+
assert Y.shape == (0,)
8389

8490

8591
def test_asarray_from_object_with_suai():

0 commit comments

Comments
 (0)