Cumulative binary operator (scan) with similar axis behavior as np.cumsum and np.cumprod. See cumprod and cumsum for an example of use. E.g. if * is your binary operator and the input tensor is [1, 2, 3, 4] the output may be [1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4] Parameters ----
(
data: tvm.te.Tensor,
binop: Callable[["tvm.Expr", "tvm.Expr"], "tvm.Expr"],
identity_value: float | int,
axis: int | None = None,
dtype: str | None = None,
exclusive: bool | None = None,
workspace: tvm.te.Tensor | None = None,
)
| 602 | |
| 603 | |
| 604 | def scanop( |
| 605 | data: tvm.te.Tensor, |
| 606 | binop: Callable[["tvm.Expr", "tvm.Expr"], "tvm.Expr"], |
| 607 | identity_value: float | int, |
| 608 | axis: int | None = None, |
| 609 | dtype: str | None = None, |
| 610 | exclusive: bool | None = None, |
| 611 | workspace: tvm.te.Tensor | None = None, |
| 612 | ) -> tvm.te.Tensor: |
| 613 | """Cumulative binary operator (scan) with similar axis behavior as np.cumsum and np.cumprod. |
| 614 | |
| 615 | See cumprod and cumsum for an example of use. |
| 616 | |
| 617 | E.g. if * is your binary operator and the input tensor is [1, 2, 3, 4] the output may be |
| 618 | [1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4] |
| 619 | |
| 620 | Parameters |
| 621 | ---------- |
| 622 | data : tvm.te.Tensor |
| 623 | The input data to the operator. |
| 624 | |
| 625 | binop: Callable (tvm.Expr, tvm.Expr) -> tvm.Expr |
| 626 | A binary operator which should be associative and commutative. E.g. if * is your |
| 627 | operator then a * (b * c) = (a * b) * c and a * b = b * a |
| 628 | |
| 629 | identity_value: int or float |
| 630 | A value for the binary operation which provides the identity property. E.g. if * is |
| 631 | your operator and i is the identity_value then a * i = a for all a in the domain of |
| 632 | your operation. |
| 633 | |
| 634 | axis : int, optional |
| 635 | Axis along which the operation is computed. The default (None) is to compute |
| 636 | the cumulative operation over the flattened array. |
| 637 | |
| 638 | dtype : string, optional |
| 639 | Type of the returned array and of the accumulator in which the elements are computed. |
| 640 | If dtype is not specified, it defaults to the dtype of data. |
| 641 | |
| 642 | exclusive : bool, optional |
| 643 | If true will return exclusive cumulative operation in which the first element is not |
| 644 | included. In other terms, if true, the j-th output element would be |
| 645 | the cumulative operation of the first (j-1) elements. Otherwise, it would be the |
| 646 | cumulative operation of the first j elements. |
| 647 | |
| 648 | workspace: Optional[tvm.te.Tensor] |
| 649 | |
| 650 | Returns |
| 651 | ------- |
| 652 | result : tvm.te.Tensor |
| 653 | The result has the same size as data, and the same shape as data if axis is not None. |
| 654 | If axis is None, the result is a 1-d array. |
| 655 | """ |
| 656 | if axis is None: |
| 657 | axis = 0 |
| 658 | data = reshape(data, (prod(data.shape),)) |
| 659 | axis = get_const_int(axis) |
| 660 | if exclusive is not None and exclusive: |
| 661 | return exclusive_scan( |
no test coverage detected
searching dependent graphs…