Operator Reference

create_dl_layer_sliceT_create_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_slice (Operator)

create_dl_layer_sliceT_create_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_slice — Create a slice layer.

Signature

Herror T_create_dl_layer_slice(const Htuple DLLayerInput, const Htuple LayerName, const Htuple Axes, const Htuple StartIndices, const Htuple EndIndices, const Htuple Steps, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerSlice)

void CreateDlLayerSlice(const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Axes, const HTuple& StartIndices, const HTuple& EndIndices, const HTuple& Steps, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerSlice)

HDlLayer HDlLayer::CreateDlLayerSlice(const HString& LayerName, const HTuple& Axes, const HTuple& StartIndices, const HTuple& EndIndices, const HTuple& Steps, const HTuple& GenParamName, const HTuple& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerSlice(const HString& LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerSlice(const char* LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerSlice(const wchar_t* LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

def create_dl_layer_slice(dllayer_input: HHandle, layer_name: str, axes: MaybeSequence[Union[int, str]], start_indices: MaybeSequence[int], end_indices: MaybeSequence[int], steps: MaybeSequence[int], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> HHandle

Description

The operator create_dl_layer_slicecreate_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_slice creates a slice layer that extracts a single slice of a tensor along specified axes, based on the provided start and end indices as well as the step size for the slicing operations. The handle of the slice layer is returned in DLLayerSliceDLLayerSliceDLLayerSliceDLLayerSlicedllayer_slice.

The parameter DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input determines the feeding input layer and expects the layer handle as value.

The parameter LayerNameLayerNameLayerNamelayerNamelayer_name sets an individual layer name. Note that if creating a model using create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model each layer of the created network must have a unique name.

The following parameters are used for the slice operation:

'starts'"starts""starts""starts""starts"

Determines the starting indices of the slice operation along the axes specified in 'axes'"axes""axes""axes""axes". This parameter is set using StartIndicesStartIndicesStartIndicesstartIndicesstart_indices.

'ends'"ends""ends""ends""ends"

Determines the ending indices of the slice operation along the axes specified in 'axes'"axes""axes""axes""axes". This parameter is set using EndIndicesEndIndicesEndIndicesendIndicesend_indices.

'steps'"steps""steps""steps""steps"

Determines the step size for the slicing operation along the axes specified in 'axes'"axes""axes""axes""axes". The parameter 'steps'"steps""steps""steps""steps" must either be an empty tuple or have the same length as 'axes'"axes""axes""axes""axes". If it is empty, the 'steps'"steps""steps""steps""steps" are set to 1 for all 'axes'"axes""axes""axes""axes". This parameter is set using StepsStepsStepsstepssteps.

'axes'"axes""axes""axes""axes"

Specifies the axes along which the slicing operation is performed. The axes are defined in the format WHC, representing Width, Height, and Channel and can also be specified as strings. Slicing in the Batch dimension is not supported. This parameter is set using AxesAxesAxesaxesaxes.

The slice layer allows slicing a tensor along specified axes, providing flexible adjustment options. To ensure correct operations 'starts'"starts""starts""starts""starts" and 'ends'"ends""ends""ends""ends" must have the same length as the parameter 'axes'"axes""axes""axes""axes". Negative values in 'starts'"starts""starts""starts""starts" and 'ends'"ends""ends""ends""ends" are adjusted by adding the size of the corresponding array dimension, effectively allowing negative indexing for one iteration. After that, negative values are clamped to prevent further out-of-bounds slicing.

Negative values in 'axes'"axes""axes""axes""axes" are adjusted by adding the total number of dimensions of the tensor to the respective axis. Negative value means counting dimensions from the back. The accepted range is [ , ] where = rank. For slicing to the end of a dimension with unknown size, it is recommended to pass in H_INT_MAX when slicing forward and H_INT_MIN when slicing backward.

Handling of axes and indices

Adjusting axes

Negative values in the 'axes'"axes""axes""axes""axes" parameter are made non-negative by adding the rank of the input tensor to each negative axis:

Adjusting 'starts' and 'ends'

Negative Index Adjustment

Negative values in 'starts'"starts""starts""starts""starts" and 'ends'"ends""ends""ends""ends" are adjusted by adding the respective tensor dimension size:

'starts'"starts""starts""starts""starts"[ ] is adjusted by adding the tensor dimension size.

'ends'"ends""ends""ends""ends"[ ] is adjusted by adding the respective tensor dimension size.

Clamping 'starts' Values

Adjusted 'starts'"starts""starts""starts""starts" values are clamped to the range:

Clamping 'ends' Values

Adjusted 'ends'"ends""ends""ends""ends" values are clamped based on the step direction:

  • Positive Stepping: 'ends'"ends""ends""ends""ends" is clamped to the range [0, dims].

  • Negative Stepping: 'ends'"ends""ends""ends""ends" is clamped to the range [-1, dims - 1].

The following generic parameters GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and the corresponding values GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value are supported:

'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output":

Determines whether apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelapply_dl_model will include the output of this layer in the dictionary DLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch even without specifying this layer in OutputsOutputsOutputsoutputsoutputs ('true'"true""true""true""true") or not ('false'"false""false""false""false").

List of values: 'true'"true""true""true""true", 'false'"false""false""false""false"

Default: 'false'"false""false""false""false"

Certain parameters of layers created using this operator create_dl_layer_slicecreate_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_slice can be set and retrieved using further operators. The following tables give an overview, which parameters can be set using set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and which ones can be retrieved using get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param or get_dl_layer_paramget_dl_layer_paramGetDlLayerParamGetDlLayerParamget_dl_layer_param. Note, the operators set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param require a model created by create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model.

Layer Parameters set get
'input_layer'"input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input) x
'name'"name""name""name""name" (LayerNameLayerNameLayerNamelayerNamelayer_name) x x
'axes'"axes""axes""axes""axes" x
'starts'"starts""starts""starts""starts" x
'ends'"ends""ends""ends""ends" x
'steps'"steps""steps""steps""steps" x
'output_layer'"output_layer""output_layer""output_layer""output_layer" (DLLayerSliceDLLayerSliceDLLayerSliceDLLayerSlicedllayer_slice) x
'shape'"shape""shape""shape""shape" x
'type'"type""type""type""type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output" x x
'num_trainable_params'"num_trainable_params""num_trainable_params""num_trainable_params""num_trainable_params" x

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (input_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Feeding layer.

Default: 'DLLayerInput' "DLLayerInput" "DLLayerInput" "DLLayerInput" "DLLayerInput"

LayerNameLayerNameLayerNamelayerNamelayer_name (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the output layer.

AxesAxesAxesaxesaxes (input_control)  number(-array) HTupleMaybeSequence[Union[int, str]]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)

Axes used for slicing.

Default: 0

Suggested values: 0, 'width'"width""width""width""width", 1, 'height'"height""height""height""height", 2, 'depth'"depth""depth""depth""depth"

StartIndicesStartIndicesStartIndicesstartIndicesstart_indices (input_control)  number(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Starting indices of corresponding axes (inclusive).

Default: 0

EndIndicesEndIndicesEndIndicesendIndicesend_indices (input_control)  number(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Ending indices of corresponding axes (exclusive).

Default: 1

StepsStepsStepsstepssteps (input_control)  number(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Slicing steps.

Default: []

GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Generic input parameter names.

Default: []

List of values: 'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output"

GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.value(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Generic input parameter values.

Default: []

Suggested values: 'true'"true""true""true""true", 'false'"false""false""false""false"

DLLayerSliceDLLayerSliceDLLayerSliceDLLayerSlicedllayer_slice (output_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Output layer.

Module

Deep Learning Professional