Substitutes for Deprecated APIs
The single-operator model execution APIs and CBLAS APIs described in this chapter will be deprecated in later versions. If they are still used, undefined behavior may occur. Use the aclnn operator APIs instead.
Substitutes for Single-Operator Model Execution APIs
The single-operator model execution APIs mainly consist of core steps such as operator building (such as aclopCompile), operator model file loading (such as aclopLoad), and operator execution (such as aclopExecuteV2). This API set is called for different operators, but the input parameters need to be constructed based on the input, output, and attributes of the operators. Therefore, when replacing a single-operator model execution API, you can directly use the corresponding aclnn operator API. For example, if the single-operator model execution API is used to call the Add operator, you can now use the aclnnAdd operator API instead.
Substitutes for CBLAS APIs
The CBLAS APIs primarily provide two types of functionalities:matrix-vector multiplication and matrix-matrix multiplication. The core steps include using the ATC tool to compile operators, loading operator model files (such as aclopLoad), and executing operators (such as aclblasGemvEx). Matrix-vector multiplication and matrix-matrix multiplication correspond to different execution APIs, and the input and output data types are also different. Therefore, there is no direct one-to-one mapping between the CBLAS APIs and the aclnn operator APIs. The substitution is implemented by combining basic aclnn operator APIs such as Matmul, Muls, and Add. For details about the sample code, see here.
The following tables describes the specific substitution solutions.
New/Old APIs |
CBLAS APIs |
aclnn Combination |
|---|---|---|
API |
aclblasGemvEx aclblasCreateHandleForGemvEx |
aclnnMatmul(n=1) + aclnnMuls + aclnnAdd |
Data Type |
FLOAT16/FLOAT |
FLOAT16/FLOAT |
Formula |
y = αAx + βy |
Four steps: Matmul → Muls → Muls → Add |
New/Old APIs |
CBLAS APIs |
aclnn Combination |
|---|---|---|
API |
aclblasHgemv aclblasCreateHandleForHgemv |
aclnnMatmul(n=1) + aclnnMuls + aclnnAdd |
Data Type |
FLOAT16 (fixed) |
FLOAT16 (fixed) |
Formula |
y = αAx + βy |
Four steps: Matmul → Muls → Muls → Add |
New/Old APIs |
CBLAS APIs |
aclnn Combination |
|---|---|---|
API |
aclblasS8gemv aclblasCreateHandleForS8gemv |
aclnnQuantMatmulV5(n=1) + aclnnMuls + aclnnAdd |
Data Type |
INT8 × INT8 input → INT32 output |
INT8 input → INT32 output |
Formula |
y = αAx + βy |
Four steps: QuantMatmulV5 → Muls (INT32) → Muls (INT32) → Add |
New/Old APIs |
CBLAS APIs |
aclnn Combination |
|---|---|---|
API |
aclblasGemmEx aclblasCreateHandleForGemmEx |
aclnnMatmul + aclnnMuls + aclnnAdd |
Data Type |
FLOAT16/FLOAT |
FLOAT16/FLOAT |
Formula |
C = alpha × op(A) × op(B) + beta × C |
Four steps: Matmul → Muls(alpha) → Muls(beta) → Add |
New/Old APIs |
aclblas |
aclnn Combination |
|---|---|---|
API |
aclblasHgemm aclblasCreateHandleForHgemm |
aclnnMatmul + aclnnMuls + aclnnAdd |
Data Type |
FLOAT (fixed) |
FLOAT (fixed) |
Formula |
C = alpha × op(A) × op(B) + beta × C |
Four steps: Matmul → Muls(alpha) → Muls(beta) → Add |
New/Old APIs |
aclblas |
aclnn Combination |
|---|---|---|
API |
aclblasS8gemm aclblasCreateHandleForS8gemm |
aclnnQuantMatmulV5 + aclnnMuls + aclnnAdd |
Data Type |
INT8 × INT8 input → INT32 output |
INT8 input → INT32 output |
Formula |
C = alpha × A × B + beta × C |
Four steps: QuantMatmulV5 → Muls (INT32) → Muls (INT32) → Add |