Strided slice of a tensor. Parameters ---------- x : relax.Expr The source tensor to be sliced. axes : List[int] Axes along which slicing is applied. begin : List[PrimExprLike] The indices to begin with in the slicing, inclusive. end : List[PrimExp
(
x: Expr,
axes: Expr,
begin: Expr,
end: Expr,
strides: Expr | None = None,
assume_inbound: bool = False,
)
| 59 | |
| 60 | |
| 61 | def strided_slice( |
| 62 | x: Expr, |
| 63 | axes: Expr, |
| 64 | begin: Expr, |
| 65 | end: Expr, |
| 66 | strides: Expr | None = None, |
| 67 | assume_inbound: bool = False, |
| 68 | ) -> Expr: |
| 69 | """Strided slice of a tensor. |
| 70 | |
| 71 | Parameters |
| 72 | ---------- |
| 73 | x : relax.Expr |
| 74 | The source tensor to be sliced. |
| 75 | |
| 76 | axes : List[int] |
| 77 | Axes along which slicing is applied. |
| 78 | |
| 79 | begin : List[PrimExprLike] |
| 80 | The indices to begin with in the slicing, inclusive. |
| 81 | |
| 82 | end : List[PrimExprLike] |
| 83 | The indices indicating end of the slice, exclusive. |
| 84 | |
| 85 | strides : Optional[List[PrimExprLike]] |
| 86 | Specifies the stride values, it can be negative in that case, |
| 87 | the input tensor will be reversed in that particular axis. |
| 88 | If not specified, it by default is an list of ones of the same length as `axes`. |
| 89 | |
| 90 | assume_inbound : bool |
| 91 | Whether to assume the indices are in bound. If it is set to false, |
| 92 | out of bound indices will be clipped to the bound. |
| 93 | Returns |
| 94 | ------- |
| 95 | ret : relax.Expr |
| 96 | The sliced result. |
| 97 | |
| 98 | Note |
| 99 | ---- |
| 100 | strided_slice require the input `begin`, `end` and `strides` to have the |
| 101 | same length as `axes`. |
| 102 | """ |
| 103 | axes = convert_to_expr(axes) |
| 104 | begin = convert_to_expr(begin) |
| 105 | end = convert_to_expr(end) |
| 106 | if strides is not None: |
| 107 | strides = convert_to_expr(strides) |
| 108 | return _ffi_api.strided_slice(x, axes, begin, end, strides, assume_inbound) # type: ignore |
| 109 | |
| 110 | |
| 111 | def dynamic_strided_slice( |
no test coverage detected
searching dependent graphs…