目录

Data Type

In addition to not supporting the bfloat16_t data type, Kirin X90 and Kirin 9030 also have other data type differences in some APIs, such as MrgSort, Mmad basic APIs (such as float), and Cast basic APIs (such as s64). For details, see Ascend C Operator APIs. If you use the bfloat16_t data type on Ascend 910B or Ascend 910C, replace it with another data type (such as half) on the Kirin platform.

Table 1 Data type compatibility

Basic API Compatibility
ToBfloat16, ToFloat APIs whose functions are bound to the bfloat16_t data type are not supported.
GatherMask, Cast, Duplicate, Brcb, Gather, Copy, DataCopy The data type bfloat16_t is not supported.
Sort32, MrgSort, Mmad The data type float is not supported.
SetHF32Mode, SetHF32TransMode The HF32 mode is not supported.
InitConstValue The data types bfloat16_t, float, int32_t, and uint32_t are not supported.
LoadData, Fixpipe The data types bfloat16_t and float are not supported.
Cast For details, see Ascend C Operator APIs.
DataCopy: L1 Buffer->Bias Table Kirin X90 and Kirin 9030 supports only the fp16 data type, and the layout mode is different. For details, see Data Movement.

If the data types are different, you are advised to use the following programming methods to execute the same operator code on different chip platforms:

    /* Step 1: Parameterize the data type. */
#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201)
    using L0cDtype = float
#endif
#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3003 || __NPU_ARCH__ == 3113)
    using L0cDtype = half
#endif
    // ...
    /* Step 2: Perform normalized programming for each platform. */
    // Example of the memory size allocated by the kernel
    tPipe->InitBuffer(l0cQue, tiling.dbL0c, tiling.baseM * tiling.baseN * sizeof(L0cDtype));
    // ...
    // Example of the kernel mmad computation API
    mmad<L0cDtype, L0aDtype, L0bDtype, BiasDtype>(dstLocal, fmLocal, filterLocal, biasLocal, mmadParams);
  • For details about the NPU_ARCH of each product, see Table 1 Mapping between product models and NPU_ARCH in overview.

  • If the data type difference affects the input and output data types of the operator, method 1 is recommended.

  • If only the intermediate computing data type of the operator is different, method 2 is recommended.