Slice

Description

Produces a slice of the input tensor along multiple axes. Similar to numpy : https://numpy.org/doc/stable/user/basics.indexing.html?highlight=slice#slicing-and-striding

 

 

Slice uses theΒ starts,Β ends,Β axesΒ andΒ stepsΒ inputs to select a sub-tensor of its inputΒ dataΒ tensor.

An effectiveΒ starts,Β ends, andΒ stepsΒ must be computed for eachΒ iΒ inΒ [0,Β ...Β r-1]Β whereΒ rΒ =Β rank(input)Β as follows:

IfΒ axesΒ are omitted, they are set toΒ [0,Β ...,Β r-1]. IfΒ stepsΒ are omitted, they are set toΒ [1,Β ...,Β 1]Β of lengthΒ len(starts)

The effective values are initialized asΒ startΒ =Β 0,Β endsΒ =Β dimsΒ whereΒ dimsΒ are the dimensions ofΒ inputΒ andΒ stepsΒ =Β 1.

All negative elements ofΒ axesΒ are made non-negative by addingΒ rΒ to them, whereΒ rΒ =rank(input).

All negative values inΒ startsΒ andΒ endsΒ haveΒ dims[axes]Β added to them, whereΒ dimsΒ are the dimensions ofΒ input. ThenΒ start[axes]Β is the adjustedΒ startsΒ is clamped into the rangeΒ [0,Β dims[axes]]Β for positive stepping andΒ [0,Β dims[axes]-1]Β for negative stepping.

The clamping for the adjustedΒ endsΒ depends on the sign ofΒ stepsΒ and must accommodate copying 0 throughΒ dims[axes]Β elements, so for positive steppingΒ ends[axes]Β is clamped toΒ [0,Β dims[axes]], while for negative stepping it is clamped toΒ [-1,Β dims[axes]-1].

Finally,Β steps[axes]Β =Β steps.

For slicing to the end of a dimension with unknown size, it is recommended to pass inΒ INT_MAXΒ when slicing forward and β€˜INT_MIN’ when slicing backward.

 

 

Input parameters

 

specified_outputs_name :Β array, this parameter lets you manually assign custom names to the output tensors of a node.

Β Graphs in :Β cluster, ONNX model architecture.

data (heterogeneous) – T : object, tensor of data to extract slices from.
starts (heterogeneous) – Tind : object, 1-D tensor of starting indices of corresponding axis inΒ axes.
ends (heterogeneous) – Tind : object, 1-D tensor of ending indices (exclusive) of corresponding axis inΒ axes.
axes (optional, heterogeneous) – Tind : object, 1-D tensor of axes thatΒ startsΒ andΒ ends apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated.
steps (optional, heterogeneous) – Tind : object, 1-D tensor of slice step of corresponding axis inΒ axes. Negative value means slicing backward. β€˜steps’ cannot be 0. Defaults to 1s.

Β Parameters :Β cluster,

Β training?Β :Β boolean, whether the layer is in training mode (can store data for backward).
Default value β€œTrue”.
Β lda coeff :Β float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value β€œ1”.

Β name (optional) :Β string,Β name of the node.

Output parameters

output (heterogeneous) – T : object, sliced data tensor.

Type Constraints

T in (tensor(bfloat16),Β tensor(bool),Β tensor(complex128),Β tensor(complex64),Β tensor(double),Β tensor(float),Β tensor(float16),Β 
tensor(int16),Β tensor(int32),Β tensor(int64),Β tensor(int8),Β tensor(string),Β tensor(uint16),Β tensor(uint32),Β tensor(uint64),Β tensor(uint8)) : Constrain input and output types to all tensor types.

Tind in (tensor(int32),Β tensor(int64)) : Constrain indices to integer types

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents