mindspore.ops.CumProd
- class mindspore.ops.CumProd(*args, **kwargs)[source]
Computes the cumulative product of the tensor x along axis.
- Parameters
- Inputs:
input_x (Tensor[Number]) - The input tensor.
axis (int) - The dimensions to compute the cumulative product. Only constant value is allowed.
- Outputs:
Tensor, has the same shape and dtype as the input_x.
- Raises
TypeError – If exclusive or reverse is not a bool.
ValueError – If axis is None.
- Supported Platforms:
Ascend
Examples
>>> a, b, c, = 1, 2, 3 >>> input_x = Tensor(np.array([a, b, c]).astype(np.float32)) >>> op0 = ops.CumProd() >>> output0 = op0(input_x, 0) # output=[a, a * b, a * b * c] >>> op1 = ops.CumProd(exclusive=True) >>> output1 = op1(input_x, 0) # output=[1, a, a * b] >>> op2 = ops.CumProd(reverse=True) >>> output2 = op2(input_x, 0) # output=[a * b * c, b * c, c] >>> op3 = ops.CumProd(exclusive=True, reverse=True) >>> output3 = op3(input_x, 0) # output=[b * c, c, 1] >>> print(output0) [1. 2. 6.] >>> print(output1) [1. 1. 2.] >>> print(output2) [6. 6. 3.] >>> print(output3) [6. 3. 1.]