Erase

group Erase

Unnamed Group

NVCVStatus cvcudaEraseSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, NVCVTensorHandle anchor, NVCVTensorHandle erasing, NVCVTensorHandle values, NVCVTensorHandle imgIdx, int8_t random, uint32_t seed)

Executes the erase operation on the given cuda stream. This operation does not wait for completion.

Limitations:

Input: Data Layout: [kNHWC, kHWC, kNCHW, kCHW] Channels: 1, 2, 3, 4

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

16bit Float

No

32bit Float

Yes

64bit Float

No

Output: Data Layout: [kNHWC, kHWC, kNCHW, kCHW] Channels: 1, 2, 3, 4

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

16bit Float

No

32bit Float

Yes

64bit Float

No

Input/Output dependency

 Property      |  Input == Output
-------------- | -------------
 Data Layout   | Yes
 Data Type     | Yes
 Number        | Yes
 Channels      | Yes
 Width         | Yes
 Height        | Yes

In-place execution is selected by passing the same handle for in and out. There is no separate in-place parameter. When in and out are different handles, the operation copies in to out before applying the erase areas. Passing different handles that partially alias the same storage is not a supported aliasing mode.

anchor Tensor

Must be 'N' (dim = 1) with N = number of erasing area.
Data Type must be 32bit Signed.
DataType must be TYPE_2S32.

erasing Tensor

Must be 'N' (dim = 1) with N = number of erasing area.
Data Type must be 32bit Signed.
DataType must be TYPE_3S32.

imgIdx Tensor

Must be 'N' (dim = 1) with N = number of erasing area.
Data Type must be 32bit Signed.
DataType must be TYPE_S32.

values Tensor

Must be 'N' (dim = 1) with W = number of erasing area * 4.
Data Type must be 32bit Float.
DataType must be TYPE_F32.

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

    • Must not be NULL.

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

  • in[in] input tensor / image batch.

  • out[out] output tensor / image batch.

  • anchor[in] an array of size num_erasing_area that gives the x coordinate and y coordinate of the top left point in the erasing areas.

  • erasing[in] an array of size num_erasing_area that gives the widths of the erasing areas, the heights of the erasing areas and integers in range 0-15, each of whose bits indicates whether or not the corresponding channel need to be erased.

  • values[in] an array of size num_erasing_area*4 that gives the filling value for each erase area.

  • imgIdx[in] an array of size num_erasing_area that maps a erase area idx to img idx in the batch.

  • random[in] an boolean for random op.

  • seed[in] random seed for random filling erase area.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaEraseVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, NVCVTensorHandle anchor, NVCVTensorHandle erasing, NVCVTensorHandle values, NVCVTensorHandle imgIdx, int8_t random, uint32_t seed)
NVCVStatus cvcudaEraseRegionSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, int64_t i, int64_t j, int64_t h, int64_t w, NVCVTensorHandle values)

Executes a torchvision-compatible single-region erase on the given CUDA stream. This operation does not wait for completion.

The operation is equivalent to the following assignment on the logical planar view of the input:

out = in.clone()
out[..., i:i+h, j:j+w] = values

Passing the same tensor handle for in and out performs the assignment in place. Negative, empty, and out-of-bounds regions follow Python’s step-one slice rules. For interleaved layouts, values is still broadcast against the logical planar shape (N, C, h, w) or (C, h, w).

Reference: torchvision.transforms.v2.functional.erase.

This overload is independent of the max_num_erasing_area capacity supplied to cvcudaEraseCreate.

Limitations:

Input / Output: Container: Tensor only Data Layout: [kNHWC, kHWC, kNCHW, kCHW] Channels: [1, 2, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

Yes

32bit Signed

Yes

64bit Unsigned

Yes

64bit Signed

Yes

16bit Float

Yes

32bit Float

Yes

64bit Float

Yes

Values: Rank must not exceed four. Dimensions are right-aligned against the logical (N, C, H, W) shape, with N = 1 for unbatched inputs, and each must equal the corresponding selected-region dimension or be one for broadcasting. The dtype must match the input dtype or be 32-bit float. Float-to-integer conversion matches CUDA PyTorch assignment semantics, including for non-finite and out-of-range values.

Parameters:
  • handle[in] Handle to the operator. Must not be NULL.

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

  • in[in] Input image tensor.

  • out[out] Output image tensor. Shape, layout, and dtype must match in.

  • i[in] Vertical slice start.

  • j[in] Horizontal slice start.

  • h[in] Vertical slice extent used to form the exclusive stop i + h.

  • w[in] Horizontal slice extent used to form the exclusive stop j + w.

  • values[in] Value tensor to broadcast into the selected region.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – A tensor or parameter violates the contract above.

  • NVCV_SUCCESS – Operation submitted successfully.

Functions

NVCVStatus cvcudaEraseCreate(NVCVOperatorHandle *handle, int32_t max_num_erasing_area)

Constructs and an instance of the erase operator.

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

    • Must not be NULL.

  • max_num_erasing_area[in] the maximum number of areas that will be erased.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.