Dot

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

  • asdBlasMakeDotPlan: initializes the Dot operator configuration corresponding to the handle.
  • asdBlasSdot: computes the dot product of two real number vectors.
  • asdBlasCdotu: computes the dot product of two complex number vectors.
  • asdBlasCdotc: computes the dot product of one complex number vector after conjugation and another complex number vector.

Formula:

  • asdBlasSdot formula:
    • Example:

      Input x:

      [1.0, 2.0]

      Input y:

      [1.0, 2.0]

      After the Sdot operator is called, the output result is as follows:

      5.0
  • asdBlasCdotu formula: ,

    where x[i] and y[i] are complex numbers.

    • Example:

      Input x:

      [ 0.1554+0.8840j, -0.3564-0.2552j]

      Input y:

      [-0.1404+1.3380j, -0.4876+0.1842j]

      After the Cdotu operator is called, the output result is as follows:

      -0.9838+0.1425j
  • asdBlasCdotc formula: ,

    where x[i] and y[i] are complex numbers, and conj indicates the conjugate operation.

    • Example:

      Input x:

      [ 0.1554+0.8840j, -0.3564-0.2552j]

      Input y:

      [-0.1404+1.3380j, -0.4876+0.1842j]

      After the Cdotc operator is called, the output result is as follows:

      1.2877-0.1420j

Function Prototype

  • AspbStatus asdBlasMakeDotPlan(asdBlasHandle handle)
  • AspbStatus asdBlasSdot(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx, aclTensor *y,const int64_t incy, aclTensor *result)
  • AspbStatus asdBlasCdotu(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx, aclTensor *y,const int64_t incy, aclTensor *result)
  • AspbStatus asdBlasCdotc(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx, aclTensor *y,const int64_t incy, aclTensor *result)

Parameter Description

  • asdBlasMakeDotPlan

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    Handle of the Dot operator.

  • asdBlasSdot & asdBlasCdotu & asdBlasCdotc

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    Handle of the Dot operator.

    n

    Input

    const char

    Number of elements in vector x or vector y.

    x

    Input

    aclTensor *

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

    • For Sdot, the supported data type is FLOAT32.
    • For Cdotc and Cdotu, the supported data type is COMPLEX64.

    incx

    Input

    const int64_t

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

    y

    Input

    aclTensor *

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

    • For Sdot, the supported data type is FLOAT32.
    • For Cdotc and Cdotu, the supported data type is COMPLEX64.

    incy

    Input

    const int64_t

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

    result

    Output

    aclTensor *

    result in the formula, which is a tensor on the device. The supported data type is FLOAT32. It contains only one element. The data format supports ND, and the shape is [1].

Return Value Description

For details about the return values, see Return Value.

Constraints

  • asdBlasMakeDotPlan: none.
  • asdBlasSdot
    • The input element count n currently supports the range [1, 6.71e+06].
    • The input shape of the operator is [n], and the output shape is [1].
    • The operator does not support the calculation for three or more dimensions.
  • asdBlasCdotu & asdBlasCdotc
    • The input element count n currently supports the range [1, 6.71e+06].
    • The input shape of the operator is [n], and the output shape is [1].
    • The operator does not support the calculation for three or more dimensions.

Calling Example

For details about the operator calling example, see Dot.