dpctl.tensor.usm_ndarray¶
- class dpctl.tensor.usm_ndarray(shape, dtype=None, strides=None, buffer='device', offset=0, order='C', buffer_ctor_kwargs=dict(), array_namespace=None)¶
An array object represents a multidimensional tensor of numeric elements stored in a USM allocation on a SYCL device.
- Arg:
- shape (int, tuple):
Shape of the array to be created.
- dtype (str, dtype):
Array data type, i.e. the type of array elements. If
dtype
has the valueNone
, it is determined by default floating point type supported by target device. The supported types arebool
:boolean type
int8
,int16
,int32
,int64
:signed integer types
uint8
,uint16
,uint32
,uint64
:unsigned integer types
float16
:half-precision floating type, supported if target device’s property
has_aspect_fp16
isTrue
float32
,complex64
:single-precision real and complex floating types
float64
,complex128
:double-precision real and complex floating types, supported if target device’s property
has_aspect_fp64
isTrue
.
Default:
None
.- strides (tuple, optional):
Strides of the array to be created in elements. If
strides
has the valueNone
, it is determined by theshape
of the array and the requestedorder
. Default:None
.- buffer (str, object, optional):
A string corresponding to the type of USM allocation to make, or a Python object representing a USM memory allocation, i.e.
dpctl.memory.MemoryUSMDevice
,dpctl.memory.MemoryUSMShared
, ordpctl.memory.MemoryUSMHost
. Recognized strings are"device"
,"shared"
, or"host"
. Additional arguments to the USM memory allocators can be passed in a dictionary specified viabuffer_ctor_kwrds
keyword parameter. Default:"device"
.- offset (int, optional):
Offset of the array element with all zero indexes relative to the start of the provided buffer in elements. The argument is ignored if the
buffer
value is a string and the memory is allocated by the constructor. Default:0
.- order ({“C”, “F”}, optional):
The memory layout of the array when constructing using a new allocation. Value
"C"
corresponds to C-contiguous, or row-major memory layout, while value"F"
corresponds to F-contiguous, or column-major layout. Default:"C"
.- buffer_ctor_kwargs (dict, optional):
Dictionary with keyword parameters to use when creating a new USM memory allocation. See
dpctl.memory.MemoryUSMShared
for supported keyword arguments.- array_namespace (module, optional):
Array namespace module associated with this array. Default:
None
.
buffer
can be"shared"
,"host"
,"device"
to allocate new device memory by calling respective constructor with the specifiedbuffer_ctor_kwrds
;buffer
can be an instance ofdpctl.memory.MemoryUSMShared
,dpctl.memory.MemoryUSMDevice
, ordpctl.memory.MemoryUSMHost
;buffer
can also be anotherdpctl.tensor.usm_ndarray
instance, in which case its underlyingMemoryUSM*
buffer is used.Methods
to_device
(target_device)Transfers this array to specified target device.
Attributes
Returns transposed array for 2D array, raises
ValueError
otherwise.Returns
dpctl.tensor.Device
object representing residence of the array data.Returns NumPy's dtype corresponding to the type of the array elements.
Returns
dpctl.tensor._flags.Flags
object.Returns view into imaginary component for arrays with complex data-types and returns new zero array for all other data-types.
Size of array element in bytes.
Returns array (a view) where the last two dimensions are transposed.
Total bytes consumed by the elements of the array.
Gives the number of indices needed to address elements of this array.
Returns view into real component for arrays with complex data-types and returns itself for all other data-types.
Elements of the shape tuple give the lengths of the respective array dimensions.
Number of elements in the array.
Returns memory displacement in array elements, upon unit change of respective index.
Returns
dpctl.SyclContext
object to which USM data is bound.Returns
dpctl.SyclDevice
object on which USM data was allocated.Returns
dpctl.SyclQueue
object associated with USM data.Gives USM memory object underlying
usm_ndarray
instance.USM type of underlying memory.
Special attributes
Gives a tuple (
device_type
,device_id
) corresponding toDLDevice
entry inDLTensor
in DLPack protocol.__dlpack__
(*[, stream, max_version, ...])Produces DLPack capsule.
Gives
__sycl_usm_array_interface__
dictionary describing the array.Returns USM pointer to the start of array (element with zero multi-index) encoded as integer.
Returns the offset of the zero-index element of the array, in elements, relative to the start of memory allocation
Returns a 2-tuple with pointers to the end-points of the array