[object Object][object Object][object Object]undefined
[object Object]
  • Description: Performs matrix multiplication between the self tensor and the mat2 tensor. The mat2 tensor supports only the NZ format. The self tensor must be 2-dimensional, and the mat2 tensor must be 4-dimensional. Similar APIs include aclnnMatmul (mat2 supports only ND), aclnnMm (supporting matrix multiplication with 2-dimensional tensors as the input), and aclnnBatchMatmul (supporting only 3-dimensional matrix multiplication, where the first dimension is batch).
  • Formula:result=self@mat2result=self @ mat2
[object Object]

Each operator has calls. First, aclnnMatmulWeightNzGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnMatmulWeightNz is called to perform computation.

[object Object]
[object Object]
[object Object]
  • Parameters

    [object Object]
    • [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
      • Before calling this API, you must use the aclnnTransMatmulWeight API to convert the original format of mat2 from ND to NZ.
      • When cubeMathType is set to 4, if the input data type is FLOAT32 and the k-axis is greater than 2048, grouped accumulation is used for computation. If the input data type is not FLOAT32 or the k-axis is less than 2048, no processing is performed.
    • Ascend 950PR/Ascend 950DT:
      • Before calling this API, you must use the aclnnNpuFormatCast API to convert the original format of mat2 from ND to NZ.
      • The option of cubeMathType being 1 (ALLOW_FP32_DOWN_PRECISION) is not supported.
      • The option of cubeMathType being 3 (USE_HF32) is not supported.
      • The option of cubeMathType being 4 (USE_FP32_ADD) is not supported.
  • Returns

    [object Object]: status code. For details, see .

    The first-phase API performs input parameter validation. The following errors may be returned:

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic description:

    • [object Object]Atlas training products[object Object], [object Object]Atlas inference products[object Object], and Ascend 950PR/Ascend 950DT: The default implementation of aclnnMatmulWeightNz is deterministic.
  • Computational Consistency Description

    • [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
      • If strong consistency compute is enabled, the compute result is deterministic, meaning that multiple executions will generate the same result. In addition, the compute result is irrelevant to the data location.
      • aclnnMatmulWeightNz defaults to a non-consistent implementation. You can call aclrtCtxSetSysParamOpt to enable consistency compute.
      • For example, during matrix multiplication, the accumulation sequence of different basic blocks may be different. As a result, the computation results of the same data in different rows may be slightly different. However, when strong consistency compute is enabled, the results will remain consistent across rows as long as the inputs are the same.
  • If one input is BFLOAT16 and the other is FLOAT16, the data type cannot be deduced.

  • self supports only two dimensions, and mat2 supports only the proprietary Ascend format. Before calling this API, you must convert mat2 from the ND format to the proprietary Ascend format.

  • The last two axes of mat2 cannot be 1 (k = 1 or n = 1).

  • It is recommended that this API be used in the MTE2 bound scenario, for example, when the M axis is small, matrix A is repeatedly moved, and matrix B is not repeatedly moved.

[object Object]
  • [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The data types of self and mat2 are float16. The sample code when mat2 is NZ format is as follows (for reference only). For details about the compilation and running process, see .

    [object Object]
  • Ascend 950PR/Ascend 950DT: The data types of self and mat2 are bfloat16. The sample code when mat2 is NZ format is as follows (for reference only). For details about the compilation and running process, see .

    [object Object]