numba-dpex
numba-dpex copied to clipboard
Cannot write into a dpctl.tensor view with a dpex.kernel
The following does not work:
import numba_dpex as dpex
from numba import float32
import dpctl
import dpnp
import numpy as np
@dpex.kernel
def kernel(array_i):
i = dpex.get_global_id(0)
array[i] = float32(32.)
array = dpctl.tensor.empty(sh=(4,8,16), dtype=np.float32)
view = dpctl.tensor.reshape(array, (-1,))
kernel[512, 64](view)
print(array)
and raises this error:
TypingError: Failed in dpex_nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function setitem>) found for signature:
>>> setitem(readonly array(float32, 3d, C), int64, float32)
There are 16 candidate implementations:
- Of which 14 did not match due to:
Overload of function 'setitem': File: <numerous>: Line N/A.
With argument(s): '(readonly array(float32, 3d, C), int64, float32)':
No match.
- Of which 2 did not match due to:
Overload in function 'SetItemBuffer.generic': File: numba/core/typing/arraydecl.py: Line 176.
With argument(s): '(readonly array(float32, 3d, C), int64, float32)':
Rejected as the implementation raised a specific error:
NumbaTypeError: Cannot modify readonly array of type: readonly array(float32, 3d, C)
raised from /opt/venv/lib/python3.9/site-packages/numba/core/typing/arraydecl.py:183
During: typing of setitem at <ipython-input-1-6d746adfe5f2> (10)
File "<ipython-input-1-6d746adfe5f2>", line 10:
def kernel(array_i):
<source elided>
i = dpex.get_global_id(0)
array[i] = float32(32.)
^
Would it be possible to make this kind of call work ? this would be helpful to write generic kernels that work regardless of the input rank.