Hi All,
I wanted to propose/inquire about adding a unary elementwise operator : ERF – that computes gauss error function.
Ref : [link1]
It is commonly used in implementing a GELU operator (TF : tf.nn.gelu | TensorFlow v2.12.0 & PT : GELU — PyTorch 2.0 documentation).
The existing approaches uses a variety of approximations :
- polynomial based approximations
a) CHLO->MHLO : [link2]
b) torch-mlir : [link3] - tanh based approximations (see PT link above)
However, depending on the requirement, they might not be accurate enough compared to an exact implementation.
Moreover, given the precedence of ops like tosa.tanh and tosa.sigmoid, would TOSA be open to adding tosa.erf ?
Here is a proposed defintion for a op in MLIR implementation :
//===----------------------------------------------------------------------===//
// Operator: erf
//===----------------------------------------------------------------------===//
def Tosa_ErfOp : Tosa_Op<"erf", [
DeclareOpInterfaceMethods<InferShapedTypeOpInterface,
["inferReturnTypeComponents"]>,
Pure]> {
let summary = "Computes gauss error function of input";
let description = [{
Gauss error function.
For quantized integer data types, the TABLE operator should be used instead
with the following definition. The erf_table has 513 entries each of
16-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64.
}];
let arguments = (ins
Tosa_Tensor:$input
);
let results = (outs
Tosa_Tensor:$output
);
}