Cal

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:

  • asdBlasMakeCalPlan: initializes the Cal operator configuration corresponding to the handle.
  • asdBlasSscal: performs scaling on a real-numbered vector. That is, each element in the vector is multiplied by a real-number alpha.
  • asdBlasCsscal: performs scaling on a complex-number vector. That is, each element in the vector is multiplied by a real-number alpha.
  • asdBlasCscal: performs scaling on a complex-number vector. That is, each element in the vector is multiplied by a complex-number alpha.

Formula:

  • asdBlasSscal formula:
    • Example:

      Input x:

      [3.0, 4.0]

      Input alpha: 2.0

      After the Sscal operator is called,

      Output x:

      [6.0, 8.0]
  • asdBlasCsscal formula:
    • Example:

      Input x:

      [3.0 + 4.0j, 4.0 + 4.0j]

      Input alpha: 2.0

      After the Csscal operator is called, the Output x is as follows:

      [6.0 + 8.0j, 8.0 + 8.0j]
  • asdBlasCscal formula:
    • Example:

      Input x:

      [3.0 + 4.0j, 4.0 + 4.0j]

      Input alpha:

      (3.0 + 4.0j)

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

      [-7.0 + 24.0j, -4.0 + 28.0j]

Function Prototype

  • AspbStatus asdBlasMakeCalPlan(asdBlasHandle handle)
  • AspbStatus asdBlasSscal(asdBlasHandle handle, const int64_t n, const float &alpha, aclTensor *x, const int64_t incx)
  • AspbStatus asdBlasCsscal(asdBlasHandle handle, const int64_t n, const float &alpha, aclTensor *x, const int64_t incx)
  • AspbStatus asdBlasCscal(asdBlasHandle handle, const int64_t n, const std::complex<float> &alpha, aclTensor *x,const int64_t incx)

Parameter Description

  • asdBlasMakeCalPlan

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    cal operator handle.

  • asdBlasSscal & asdBlasCsscal & asdBlasCscal

    Parameter

    Input/Output

    Type

    Description

    handle

    Input

    asdBlasHandle

    sscal operator handle.

    n

    Input

    const int64_t

    Total number of elements.

    alpha

    Input

    const float &

    The scalar factor alpha applied to the vector.

    x

    Input/Output

    aclTensor *

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

    incx

    Input

    const int64_t

    Memory address increment between the consecutive elements (currently, the offset is 1).

Return Value Description

For details about the return values, see Return Value.

Constraints

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

Calling Example

For details about the operator calling example, see Cal.