mbrookhart commented on a change in pull request #7722:
URL: https://github.com/apache/tvm/pull/7722#discussion_r600842607
##########
File path: python/tvm/topi/cuda/scan.py
##########
@@ -514,10 +616,54 @@ def cumsum(data, axis=None, dtype=None, exclusive=None):
The result has the same size as data, and the same shape as data if
axis is not None.
If axis is None, the result is a 1-d array.
"""
- if axis is None:
- axis = 0
- data = reshape(data, (prod(data.shape),))
- axis = get_const_int(axis)
- if exclusive is not None and exclusive != 0:
- return exclusive_scan(data, axis, output_dtype=dtype,
binop=tvm.tir.generic.add)
- return inclusive_scan(data, axis, output_dtype=dtype,
binop=tvm.tir.generic.add)
+ return scanop(
+ data=data,
+ binop=tvm.tir.generic.add,
+ identity_value=0,
+ axis=axis,
+ dtype=dtype,
+ exclusive=exclusive,
+ )
+
+
+def cumprod(
+ data: tvm.te.Tensor,
+ axis: Optional[int] = None,
+ dtype: Optional[int] = None,
+ exclusive: Optional[bool] = None,
+):
+ """Numpy style cumprod op. Return the cumulative product of the elements
along a given axis.
+
+ Parameters
+ ----------
+ data : tvm.te.Tensor
+ The input data to the operator.
+
+ axis : int, optional
+ Axis along which the cumulative product is computed. The default
(None) is to compute
+ the cumproduct over the flattened array.
+
+ dtype : string, optional
+ Type of the returned array and of the accumulator in which the
elements are multiplied.
+ If dtype is not specified, it defaults to the dtype of data.
+
+ exclusive : bool, optional
+ If True, will return exclusive product in which the first element is
not
+ included. In other terms, if True, the j-th output element would be
+ the product of the first (j-1) elements. Otherwise, it would be the
product of
+ the first j elements.
Review comment:
Hehehe, I tagged the wrong line. I know why cuda scan needs to be
inclusive or exclusive (it's for other ops), but I'm not sure why cumprod needs
the option?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]