rsInterpolationBySinc

Applicable Products

Hardware Model

Supported or Not

Atlas 200I/500 A2 inference products

Not supported

Atlas inference products

Not supported

Atlas training products

Not supported

Atlas A2 training products / Atlas A2 inference products

Supported

Atlas A3 training products / Atlas A3 inference products

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:

    Input inputTensor:

     [ 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, tensor on the device. The data type is COMPLEX64, the data format is ND, and the shape is [batch, signalLength].

    sincTab

    Input

    const aclTensor *

    Interpolation coefficient matrix, tensor on the device. The data type is FLOAT32, the data format is ND, and the shape is [ 4, ((quantNum + 1) * 2) * (interpNum * 2 + 8)].

    posFloor

    Input

    const aclTensor *

    A tensor of type int32 on the device, with shape [batch, length], for the rounded-down value of the interpolation point coordinates. The data format is ND.

    posToTabIndex

    Input

    const aclTensor *

    A tensor of type INT16_T on the device, with shape [batch, length]. It is used to calculate the row number of the interpolation coefficient matrix based on the coordinates of the interpolation point by using round((Pos -posFloor) *quantNum). The data format can be ND.

    outputTensor

    Output

    aclTensor *

    Interpolation result. Tensor on the device. The data type is COMPLEX64, the data format is 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.

  • rsInterpolationBySinc

    Parameter

    Input/Output

    Type

    Description

    inputTensor

    Input

    const aclTensor *

    Original signal, tensor on the device. The data type is COMPLEX64, the data format is ND, and the shape is [batch, signalLength].

    sincTab

    Input

    const aclTensor *

    Interpolation coefficient matrix, tensor on the device. The data type is FLOAT32, the data format is ND, and the shape is [ 4, ((quantNum + 1) * 2) * (interpNum * 2 + 8)].

    posFloor

    Input

    const aclTensor *

    A tensor of type int32 on the device, with shape [batch, length], for the rounded-down value of the interpolation point coordinates. The data format is ND.

    posToTabIndex

    Input

    const aclTensor *

    A tensor of type INT16_T on the device, with shape [batch, length]. It is used to calculate the row number of the interpolation coefficient matrix based on the coordinates of the interpolation point by using round((Pos -posFloor) *quantNum). The data format can be ND.

    outputTensor

    Output

    aclTensor *

    Interpolation result. Tensor on the device. The data type is COMPLEX64, the data format is 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 flow.

    workSpace

    Input

    void *

    Workspace address

Return Value Description

For details about the return values, see Return Value.

Constraints

  • rsInterpolationBySincGetWorkspaceSize

    None

  • 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.