mindspore.ops.cumprod
- mindspore.ops.cumprod(input, dim, dtype=None)[source]
Computes the cumulative product of the input tensor along dimension dim. For example, if input is a vector of size N, the result will also be a vector of size N, with elements.
\[y_i = x_1 * x_2 * x_3 * ... * x_i\]- Parameters
- Returns
Tensor, has the same shape and dtype as the input unless dtype is specified.
- Raises
TypeError – If dim is not an int.
TypeError – If dtype conversion is not acceptable.
ValueError – If dim is None.
- Supported Platforms:
Ascend
CPU
GPU
Examples
>>> x = Tensor(np.array([1, 2, 3], np.float32)) >>> output = ops.cumprod(x, 0) >>> print(output) [1. 2. 6.]