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 - dtypehas the value- None, it is determined by default floating point type supported by target device. The supported types are- bool:
- 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_fp16is- True
- 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_fp64is- True.
 - Default: - None.
- strides (tuple, optional):
- Strides of the array to be created in elements. If - strideshas the value- None, it is determined by the- shapeof the array and the requested- order. 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, or- dpctl.memory.MemoryUSMHost. Recognized strings are- "device",- "shared", or- "host". Additional arguments to the USM memory allocators can be passed in a dictionary specified via- buffer_ctor_kwrdskeyword 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 - buffervalue 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.MemoryUSMSharedfor supported keyword arguments.
- array_namespace (module, optional):
- Array namespace module associated with this array. Default: - None.
 
 - buffercan be- "shared",- "host",- "device"to allocate new device memory by calling respective constructor with the specified- buffer_ctor_kwrds;- buffercan be an instance of- dpctl.memory.MemoryUSMShared,- dpctl.memory.MemoryUSMDevice, or- dpctl.memory.MemoryUSMHost;- buffercan also be another- dpctl.tensor.usm_ndarrayinstance, in which case its underlying- MemoryUSM*buffer is used.- Methods - to_device(target_device, /, *[, stream])- Transfers this array to specified target device. - Attributes - Returns transposed array for 2D array, raises - ValueErrorotherwise.- Returns - dpctl.tensor.Deviceobject representing residence of the array data.- Returns NumPy's dtype corresponding to the type of the array elements. - Returns - dpctl.tensor._flags.Flagsobject.- 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.SyclContextobject to which USM data is bound.- Returns - dpctl.SyclDeviceobject on which USM data was allocated.- Returns - dpctl.SyclQueueobject associated with USM data.- Gives USM memory object underlying - usm_ndarrayinstance.- USM type of underlying memory. - Special attributes - Gives a tuple ( - device_type,- device_id) corresponding to- DLDeviceentry in- DLTensorin 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