Skip to content

Commit fd0785e

Browse files
authored
[mlir][tosa] Reorder ERF op to align with TOSA spec (#133814)
Minor non-functional change of the dialect to better align with the operator order from the TOSA specification: https://www.mlplatform.org/tosa/tosa_spec.html Signed-off-by: Jerry Ge <jerry.ge@arm.com>
1 parent 14c5098 commit fd0785e

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -499,21 +499,16 @@ def Tosa_ClampOp : Tosa_ElementwiseUnaryOp<"clamp"> {
499499
}
500500

501501
//===----------------------------------------------------------------------===//
502-
// Operator: sigmoid
502+
// Operator: erf
503503
//===----------------------------------------------------------------------===//
504-
def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
505-
let summary = "Computes elementwise sigmoid of input.";
504+
def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
505+
let summary = "Computes gauss error function of input.";
506506

507507
let description = [{
508-
Applies the sigmoid logistic function to each element of the input tensor:
509-
$ sigmoid(x) = \frac{1}{1 + e^{-x}} $.
510-
511-
For quantized integer data types, the TABLE operator should be used instead.
512-
Each implementation may choose an appropriate TABLE given the scale and zero
513-
point of the input data. Eight or sixteen bit precision tables may be used
514-
based on the input tensor to the sigmoid function. The sigmoid table has 513
515-
entries each of 16-bit precision and covering the input range -16.0 to +16.0
516-
in steps of 1/16.
508+
Gauss error function: $ erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt $
509+
For quantized integer data types, the TABLE operator should be used instead
510+
with the following definition. The ERF table has 513 entries each of
511+
16-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64.
517512
}];
518513

519514
let arguments = (ins
@@ -528,21 +523,26 @@ def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
528523
Profile<[Tosa_PRO_FP]>,
529524
Extension<[Tosa_EXT_BF16]>,
530525
];
526+
527+
let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
531528
}
532529

533530
//===----------------------------------------------------------------------===//
534-
// Operator: tanh
531+
// Operator: sigmoid
535532
//===----------------------------------------------------------------------===//
536-
def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
537-
let summary = "Computes elementwise hyperbolic tangent of input.";
533+
def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
534+
let summary = "Computes elementwise sigmoid of input.";
538535

539536
let description = [{
540-
Parameterized hyperbolic tangent: $ tanh(x) = \frac{1 - e^{-2x}}{1 + e^{-2x}} $.
537+
Applies the sigmoid logistic function to each element of the input tensor:
538+
$ sigmoid(x) = \frac{1}{1 + e^{-x}} $.
541539

542540
For quantized integer data types, the TABLE operator should be used instead.
543541
Each implementation may choose an appropriate TABLE given the scale and zero
544542
point of the input data. Eight or sixteen bit precision tables may be used
545-
based on the input tensor to the tanh function.
543+
based on the input tensor to the sigmoid function. The sigmoid table has 513
544+
entries each of 16-bit precision and covering the input range -16.0 to +16.0
545+
in steps of 1/16.
546546
}];
547547

548548
let arguments = (ins
@@ -560,16 +560,18 @@ def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
560560
}
561561

562562
//===----------------------------------------------------------------------===//
563-
// Operator: erf
563+
// Operator: tanh
564564
//===----------------------------------------------------------------------===//
565-
def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
566-
let summary = "Computes gauss error function of input.";
565+
def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
566+
let summary = "Computes elementwise hyperbolic tangent of input.";
567567

568568
let description = [{
569-
Gauss error function: $ erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt $
570-
For quantized integer data types, the TABLE operator should be used instead
571-
with the following definition. The ERF table has 513 entries each of
572-
16-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64.
569+
Parameterized hyperbolic tangent: $ tanh(x) = \frac{1 - e^{-2x}}{1 + e^{-2x}} $.
570+
571+
For quantized integer data types, the TABLE operator should be used instead.
572+
Each implementation may choose an appropriate TABLE given the scale and zero
573+
point of the input data. Eight or sixteen bit precision tables may be used
574+
based on the input tensor to the tanh function.
573575
}];
574576

575577
let arguments = (ins
@@ -584,8 +586,6 @@ def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
584586
Profile<[Tosa_PRO_FP]>,
585587
Extension<[Tosa_EXT_BF16]>,
586588
];
587-
588-
let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
589589
}
590590

591591
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)