Slice
The slice operation extracts a strided window of a tensor along each dimension:
where each dimension uses a half-open interval [start, limit) and an optional slice stride (step) per axis. The output length along axis i is ceil((limit_i - start_i) / step_i) when step_i > 0.
Backend operation (cuDNN 9.22+)
On cuDNN 9.22.0 and newer, the node can lower to the native backend slice operation and materializes both input and output tensor descriptors. On older versions, the frontend may use a pointer-offset style lowering for compatible cases.
C++ API
Slice_attributes setters:
If set_strides is omitted, every step defaults to 1. If provided, the vector must cover each sliced dimension consistently with set_slices.
Python API
slice(input, slices=[], compute_data_type=cudnn.data_type.NOT_SET, name="")- input: tensor to slice.
- slices: list of
sliceobjects, one per dimension. Per-axis step is taken from each slice’sstep(default1), after normalization for that axis length (same idea assequence[sl]in Python).
Example: