Swap

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 inference products/Atlas A3 training products

Supported

Function Description

API function

  • asdBlasMakeSwapPlan: initializes the Swap operator configuration corresponding to the handle.
  • asdBlasSswap: swaps two real-number vectors.
  • asdBlasCswap: swaps two complex-number vectors.

Formula:

  • asdBlasSswap formula:
    • Example:

      The input x is as follows:

      [1.0, 2.0]

      The input y is as follows:

      [3.0, 4.0]

      After the Sswap operator is called, the output x is as follows:

      [3.0, 4.0]

      The output y is as follows:

      [1.0, 2.0]
  • asdBlasCswap formula:
    • Example:

      The input x is as follows:

      [1.0 + 1.0i, 2.0 + 2.0i]

      The input y is as follows:

      [3.0 + 3.0i, 4.0 + 4.0i]

      After the Cswap operator is called, the output x is as follows:

      [3.0 + 3.0i, 4.0 + 4.0i]

      The output y is as follows:

      [1.0 + 1.0i, 2.0 + 2.0i]

Function Prototype

  • AspbStatus asdBlasMakeSwapPlan(asdBlasHandle handle)
  • AspbStatus asdBlasSswap(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx, aclTensor *y, const int64_t incy)
  • AspbStatus asdBlasCswap(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx, aclTensor *y,const int64_t incy)

Parameter Description

  • asdBlasMakeSwapPlan

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    Handle of the Swap operator.

  • asdBlasSswap & asdBlasCswap

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    Handle of the Swap operator.

    n

    Input

    const int64_t

    Number of elements in vector x (or y)

    x

    Input/Output

    aclTensor *

    x in the formula, which is a tensor on the device. The data format can be ND, and the shape is [n].

    • For Sswap, the supported data type is FLOAT32.
    • For Cswap, the supported data type is COMPLEX64.

    incx

    Input

    const int64_t

    Memory address increment between consecutive elements of x (currently restricted to 1).

    y

    Input

    /Output

    aclTensor *

    y in the formula, which is a tensor on the device. The data format can be ND, and the shape is [n].

    • For Sswap, the supported data type is FLOAT32.
    • For Cswap, the supported data type is COMPLEX64.

    incy

    Input

    const int64_t

    Memory address increment between consecutive elements of y (currently restricted to 1).

Return Value Description

For details about the return values, see Return Value.

Constraints

  • asdBlasMakeSwapPlan: none.
  • asdBlasSswap
    • The input and output data formats, data types, and shapes must be consistent.
    • The input element count n currently supports the range [1, 6.71e+07].
    • The input shape of the operator is [n] and [n], and the output shape is [n] and [n].
    • The operator does not support the calculation for three or more dimensions.
  • asdBlasCswap
    • The input and output data formats, data types, and shapes must be consistent.
    • The input element count n currently supports the range [1, 6.71e+07].
    • The input shape of the operator is [n] and [n], and the output shape is [n] and [n].
    • The operator does not support the calculation for three or more dimensions.

Calling Example

For details about the operator calling example, see Swap.