Formula:
- Core forward algorithm logic:
- Scale the destination image to the same size as the source image.
- Calculate points of the scaled destination image and points of adjacent source images.
- Calculate the weights from the adjacent points to the target points, and multiply and accumulate the weights to obtain the target point values.
- Calculation logic:
An image can be scaled by corner alignment (that is, based on the center point of the pixels in the upper left corner of the source image) or edge alignment (that is, based on the vertex in the upper left corner and two edges of the source image). The two modes differ in the scaling factor and coordinates. Then:
Therefore, for a point p (x, y) in a direction of the output, a point mapped back to the source image is denoted as q (x', y'). Then:
Denoted:
Then:
Assume that the output image out for forward interpolation is affected by the original image input . Then:
- Core forward algorithm logic:
Each operator has calls. First, aclnnUpsampleLinear1dBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnUpsampleLinear1dBackward is called to perform computation.
Parameters:
[object Object][object Object]Atlas training products[object Object]:
The data types of the input parameter
[object Object]and output parameter[object Object]must be FLOAT32 or FLOAT16.[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
Input parameter
[object Object]: If the shape of gradOut is different from that of inputSize, the data type can only be FLOAT32 or FLOAT16.
Returns:
aclnnStatus: status code. For details, see .
The first-phase API implements input parameter verification. The following errors may be thrown.
[object Object]
The shape constraints of
[object Object]and[object Object]are as follows:The value of each dimension is less than or equal to 2^20.
The N and C axes of
[object Object]must be the same as those of[object Object].The memory usage must be less than 60 GB. The memory size can be calculated according to the following formula:
Where,
- N indicates the N axis of the input and output.
- C indicates the C axis of the input and output.
N * C < 2^31
If the data formats of the input parameter
[object Object]and output parameter[object Object]are not NCL or ND, the input data is processed as NCL format by default.[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The upscaling factor for input data must be less than or equal to 500, that is, .
Either outputSize or scales must be used.
- If alignCorners is set to True:
- If outputSize is equal to 1, the value of scales is 0.
- In other cases, the values of the input parameters inputSize and outputSize are used, and .
- If alignCorners is set to False:
- If the value of scales is less than or equal to 0, the value of outputSize is used, that is, .
- If the value of scales is greater than 0 and is not met, the value of outputSize is used. Otherwise, the value of scales is used.
- If alignCorners is set to True:
Deterministic computing:
- aclnnUpsampleLinear1dBackward defaults to a deterministic implementation.
The following example is for reference only. For details, see .