Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 222 additions & 51 deletions Acc/api_precision_compare.py

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion Acc/compare/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 定义比对算法及比对标准
import paddle
import numpy as np
from compare.compare_utils import CompareConst, check_dtype_comparable
from compare.compare_utils import CompareConst, check_dtype_comparable, ULP_PARAMETERS


#cos
Expand Down Expand Up @@ -188,3 +188,19 @@ def check_norm_value(normal_value_mask, rel_err, rtol):
err_mask = np.logical_and(err_mask, normal_value_mask)
err_cnt = np.sum(err_mask)
return 0 if np.sum(normal_value_mask) == 0 else err_cnt / np.sum(normal_value_mask)


def get_ulp_err(bench_output, device_output, dtype):
parameters = ULP_PARAMETERS.get(dtype)
min_eb = (parameters.get('min_eb'))[0]
exponent_num = (parameters.get('exponent_num'))[0]
abs_bench = np.abs(bench_output)
eb = np.where(abs_bench == 0, 0, np.floor(np.log2(abs_bench)))
eb = np.maximum(eb, min_eb)

if dtype == paddle.float32:
ulp_err = (device_output.astype(np.float64) - bench_output).astype(np.float64) * np.exp2(-eb + exponent_num).astype(np.float64)
else:
ulp_err = (device_output.astype(np.float32) - bench_output).astype(np.float32) * np.exp2(-eb + exponent_num).astype(np.float32)
ulp_err = np.abs(ulp_err)
return ulp_err
24 changes: 24 additions & 0 deletions Acc/compare/api_precision_standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,27 @@ BinaryCompareStandard:
- tril_
- triu
- triu_
- type_as

ULPStandard:
- __matmul__
- addbmm
- addbmm_
- addmm
- addmm_
- baddbmm
- baddbmm_
- bilinear
- bmm
- chain_matmul
- hspmm
- linear
- matmul
- mm
- mv
- smm
- sspaddmm

ThousandthStandard:
- conv1d
- conv2d
Loading