Multi-Dimensional Array (ndarray)¶
Multi-dimensional array on a CUDA device.
This class implements a subset of methods of
numpy.ndarray. The difference is that this class allocates the array content on the current GPU device.
- base (None or cupy.ndarray) – Base array from which this array is created as a view.
- data (cupy.cuda.MemoryPointer) – Pointer to the array content head.
- dtype (numpy.dtype) –
Dtype object of element type.
- size (int) –
Number of elements this array holds.
This is equivalent to product over the shape tuple.
Shape-reversed view of the array.
If ndim < 2, then this is just a reference to the array itself.
Returns the indices of the maximum along a given axis.
Returns the indices of the minimum along a given axis.
Casts the array to given data type.
- dtype – Type specifier.
- copy (bool) – If it is False and no cast happens, then this method returns the array itself. Otherwise, a copy is returned.
copyis False and no cast is required, then the array itself is returned. Otherwise, it returns a (possibly casted) copy of the array.
This method currently does not support
Returns an array with values limited to [a_min, a_max].
Returns a copy of the array.
C representation of the array.
This property is used for sending an array to CUDA kernels. The type of returned C structure is different for different dtypes and ndims. The definition of C type is written in
CUDA device on which this array resides.
Returns a view of the specified diagonals.
Returns the dot product with given array.
Dumps a pickle of the array to a file.
Dumps a pickle of the array to a string.
Fills the array with a scalar value.
Parameters: value – A scalar value to fill the array content.
Object containing memory-layout information.
It only contains
owndataattributes. All of these are read-only. Accessing by indexes is also supported.
Returns a copy of the array flatten into one dimension.
It currently supports C-order only.
Returns: A copy of the array with one dimension. Return type: cupy.ndarray
Returns a copy of the array on host memory.
Parameters: stream (cupy.cuda.Stream) – CUDA stream object. If it is given, the copy runs asynchronously. Otherwise, the copy is synchronous. Returns: Copy of the array on host memory. Return type: numpy.ndarray
Returns the maximum along a given axis.
Returns the mean along a given axis.
Returns the minimum along a given axis.
Size of whole elements in bytes.
It does not count skips between elements.
Return the indices of the elements that are non-zero.
Returned Array is containing the indices of the non-zero elements in that dimension.
Returns: Indices of elements that are non-zero. Return type: tuple of arrays
Returns the product along a given axis.
Returns an array flattened into one dimension.
Returns a view of the array with minimum number of dimensions.
Parameters: dtype – Data type specifier. If it is given, then the memory sequence is reinterpreted as the new type. Returns: A view of the array with reduced dimensions. Return type: cupy.ndarray
Returns an array with repeated arrays along an axis.
Returns an array of a different shape and the same content.
Adds given values to specified elements of an array.
cupy.scatter_add()for full documentation.
Copies an array on the host memory to
Lengths of axes.
Setter of this property involves reshaping without copy. If the array cannot be reshaped without copy, it raises an exception.
Returns a view with size-one axes removed.
Returns the standard deviation along a given axis.
Returns the sum along a given axis.
Returns a view of the array with two axes swapped.
Returns an array of elements at given indices along the axis.
Converts the array to a (possibly nested) Python list.
Returns: The possibly nested Python list of array elements. Return type: list
Returns the sum along diagonals of the array.
Returns a view of the array with axes permuted.
Returns the variance along a given axis.
Returns a view of the array.
Parameters: dtype – If this is different from the data type of the array, the returned view reinterpret the memory sequence as an array of this type. Returns: A view of the array. A reference to the original array is stored at the
Return type: cupy.ndarray
Returns an array on the host memory from an arbitrary source array.
Converted array on the host memory.