numba-dpex icon indicating copy to clipboard operation
numba-dpex copied to clipboard

numba-dpex doesn't support zero-length array creation

Open chudur-budur opened this issue 2 years ago • 0 comments

If we look at dpnp and numpy, they support zero-length array creation (i.e. shape is 0)

>>> import numpy as np
>>> a = np.empty(0)
>>> a
array([], dtype=float64)
>>> import dpnp
>>> a = dpnp.empty(0)
>>> a
array([])

numba-dpex should do the same.

@dpjit
def foo():
    x = dpnp.empty(0)
    return x

a = foo()
print(a)

but it doesn't:

Traceback (most recent call last):
  File "/localdisk/work/$USER/numba-dpex/my-driver.py", line 20, in <module>
    a = bar()
MemoryError: USM allocation failed. Check the usm_type and queue.

This is applicable all other array creation functions, zeros(), ones(), etc.

chudur-budur avatar Oct 27 '23 09:10 chudur-budur