rsInterpolationBySinc
Applicable Products
Hardware Model |
Supported or Not |
|---|---|
Not supported |
|
Not supported |
|
Not supported |
|
Supported |
|
Not supported |
Function Description
API function
- rsInterpolationBySincGetWorkspaceSize: calculates the workspace size required by the rsInterpolationBySinc operator.
To use the rsInterpolationBySinc operator, you need to call the rsInterpolationBySincGetWorkspaceSize API to obtain the workspace size required for calculation and the executor that contains the operator calculation process, and then call the rsInterpolationBySinc API to perform computation.
rsInterpolationBySinc: implements one-dimensional complex vector interpolation calculation with batch. The shape and size of the returned result are the same as those of the interpolation coordinates.
Formula:
- rsInterpolationBySinc formula:

n is the real signal index, x[n] is the original real signal sequence, and sinc (d-n) is the interpolation coefficient. They need to be transferred as parameters in this operator.
- Example:
[ 1 + i , 2 + i ]
Input sincTab: (intp_num = 2, quant_num = 2)
[ [ 1 , 0 ], [ 0.5 , 0.5 ], [ 0 , 1 ] ]
Original pos:
[ 0.2 , 1.6 ]
Input posFloor after conversion: floor(Pos)
[ 0 , 1 ]
Input posToTabIndex after conversion: round((Pos -posFloor) *quant_num)
[ 0 , 1 ]
The tab size is 2 x 3. Because pos[0] = 0.2, inputTensor[0] and the following element inputTensor[1] are used for vector point multiplication with sincTab[posToTabIndex[0]] to obtain outputTensor[0]. Subsequent elements are computed in sequence. The computation formula is as follows:
pos[0] = 0.3 → outputTensor[0] = [1 + i , 2 + i] · [ 1 , 0 ] = 1 + i pos[1] = 1.6 → outputTensor[1] = [2 + i , 2 + i] · [ 0.5 , 0.5 ] = 2 + i
After the rsInterpolationBySinc operator is called, the output outputTensor is as follows:
[ 1 + i , 2 + i ]
Function Prototype
- AspbStatus rsInterpolationBySincGetWorkspaceSize(const aclTensor *inputTensor, const aclTensor *sincTab,const aclTensor *posFloor, const aclTensor *posToTabIndex,aclTensor *outputTensor, int interpNum, int quantNum, int length,size_t *workspaceSize)
- AspbStatus rsInterpolationBySinc(const aclTensor *inputTensor, const aclTensor *sincTab,const aclTensor *posFloor, const aclTensor *posToTabIndex,aclTensor *outputTensor, int interpNum, int quantNum, int interpLength,void *stream, void *workSpace = nullptr)
Parameter Description
- rsInterpolationBySincGetWorkspaceSize
Parameter
Input/Output
Type
Description
inputTensor
Input
const aclTensor *
Original signal, which is a tensor on the device. The data type can be COMPLEX64, the data format can be ND, and the shape is [batch, signalLength].
sincTab
Input
const aclTensor *
Interpolation coefficient matrix, which is a tensor on the device. The data type can be FLOAT32, the data format can be ND, and the shape is [4, ((quantNum + 1) * 2) * (interpNum * 2 + 8)].
posFloor
Input
const aclTensor *
Floor value of the interpolation point coordinates, a tensor on the device. The data type can be INT32, the data format can be ND, and the shape is [batch, length].
posToTabIndex
Input
const aclTensor *
The row index into the interpolation coefficient matrix, computed from the interpolation point coordinates through round((Pos - posFloor) * quantNum). A Tensor on the device. The data type supcan be ports INT16_T, the data format can be ND, and the shape is [batch, length].
outputTensor
Output
aclTensor *
Interpolation result, which is a tensor on the device. The data type can be COMPLEX64, the data format can be ND, and the shape is [batch, length].
interpNum
Input
int
Number of interpolation points.
quantNum
Input
int
Number of quantization points.
length
Input
int
Interpolation length.
workspaceSize
Output
size_t *
Workspace required by the rsInterpolationBySinc operator.
-
Parameter
Input/Output
Type
Description
inputTensor
Input
const aclTensor *
Original signal, which is a tensor on the device. The data type can be COMPLEX64, the data format can be ND, and the shape is [batch, signalLength].
sincTab
Input
const aclTensor *
Interpolation coefficient matrix, which is a tensor on the device. The data type can be FLOAT32, the data format can be ND, and the shape is [4, ((quantNum + 1) * 2) * (interpNum * 2 + 8)].
posFloor
Input
const aclTensor *
Floor value of the interpolation point coordinates, a tensor on the device. The data type can be INT32, the data format can be ND, and the shape is [batch, length].
posToTabIndex
Input
const aclTensor *
The row index into the interpolation coefficient matrix, computed from the interpolation point coordinates through round((Pos - posFloor) * quantNum). A Tensor on the device. The data type supcan be ports INT16_T, the data format can be ND, and the shape is [batch, length].
outputTensor
Output
aclTensor *
Interpolation result, which is a tensor on the device. The data type can be COMPLEX64, the data format can be ND, and the shape is [batch, length].
interpNum
Input
int
Number of interpolation points.
quantNum
Input
int
Number of quantization points.
length
Input
int
Interpolation length.
stream
Input
void *
NPU execution stream.
workSpace
Input
void *
Workspace address.
Return Value Description
For details about the return values, see Return Value.
Constraints
- rsInterpolationBySincGetWorkspaceSize
- rsInterpolationBySinc
- The theoretical range of the number of input elements is [1, 3.93e+09].
- The input shape is [batch, signalLength], [ 4, ((quantNum + 1) * 2) * (interpNum * 2 + 8)], [batch, length] and [batch, length], and the output shape is [batch, length].
- The operator does not support the calculation for three or more dimensions.
- The value of interpNum must be an even number. Generally, the value range is [8, 12, 16]. In the current version, the maximum value is 16.
- quantNum is a power of 2 and the maximum value is 32.
- The inputTensor, posFloor, and posToTabIndex have the same batch number in dimension 0. The length of outTensors is the same as that of posFloor and posToTabIndex.
- sincTab: Pre-processing is required to convert complex point multiplication into real point multiplication and make it more affinity with the NPU. Therefore, sincTab needs to be extended to [ ((quantNum + 1) * 2) * (interpNum * 2 + 8) * 4]. For details, check the pre-processing content in rsInterpolationBySinc.
Calling Example
For details about the operator calling example, see rsInterpolationBySinc.