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

Function strided_slice

python/tvm/topi/transform.py:176–235  ·  view source on GitHub ↗

Slice of an array. Parameters ---------- a : tvm.te.Tensor The tensor to be sliced. begin : list of int The indices to begin with in the slicing. end : list of int Indices indicating end of the slice. strides : list of int, optional Specifi

(a, begin, end, strides=None, axes=None, slice_mode="end", assume_inbound=True)

Source from the content-addressed store, hash-verified

174
175
176def strided_slice(a, begin, end, strides=None, axes=None, slice_mode="end", assume_inbound=True):
177 """Slice of an array.
178
179 Parameters
180 ----------
181 a : tvm.te.Tensor
182 The tensor to be sliced.
183
184 begin : list of int
185 The indices to begin with in the slicing.
186
187 end : list of int
188 Indices indicating end of the slice.
189
190 strides : list of int, optional
191 Specifies the stride values, it can be negative
192 in that case, the input tensor will be reversed
193 in that particular axis.
194
195 axes : list of int, optional
196 Axes along which slicing is applied. When it is specified, begin, end
197 strides, and axes need to a list of integers of the same length.
198
199 slice_mode : str, optional
200 The slice mode [end, size].
201 end - The ending indices for the slice [default].
202 size - The input strides will be ignored, input end in this mode indicates
203 the sizeof a slice starting at the location specified by begin. If end[i]
204 is -1, all remaining elements in that dimension are included in the slice.
205
206 assume_inbound: bool, optional
207 A flag to indicate if all indices are assumed to be inbound
208
209 Returns
210 -------
211 ret : tvm.te.Tensor
212 """
213 if (
214 isinstance(begin, tvm.te.Tensor)
215 or isinstance(end, tvm.te.Tensor)
216 or isinstance(strides, tvm.te.Tensor)
217 ):
218 assert axes is None, "axes argument is not supported by dynamic strided slice yet."
219 if not isinstance(begin, tvm.te.Tensor):
220 begin = const_vector(begin)
221 if not isinstance(end, tvm.te.Tensor):
222 end = const_vector(end)
223 if strides is None:
224 strides = [1] * begin.shape[0].value
225 if not isinstance(strides, tvm.te.Tensor):
226 strides = const_vector(strides)
227 return cpp.dynamic_strided_slice(a, begin, end, strides)
228 if strides is None:
229 strides = []
230 if axes is None:
231 axes = []
232 # axes is a list of host integers on the C++ side (Array<int64_t>); unwrap any
233 # IntImm entries that callers may pass through (e.g. relax legalize pipeline).

Callers 3

topkFunction · 0.50
topk_thrustFunction · 0.50
fifo_bufferFunction · 0.50

Calls 3

const_vectorFunction · 0.85
dynamic_strided_sliceMethod · 0.80
strided_sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…