[Mlir-commits] [mlir] [mlir][tosa] Reorder ERF op to align with TOSA spec (PR #133814)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 31 15:46:53 PDT 2025
https://github.com/Jerry-Ge created https://github.com/llvm/llvm-project/pull/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
>From 97b5ffa8b6ac6a043c2d694e1ea645830cd677b6 Mon Sep 17 00:00:00 2001
From: Jerry Ge <jerry.ge at arm.com>
Date: Mon, 31 Mar 2025 15:41:15 -0700
Subject: [PATCH] [mlir][tosa] Reorder ERF op to align with TOSA spec
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 at arm.com>
Change-Id: I1d2250aa5931b8d6285494bd86a1f828baa9fa89
---
mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td | 52 ++++++++++----------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 1ba44db02f25f..75f167afd9dd0 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -499,21 +499,16 @@ def Tosa_ClampOp : Tosa_ElementwiseUnaryOp<"clamp"> {
}
//===----------------------------------------------------------------------===//
-// Operator: sigmoid
+// Operator: erf
//===----------------------------------------------------------------------===//
-def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
- let summary = "Computes elementwise sigmoid of input.";
+def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
+ let summary = "Computes gauss error function of input.";
let description = [{
- Applies the sigmoid logistic function to each element of the input tensor:
- $ sigmoid(x) = \frac{1}{1 + e^{-x}} $.
-
- For quantized integer data types, the TABLE operator should be used instead.
- Each implementation may choose an appropriate TABLE given the scale and zero
- point of the input data. Eight or sixteen bit precision tables may be used
- based on the input tensor to the sigmoid function. The sigmoid table has 513
- entries each of 16-bit precision and covering the input range -16.0 to +16.0
- in steps of 1/16.
+ Gauss error function: $ erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt $
+ 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
@@ -528,21 +523,26 @@ def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
Profile<[Tosa_PRO_FP]>,
Extension<[Tosa_EXT_BF16]>,
];
+
+ let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
-// Operator: tanh
+// Operator: sigmoid
//===----------------------------------------------------------------------===//
-def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
- let summary = "Computes elementwise hyperbolic tangent of input.";
+def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
+ let summary = "Computes elementwise sigmoid of input.";
let description = [{
- Parameterized hyperbolic tangent: $ tanh(x) = \frac{1 - e^{-2x}}{1 + e^{-2x}} $.
+ Applies the sigmoid logistic function to each element of the input tensor:
+ $ sigmoid(x) = \frac{1}{1 + e^{-x}} $.
For quantized integer data types, the TABLE operator should be used instead.
Each implementation may choose an appropriate TABLE given the scale and zero
point of the input data. Eight or sixteen bit precision tables may be used
- based on the input tensor to the tanh function.
+ based on the input tensor to the sigmoid function. The sigmoid table has 513
+ entries each of 16-bit precision and covering the input range -16.0 to +16.0
+ in steps of 1/16.
}];
let arguments = (ins
@@ -560,16 +560,18 @@ def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
}
//===----------------------------------------------------------------------===//
-// Operator: erf
+// Operator: tanh
//===----------------------------------------------------------------------===//
-def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
- let summary = "Computes gauss error function of input.";
+def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
+ let summary = "Computes elementwise hyperbolic tangent of input.";
let description = [{
- Gauss error function: $ erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt $
- 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.
+ Parameterized hyperbolic tangent: $ tanh(x) = \frac{1 - e^{-2x}}{1 + e^{-2x}} $.
+
+ For quantized integer data types, the TABLE operator should be used instead.
+ Each implementation may choose an appropriate TABLE given the scale and zero
+ point of the input data. Eight or sixteen bit precision tables may be used
+ based on the input tensor to the tanh function.
}];
let arguments = (ins
@@ -584,8 +586,6 @@ def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
Profile<[Tosa_PRO_FP]>,
Extension<[Tosa_EXT_BF16]>,
];
-
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list