[object Object][object Object][object Object]undefined
[object Object]
  • This API is used to fuse GeluV2 with DynamicQuant/AscendQuantV2. It performs Gelu activation on the input data self, quantizes the activation result, and outputs the quantized result.

  • Formula:

  1. Calculate the Gelu value to obtain geluOut.
  • approximate = tanh
geluOut=Gelu(self)=self×Φ(self)=0.5self(1+Tanh(2/π(self+0.044715self3)))geluOut=Gelu(self)=self × Φ(self)=0.5 * self * (1 + Tanh( \sqrt{2 / \pi} * (self + 0.044715 * self^{3})))
  • approximate = none
geluOut=Gelu(self)=self×Φ(self)=0.5self[1+erf(self/2)]geluOut=Gelu(self)=self × Φ(self)=0.5 * self *[1 + erf(self/\sqrt{2})]
  1. Quantize geluOut.
  • quant_mode = static
y=round_to_dst_type(geluOutinputScaleOptional+inputOffsetOptional,round_mode)y = round\_to\_dst\_type(geluOut * inputScaleOptional + inputOffsetOptional, round\_mode)
  • quant_mode = dynamic

    geluOut=geluOutinputScaleOptionalgeluOut = geluOut * inputScaleOptional Max=max(abs(geluOut))Max = max(abs(geluOut)) outScaleOptional=Max/maxValueoutScaleOptional = Max/maxValue y=round_to_dst_type(geluOut/outScaleOptional,round_mode)y = round\_to\_dst\_type(geluOut / outScaleOptional, round\_mode)
  • maxValue: maximum value of the corresponding data type.

    [object Object]undefined
[object Object]

Each operator has calls. You must call aclnnGeluQuantGetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator computation process, and then call aclnnGeluQuant to perform the computation.

[object Object]
[object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns

[object Object]: status code. For details, see .

The first-phase API implements input parameter validation. The following error codes may be returned.

[object Object][object Object]
  • Parameters

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic computation:

    • The aclnnGeluQuant is implemented in deterministic mode by default.
  • The data type of inputScaleOptional is the same as that of self. If the types are different, the type with higher precision is used.

[object Object]

The following example is for reference only. For details, see .

[object Object]