Clone

Function Usage

Prototype 1:

Performs a deep copy on a tensor and returns the copied tensor.

  • If the tensor is on the host, the copy process is synchronous.
  • If the tensor is on the DVPP or device, the synchronous or asynchronous operation needs to be determined based on the stream parameter. The device where the tensor is located must be the same as the device where the stream is located.

Prototype 2:

Performs deep copy on the specified region of a tensor. The content of the src region is copied to the region to which the tensor is assigned. The requirements are as follows:

  • Neither src nor the assigned tensor can be empty. The length and width of the assigned tensor are [64, 4096]. The maximum height of src cannot exceed 1048576, and the total size (N x H x W x C) of src cannot exceed 67108864.
  • src and the assigned tensor contain the reference rectangle (ReferRect) with the same height and width, and neither of them is 0. The width of ReferRect cannot exceed 1920.
  • The data types of src and the assigned tensor can be uint8 and float16, and the data types must be the same.
  • src and the assigned tensor support only NHWC, HWC, and HW tensors (the number of channels is 1 or 3, and N is 1). The dimensions and number of channels of src and the assigned tensor must be the same.
  • src and the assigned tensor must be on the DVPP or device.
  • src and the device where the value is assigned must be the same as the device where the stream is located.

Prototype

1
2
3
4
// Prototype 1:
Tensor Tensor::Clone(AscendStream &stream=AscendStream::DefaultStream()) const;
// Prototype 2 (not supported by Atlas inference products):
APP_ERROR Tensor::Clone(const Tensor &src, AscendStream &stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

src

Input

Assigns the reference specified region of src to the reference region of the tensor that executes the method.

stream

Input

AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation.

Response Parameters

Prototype 1:

Data Structure

Description

Tensor

Tensor class. For details, see Tensor.

Prototype 2:

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.