DepthToSpace#

Functions#

NVCVStatus pvaDepthToSpaceCreate(NVCVOperatorHandle *handle, NVCVTensorRequirements const *const tensorRequirements, int32_t blkSz)

Constructs an instance of the DepthToSpace operator.

NVCVStatus pvaDepthToSpaceSubmit(NVCVOperatorHandle handle, cupvaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out)

Executes the DepthToSpace operation on a NCHW tensor.

Functions#

NVCVStatus pvaDepthToSpaceCreate(
NVCVOperatorHandle *handle,
NVCVTensorRequirements const *const tensorRequirements,
int32_t blkSz,
)#

Constructs an instance of the DepthToSpace operator.

DepthToSpace squeezes the depth dimension and moves the squeezed elements into both the width and height dimension. Depth here is the synonym of the channel dimension and these two are used interchangeably. After performing the DepthToSpace operation, the total number elements keep the same. The output width and height dimension are both enlarged by a ratio, which is called block size parameter of the DepthToSpace operation. The reverse operation is called SpaceToDepth. More info can also be found in https://onnx.ai/onnx/operators/onnx__DepthToSpace.html

Input: Data Layout: [CHW] Note that this operator only supports tightly packed layout for both input and output, which means that strides[1] must equal shape[2] in the tensorRequirements struct.

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

Output: Data Layout: [CHW]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

Input/Output Dependency:

Property

Input == Output

Data Layout

Yes

Data Type

Yes

Number

Yes

Channels

No, Output Channels = (Input Channels) / (blkSz^2). Note that input channels should be multiple of (blkSz^2).

Width

No, Output Width = (Input Width) * (blkSz)

Height

No, Output Height = (Output Height) * (blkSz)

Parameters:
  • handle[out] Where the operator instance handle will be written to.

    • Must not be NULL.

  • tensorRequirements[in] Pointer to the NVCVTensorRequirements structure which contains Tensor rank, shape, layout and data type information.

  • blkSz[in] Block size, only supports 2 or 3 or 4. The implementation will use this parameter as well as the tensor size within tensorRequirements to do the tiling and mapping table generation, which is not light weight. Therefore, the blkSz parameter is specified during the create phase instead of the submission phase.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – The possible cases might be the following: 1) Either tensorRequirements is NULL or handle and tensorRequirements point to an invalid address. 2) Block size is not either 2 or 3 or 4. 3) The channel number is not multiple of block size. 4) The tensor is not in NCHW layout, or data type is not either 8bit signed or unsigned. 5) Auto tiling algorithm fails to find a reasonable tile size.

  • NVCV_ERROR_OUT_OF_MEMORY – The possible cases might be the following: 1) Failed to allocate memory for the operator. 2) Failed to allocate memory for holding the mapping table, which the host initializes then send it for the device’s use.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus pvaDepthToSpaceSubmit(
NVCVOperatorHandle handle,
cupvaStream_t stream,
NVCVTensorHandle in,
NVCVTensorHandle out,
)#

Executes the DepthToSpace operation on a NCHW tensor.

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid CUPVA stream.

  • in[in] Input tensor handle.

  • out[out] Output tensor handle.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – The possible cases might be the following: 1) The handle or stream or in or out is either NULL or points to an invalid address. 2) The input or output tensor does not meet the requirements used to create the operator handle.

  • NVCV_SUCCESS – Operation executed successfully.