MCPcopy Create free account
hub / github.com/apache/tvm / strided_slice

Function strided_slice

python/tvm/relax/op/index.py:61–108  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

59
60
61def 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
111def dynamic_strided_slice(

Callers 1

conv2d_gradFunction · 0.70

Calls 2

convert_to_exprFunction · 0.85
strided_sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…