ViewCopy
Availability
Function Usage
Moves a contiguous tensor to a contiguous or non-contiguous tensor.
An input tensor of L2 API may be non-contiguous. Therefore, a contiguous tensor needs to be moved to a non-contiguous tensor by using this API.
An output tensor can be contiguous or non-contiguous, which will be processing in the API for better compatibility. However, it requires a contiguous input tensor.
Prototype
const aclTensor *ViewCopy(const aclTensor *x, const aclTensor *y, aclOpExecutor*executor)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
x |
Input |
Input tensor. The data type and format are not restricted. The input must be contiguous memory data. |
y |
Output |
Output tensor. The data type and format are not restricted, except that the data type, ViewShape, and data format must be the same as those of x. |
executor |
Input |
Operator executor, containing the operator computation process. |
Returns
Success: An output tensor is returned. Failure: nullptr is returned.
Constraints
The input tensor must be contiguous.
Example
1 2 3 4 | // (Fixed writing) Create an OpExecutor. auto uniqueExecutor = CREATE_EXECUTOR(); // If out is a non-contiguous tensor, the computed contiguous tensor must be converted into a non-contiguous tensor. auto viewCopyResult = l0op::ViewCopy(absResult, out, executor); |