Conversation
6b118f5 to
6b496f0
Compare
|
@oleksandr-pavlyk I will review it in detail, as an initial suggestion. Can you reorganize it in to finer granular PRs? I understand that pieces of the code are not fully polished but we need it for 2021.3. So, we can push what is clean separately and the rest into an internal experimental sub module. |
6ec1ff5 to
35ceb07
Compare
I removed unused portions of libtensor/ from this PR, this is to be added elsewhere. Remainder has been squashed into a single commit. |
35ceb07 to
1357ba8
Compare
Added Cython extension class dpctl.tensor.usm_ndarray that represents strided layout array over SYCL USM memory chunk, supporting 3 USM types: 'device', 'shared', 'host'. The container implements constructor, certain properties and basic slicing for now. The container allocates memory using dpctl.memory memory buffers specific to USM type.
1357ba8 to
2475a90
Compare
diptorupd
left a comment
There was a problem hiding this comment.
I builds so let us merge it for now to help dpnp and numba start integrating with it.
|
|
||
| cdef object _basic_slice_meta(object ind, tuple shape, | ||
| tuple strides, Py_ssize_t offset): | ||
| """ |
There was a problem hiding this comment.
Although a cdef adding a docstring is good.
| { | ||
| return flags_; | ||
| } | ||
|
|
This adds
dpctl.tensor.usm_ndarrayclass.This is a Python class representing USM-allocated memory.
USM array data container specs
USM array represents a logic view into 1D contiguous array of USM memory to represent
r-dimensional type-homogenous array with shape(n[0], ..., n[r-1]). Referencing an element of such an array requires specifyingr-dimensional tuple of indexes(i[0], ..., i[r-1]) such that for all0<=k<rwe have0<=i[k] <n[k].Location of the individual element of the array referenced by the index is determined by strides.
Thus
strides[k]describes the number of array elements we jump in 1D physical array when indexi[k]increases by 1 while other indexes remain fixed.The array container delegates ownership of memory to
dpctl.memory.MemoryUSM*perusm_typeof memory it represents. The Python object representing this memory is stored indpctl.tensor.usm_array.base.Examples of dpctl.tensor.usm_ndarray instances
{{a[0,0], a[0, 1]}, {a[1,0], a[1,1]}}in the C-contiguous layout (first example)contig_vec[7::-2]Constructor
Examples
Warning
Integrity of
__sycl_usm_array_interface__dictionary (i.e. accessibility of all array elements) remains responsibility of the user. It is possible to craftoffset,stridesorshapethat would result in access outside of the boundary of allocated USM data. Doing so may result in a crash, or a runtime-error.Remark
usm_ndarrayconstructor, much likenumpy.ndarrayconstructor, is expected to be for the internal use, and is not expected to have external usage.