---
title: 高精度
description: "在进行attention计算时，Q∙KT的结果有可能溢出float16，导致算子输出tensor中间出现NAN值；此时可开启此功能，算子内部使用float32承载中间结果。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0354.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0354.html
indexId: 224f1be4f06aeac7206407d749117202cfaaf288c336da2cc5202cb6978d07c064
---
# 高精度

#### 功能说明

在进行attention计算时，Q∙KT的结果有可能溢出float16，导致算子输出tensor中间出现NAN值；此时可开启此功能，算子内部使用float32承载中间结果。


#### 开启方式

参数“kernelType”置为KERNELTYPE_HIGH_PRECISION。


#### 约束说明

开启此功能时，传入的mask中需把-inf换成1。

高精度功能只在 Atlas A2 训练系列产品 / Atlas A2 推理系列产品 和 Atlas A3 推理系列产品 / Atlas A3 训练系列产品 上才能生效。
