strided_slice

    strided_slice算子。

    该OP沿多个轴生成 x 的切片,与numpy类似: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html。该OP使用 axesstartsends 属性来指定轴列表中每个轴的起点和终点位置,并使用此信息来对 x 切片。如果向 startsends 传递负值如

    参数:

    代码示例:

    1. import paddle
    2. x = paddle.zeros(shape=[3,4,5,6], dtype="float32")
    3. # example 1:
    4. # attr starts is a list which doesn't contain tensor Tensor.
    5. axes = [1, 2, 3]
    6. starts = [-3, 0, 2]
    7. ends = [3, 2, 4]
    8. strides_1 = [1, 1, 1]
    9. sliced_1 = paddle.strided_slice(x, axes=axes, starts=starts, ends=ends, strides=strides_1)
    10. # sliced_1 is x[:, 1:3:1, 0:2:1, 2:4:1].
    11. # example 2:
    12. # attr starts is a list which contain tensor Tensor.
    13. minus_3 = paddle.full(shape=[1], fill_value=-3, dtype='int32')
    14. sliced_2 = paddle.strided_slice(x, axes=axes, starts=[minus_3, 0, 2], ends=ends, strides=strides_2)
    15. # sliced_2 is x[:, 1:3:1, 0:2:1, 2:4:2].