dpnp.prod
- dpnp.prod(a, axis=None, dtype=None, out=None, keepdims=False, initial=None, where=True)[source]
Return the product of array elements over a given axis.
For full documentation refer to
numpy.prod.- Returns:
out – A new array holding the result is returned unless out is specified, in which case it is returned.
- Return type:
dpnp.ndarray
Limitations
Input array is only supported as either
dpnp.ndarrayordpctl.tensor.usm_ndarray. Parameters initial, and where are only supported with their default values. Otherwise the function will be executed sequentially on CPU. Input array data types are limited by DPNP Data types.See also
dpnp.nanprodReturn the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.
Examples
>>> import dpnp as np >>> np.prod(np.array([1, 2])) array(2)
>>> a = np.array([[1, 2], [3, 4]]) >>> np.prod(a) array(24)
>>> np.prod(a, axis=1) array([ 2, 12]) >>> np.prod(a, axis=0) array([3, 8])
>>> x = np.array([1, 2, 3], dtype=np.int8) >>> np.prod(x).dtype == int True