High-Level API Porting Guide

Ascend C high-level APIs are basically compatible with the 351x and 220x architectures, and some APIs are extended. Currently, the 351x architecture does not support high-level APIs for convolution computation.

Matmul High-level APIs

  • Supported data types are changed.
    Table 1 Data type compatibility

    Matrix A

    Matrix B

    Bias Matrix

    Matrix C

    Description

    int4b_t

    int4b_t

    int32_t

    int32_t, half

    Not supported in the 351x architecture.

    fp8_e4m3fn_t, fp8_e5m2_t

    fp8_e4m3fn_t, fp8_e5m2_t

    float, half, bfloat16_t

    fp8_e4m3fn_t, half, bfloat16_t, float

    Added in the 351x architecture.

    hifloat8_t

    hifloat8_t

    float, half, bfloat16_t

    hifloat8_t, half, bfloat16_t, float

    Added in the 351x architecture.

    float

    float

    bfloat16_t

    float, half, bfloat16_t

    Added in the 351x architecture.

    bfloat16_t

    bfloat16_t

    bfloat16_t

    float, half, bfloat16_t

    Added in the 351x architecture.

    half

    half

    bfloat16_t

    float, half, bfloat16_t

    Added in the 351x architecture.

    int8_t

    int8_t

    int32_t

    bfloat16_t

    Added in the 351x architecture.

  • The 4:2 sparsity feature is not supported. For details about the compatibility solution, see the 4:2 structured sparsity.

Other High-Level APIs

Table 2 Mathematical computation

Ascend C High-Level API

Compatibility Description

Tanh, Asin, Sin, Acos, Cos, Log, Atan, Fmod

Compatible with the 220x architecture.

Extended support for algorithm configuration. The algorithm used by the API can be configured through template parameters, providing selection of high-precision and high-performance algorithms.

Sinh, Cosh, Tan, Trunc, Frac, Erf, Erfc, Atanh, Asinh,

Acosh, Floor, Ceil, Round, Axpy, Exp, Lgamma, Digamma, Xor, Cumsum

Compatible with the 220x architecture.

Power

Compatible with the 220x architecture.

Extended support for the uint8_t, int8_t, uint16_t, int16_t, uint32_t, and bfloat16_t data types.

Sign

Compatible with the 220x architecture.

Extended support for the int64_t data type.

Table 3 Activation functions

Ascend C High-Level API

Compatibility Description

SoftMax, SimpleSoftMax, SoftmaxFlash, SoftmaxGrad, SoftmaxFlashV2, SoftmaxFlashV3, SoftmaxGradFront, AdjustSoftMaxRes, LogSoftMax, FasterGelu, FasterGeluV2, Gelu, SwiGLU, Silu, Swish, GeGLU, ReFlu, Sigmoid

Compatible with the 220x architecture.

Table 4 Data normalization

Ascend C High-Level API

Compatibility Description

LayerNormGrad, LayerNormGradBeta, RmsNorm, BatchNorm, DeepNorm, GroupNorm

Compatible with the 220x architecture.

Normalize, WelfordUpdate

Compatible with the 220x architecture.

Extended support for the bfloat16_t data type.

LayerNorm

Compatible with the 220x architecture.

Extended support for variance computation.

WelfordFinalize

Compatible with the 220x architecture.

Extended support for algorithm configuration. The template parameter is used to specify whether to use the correction coefficient when computing the variance.

Table 5 Quantization

Ascend C High-Level API

Compatibility Description

AscendQuant

Compatible with the 220x architecture.

Extended support for PRE_TOKEN quantization and PRE_GROUP quantization.

Extended support for quantization from the half, bfloat16_t, and float types to the fp8_e5m2_t, fp8_e4m3fn_t, hifloat8_t, and int8_t types.

Extended support for quantization from the half and bfloat16_t types to the fp4x2_e1m2_t and fp4x2_e2m1_t types.

AscendDequant

Compatible with the 220x architecture.

Extended support for PRE_TOKEN quantization and PRE_GROUP quantization.

Extended support for dequantization from the int32_t type to the half, bfloat16_t, and float types.

Extended support for dequantization from the float type to the half, bfloat16_t, and float types.

AscendAntiQuant

Compatible with the 220x architecture.

Extended support for PRE_TOKEN quantization and PRE_GROUP quantization.

Extended support for fake-quantization from the int8_t, hifloat8_t, fp8_e5m2_t, and fp8_e4m3fn_t types to the half, bfloat16_t, float, and half types.

Extended support for fake-quantization from the fp4x2_e1m2_t and fp4x2_e2m1_t types to the half and bfloat16_t types.

Table 6 Reduce operations

Ascend C High-Level API

Compatibility Description

Sum, Mean, ReduceXorSum, ReduceMean, ReduceAny, ReduceAll, ReduceProd

Compatible with the 220x architecture.

ReduceSum

Compatible with the 220x architecture.

Extended support for the int32_t, uint32_t, int64_t, and uint64_t data types.

ReduceMax, ReduceMin

Compatible with the 220x architecture.

Extended support for the int8_t, uint8_t, int16_t, uint16_t, bfloat16_t, int32_t, uint32_t, int64_t, and uint64_t data types.

Table 7 Sorting operations

Ascend C High-Level API

Compatibility Description

Concat, Extract, GetSortOffset, GetSortLen, MrgSort

Compatible with the 220x architecture.

TopK

Compatible with the 220x architecture.

Extended support for the uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, bfloat16_t, uint64_t, and int64_t data types when the RADIX_SELECT algorithm is used.

Sort

Compatible with the 220x architecture.

Extended support for algorithm configuration. The template parameter is used to specify the sorting algorithm and the ascending or descending order.

Table 8 Index computation

Ascend C High-Level API

Compatibility Description

Arange

Compatible with the 220x architecture.

Extended support for the int64_t data type.

Table 9 Data filtering

Ascend C High-Level API

Compatibility Description

Select

Compatible with the 220x architecture.

DropOut

Compatible with the 220x architecture.

Extended support for the bfloat16_t data type.

Table 10 Tensor transformation

Ascend C High-Level API

Compatibility Description

Transpose

Compatible with the 220x architecture.

Supported data layout conversion scenarios.
  • 2D tensor transpose or transpose of the last two dimensions of a 3D tensor
  • Interchange of the first and second dimensions in a 3D tensor
  • Interchange of the first and third dimensions in a 3D tensor
  • 2D ND2NZ transpose using interleaving instructions

TransData, Pad, UnPad

Compatible with the 220x architecture.

BroadCast

Compatible with the 220x architecture.

Extended support for dynamic shapes.

Extended support for the int16_t, uint16_t, bfloat16_t, int32_t, and uint32_t data types.

Fill

Compatible with the 220x architecture.

Extended support for the uint8_t, int8_t, bfloat16_t, uint64_t, and int64_t data types.

Table 11 HCCL

Ascend C High-Level API

Compatibility Description

HCCL template parameters

Supported the HCCL_SERVER_TYPE_CCU server type.

InitV2, SetCcTilingV2, AllReduce, AllGather, ReduceScatter, AlltoAll, AlltoAllV, Commit, Wait, Finalize

Compatible with the 220x architecture.

BatchWrite, iterate, Query, InterHcclGroupSync, GetWindowsInAddr, GetWindowsOutAddr, GetRankId, GetRankDim, QueueBarrier, GetQueueNum

Not supported in the 351x architecture.

SetReduceType, AlltoAllvWrite

Added in the 351x architecture.