Cgemv

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

  • asdBlasMakeCgemvPlan: initializes the Cgemv operator configuration corresponding to the handle.
  • asdBlasCgemv: matrix-vector multiplication, which is used to compute the product of complex matrix A and complex vector x. The result is stored in complex vector y.

Formula:

  • asdBlasCgemv formula: ,

    where . alpha and beta are scalars, x and y are vectors, and A is an m*n matrix.

  • Example:
    Input A:
    [   [ 1+i,1+2i ],
        [ 1+2i,1+3i ]  ]

    Input x:

    [ 2+i,2+2i ]

    Input y:

    [ 1+i,1+2i ]

    The input m is 2, the input n is 2, the input trans is 'N':2, the input alpha is 1+i, and the input beta is 2+2i.

    The input lda is 2, the input incx is 1, and the input incy is 1.

    asdBlasMakeCgemvPlan is called to generate a plan.

    After the asdBlasCgemv API is called, the output y is as follows:

    [ -10 + 12i,-19 + 15i]

Function Prototype

  • AspbStatus asdBlasMakeCgemvPlan(asdBlasHandle handle, asdBlasOperation_t trans, const int64_t m, const int64_t n,aclTensor *y, const int64_t incy)
  • AspbStatus asdBlasCgemv(asdBlasHandle handle, asdBlasOperation_t trans, const int64_t m, const int64_t n,const std::complex<float> *alpha, aclTensor *A, const int64_t lda, aclTensor *x,const int64_t incx, const std::complex<float> *beta, aclTensor *y, const int64_t incy)

Parameter Description

  • asdBlasMakeCgemvPlan

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    cgemv operator handle.

    trans

    Input

    asdBlasOperation_t

    Whether matrix A should be transposed.

    ASDBLAS_OP_N // Not transposed
    ASDBLAS_OP_T // Transposed
    ASDBLAS_OP_C // Conjugately transposed

    m

    Input

    const int64_t

    Number of rows of matrix A, and number of elements in vector y.

    n

    Input

    const int64_t

    Number of columns of matrix A, and number of elements in vector x.

    y

    Input

    aclTensor *

    Vector y.

    incy

    Input

    const int64_t

    Stride of vector y.

  • asdBlasCgemv

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    cgemv operator handle.

    trans

    Input

    asdBlasOperation_t

    Whether matrix A should be transposed.

    ASDBLAS_OP_N // Not transposed
    ASDBLAS_OP_T // Transposed
    ASDBLAS_OP_C // Conjugately transposed

    m

    Input

    const int64_t

    Number of rows of matrix A, and number of elements in vector y.

    n

    Input

    const int64_t

    Number of columns of matrix A, and number of elements in vector x.

    alpha

    Input

    const std::complex<float> *

    alpha in the formula is a complex scalar, and is used to multiply the result of the matrix and vector multiplication.

    A

    Input

    aclTensor *

    Matrix A in the formula, which is in column-major order and is a tensor on the device. The data type is COMPLEX64, the data format is ND, and the shape is [m, n].

    lda

    Input

    const int64_t

    Memory address increment between consecutive elements of A (currently restricted to m).

    x

    Input

    aclTensor *

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

    incx

    Input

    const std::complex<float>

    Stride of vector x (currently restricted to 1).

    beta

    Input

    const std::complex<float> *

    beta in the formula is a complex scalar, and is used to multiply vector y.

    y

    Input/Output

    aclTensor *

    Vector y in the formula, which is a tensor on the device. The data type can only be COMPLEX64, the data format can be ND, and the shape is [m].

    incy

    Input

    const int64_t

    Stride of vector y (currently restricted to 1).

Return Value Description

For details about the return values, see Return Value.

Constraints

  • asdBlasMakeCgemvPlan: none.
  • asdBlasCgemv
    • The input element count (m, n) currently supports the range [1, 8193].
    • The input matrix A of the operator is in column-major order. The input shape is [m, n], [m], or [n], and the output shape is [m].
    • The operator does not support the calculation for three or more dimensions.

Calling Example

For details about the operator calling example, see Cgemv.