[Mlir-commits] [mlir] [mlir][tosa] Align dialect summary and description sections to the TOSA v1.0 spec (PR #132835)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Mar 24 15:01:44 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Jerry-Ge (Jerry-Ge)

<details>
<summary>Changes</summary>

Align dialect summary and description sections to the TOSA v1.0 spec

* Updated the summary and description sections in the dialect to better align with the TOSA v1.0 specification.
* Fixed the output variable names LogicalAndOp, LogicalRightShiftOp, LogicalXorOp
* Removed some redundant comments


---

Patch is 36.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/132835.diff


2 Files Affected:

- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+105-115) 
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td (+4-5) 


``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index bd01c5f704b6b..aa5f766dd0d40 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -25,7 +25,7 @@ include "mlir/Dialect/Tosa/IR/TosaTypesBase.td"
 include "mlir/Dialect/Tosa/IR/TosaOpBase.td"
 
 //===----------------------------------------------------------------------===//
-// Operator Class: Tensor Data Engine Operators.
+// Operator Class: Tensor Operators.
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
@@ -114,7 +114,7 @@ def Tosa_AvgPool2dOp : Tosa_InferShapedTypeOp<"avg_pool2d"> {
 // Operator: conv2d
 //===----------------------------------------------------------------------===//
 def Tosa_Conv2DOp : Tosa_ConvOp<"conv2d"> {
-  let summary = "2D Convolution Operator";
+  let summary = "2D Convolution operator.";
 
   let description = [{
     Performs a 2D convolution over the given tensor input, using the weight
@@ -160,7 +160,7 @@ def Tosa_Conv2DOp : Tosa_ConvOp<"conv2d"> {
 // Operator: conv3d
 //===----------------------------------------------------------------------===//
 def Tosa_Conv3DOp : Tosa_ConvOp<"conv3d"> {
-  let summary = "3D Convolution operator";
+  let summary = "3D Convolution operator.";
 
   let description = [{
     Performs a 3D convolution over the given input tensor. Implementations
@@ -205,7 +205,7 @@ def Tosa_Conv3DOp : Tosa_ConvOp<"conv3d"> {
 // Operator: depthwise_conv2d
 //===----------------------------------------------------------------------===//
 def Tosa_DepthwiseConv2DOp : Tosa_ConvOp<"depthwise_conv2d"> {
-  let summary = "Depthwise 2D Convolution operator";
+  let summary = "Depthwise 2D Convolution operator.";
 
   let description = [{
     Performs 2D convolutions separately over each channel of the given tensor
@@ -300,7 +300,7 @@ def Tosa_FFT2dOp : Tosa_InferShapedTypeOp<"fft2d", [
 // Operator: matmul
 //===----------------------------------------------------------------------===//
 def Tosa_MatMulOp : Tosa_InferShapedTypeOp<"matmul"> {
-  let summary = "Matrix multiplication";
+  let summary = "Matrix multiplication operator.";
 
   let description = [{
     Performs two dimensional matrix multiplications.
@@ -534,7 +534,7 @@ def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
 // Operator: tanh
 //===----------------------------------------------------------------------===//
 def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
-  let summary = "Computes elementwise hyperbolic tangent of input";
+  let summary = "Computes elementwise hyperbolic tangent of input.";
 
   let description = [{
     Parameterized hyperbolic tangent: $ tanh(x) = \frac{1 - e^{-2x}}{1 + e^{-2x}} $.
@@ -542,9 +542,7 @@ def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
     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. The tanh_table has 513
-    entries each of 16-bit precision and covering the input range -8.0 to +8.0
-    in steps of 1/32.
+    based on the input tensor to the tanh function.
   }];
 
   let arguments = (ins
@@ -565,7 +563,7 @@ def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
 // Operator: erf
 //===----------------------------------------------------------------------===//
 def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
-  let summary = "Computes gauss error function of input";
+  let summary = "Computes gauss error function of input.";
 
   let description = [{
     Gauss error function: $ erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt $
@@ -591,8 +589,7 @@ def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
 }
 
 //===----------------------------------------------------------------------===//
-// Operator Class: Elementwise unary/binary/ternary operators.
-// Operator Subclass: Elementwise binary ops.
+// Operator Class: Elementwise Binary Operators.
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
@@ -601,7 +598,7 @@ def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
 def Tosa_AddOp : Tosa_ElementwiseOp<"add", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Elementwise addition operator";
+  let summary = "Elementwise addition operator.";
 
   let description = [{
     Elementwise addition of input1 and input2. Axis of size 1 will be broadcast,
@@ -640,7 +637,7 @@ def Tosa_AddOp : Tosa_ElementwiseOp<"add", [
 //===----------------------------------------------------------------------===//
 def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift",
     [SameOperandsAndResultElementType]> {
-  let summary = "Elementwise Arithmetic Right Shift";
+  let summary = "Elementwise Arithmetic Right Shift.";
 
   let description = [{
     Elementwise arithmetic right shift of input1 by the amount specified in
@@ -670,7 +667,7 @@ def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift",
 def Tosa_BitwiseAndOp : Tosa_ElementwiseOp<"bitwise_and", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Bitwise AND operator";
+  let summary = "Bitwise AND operator.";
 
   let description = [{
     Elementwise bitwise AND of input1 and input2. Axis of size 1
@@ -698,7 +695,7 @@ def Tosa_BitwiseAndOp : Tosa_ElementwiseOp<"bitwise_and", [
 def Tosa_BitwiseOrOp : Tosa_ElementwiseOp<"bitwise_or", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Bitwise OR operator";
+  let summary = "Bitwise OR operator.";
 
   let description = [{
     Elementwise bitwise OR of input1 and input2. Axis of size 1 will be
@@ -726,7 +723,7 @@ def Tosa_BitwiseOrOp : Tosa_ElementwiseOp<"bitwise_or", [
 def Tosa_BitwiseXorOp : Tosa_ElementwiseOp<"bitwise_xor", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Bitwise XOR operator";
+  let summary = "Bitwise XOR operator.";
 
   let description = [{
     Elementwise bitwise XOR of input1 and input2. Axis of size 1 will be
@@ -752,13 +749,14 @@ def Tosa_BitwiseXorOp : Tosa_ElementwiseOp<"bitwise_xor", [
 // Operator: int_div
 //===----------------------------------------------------------------------===//
 def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [SameOperandsAndResultElementType]> {
-  let summary = "Integer divide operator";
+  let summary = "Integer divide operator.";
 
   let description = [{
-    Elementwise integer divide operator of input1 by input2. The result of the divide
-    is truncated towards zero. Expected use is for operations on non-scaled integers.
-    Floating point divide should use RECIPROCAL and MUL. Quantized integer divide
-    should use TABLE (for 1/x) and MUL.
+    Elementwise integer divide of input1 by input2. Axis of size 1 will be 
+    broadcast as necessary. Rank of input tensors must match. The result of the 
+    divide is truncated towards zero. Expected use is for operations on 
+    non-scaled integers. Floating point divide should use RECIPROCAL and MUL. 
+    Quantized integer divide should use TABLE (for 1/x) and MUL.
   }];
 
   let arguments = (ins
@@ -784,7 +782,7 @@ def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [SameOperandsAndResultElementT
 def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Returns the truth value of x AND y element-wise.";
+  let summary = "Returns the truth value of input1 AND input2 element-wise.";
 
   let description = [{
     Elementwise logical AND of input1 and input2. Axis of size 1 will be
@@ -797,7 +795,7 @@ def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
   );
 
   let results = (outs
-    Tosa_I1Tensor:$z
+    Tosa_I1Tensor:$output
   );
 
   list<Availability> availability = [
@@ -811,11 +809,12 @@ def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
 //===----------------------------------------------------------------------===//
 def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift",
     [SameOperandsAndResultElementType]> {
-  let summary = "Elementwise Logical Left Shift";
+  let summary = "Elementwise Logical Left Shift.";
 
   let description = [{
-    Elementwise left shift of input1 and input2. Axis of size 1 will be
-    broadcast, as necessary. Rank of input tensors must match.
+    Elementwise logical left-shift of input1 by the amount specified in input2.
+    Axis of size 1 will be broadcast, as necessary.
+    Rank of input tensors must match.
   }];
 
   let arguments = (ins
@@ -838,7 +837,7 @@ def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift",
 //===----------------------------------------------------------------------===//
 def Tosa_LogicalRightShiftOp : Tosa_ElementwiseOp<"logical_right_shift",
     [SameOperandsAndResultElementType]> {
-  let summary = "Elementwise Logical Right Shift";
+  let summary = "Elementwise Logical Right Shift.";
 
   let description = [{
     Elementwise logical right shift of input1 by the amount specified in input2.
@@ -880,7 +879,7 @@ def Tosa_LogicalOrOp : Tosa_ElementwiseOp<"logical_or", [
   );
 
   let results = (outs
-    Tosa_I1Tensor:$z
+    Tosa_I1Tensor:$output
   );
 
   list<Availability> availability = [
@@ -895,7 +894,7 @@ def Tosa_LogicalOrOp : Tosa_ElementwiseOp<"logical_or", [
 def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Returns the truth value of x XOR y element-wise.";
+  let summary = "Returns the truth value of input1 XOR input2 element-wise.";
 
   let description = [{
     Elementwise logical XOR of input1 and input2. Axis of size 1 will be
@@ -908,7 +907,7 @@ def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
   );
 
   let results = (outs
-    Tosa_I1Tensor:$z
+    Tosa_I1Tensor:$output
   );
 
   list<Availability> availability = [
@@ -923,7 +922,7 @@ def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
 def Tosa_MaximumOp : Tosa_ElementwiseOp<"maximum", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Elementwise Maximum";
+  let summary = "Elementwise Maximum.";
 
   let description = [{
     Elementwise max of input1 and input2. Axis of size 1 will be broadcast, as
@@ -952,7 +951,7 @@ def Tosa_MaximumOp : Tosa_ElementwiseOp<"maximum", [
 def Tosa_MinimumOp : Tosa_ElementwiseOp<"minimum", [
     Commutative,
     SameOperandsAndResultElementType]> {
-  let summary = "Elementwise Minimum";
+  let summary = "Elementwise Minimum.";
 
   let description = [{
     Elementwise minimum of input1 and input2. Axis of size 1
@@ -988,7 +987,7 @@ def Tosa_MulOp : Tosa_Op<"mul", [
                               ["inferReturnTypeComponents"]>,
     Commutative,
     Pure]> {
-  let summary = "Multiplication operator";
+  let summary = "Multiplication operator.";
 
   let description = [{
     Elementwise multiplication (Hadamard product) of input1 and input2.
@@ -1026,7 +1025,7 @@ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
   let summary = "Computes the power of one value to another.";
 
   let description = [{
-    Elementwise input1 raised to the power of input2.
+    Elementwise input1 value raised to the power of input2.
     Axis of size 1 will be broadcast, as necessary. Rank of input tensors must
     match.
   }];
@@ -1050,7 +1049,7 @@ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
 // Operator: sub
 //===----------------------------------------------------------------------===//
 def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [SameOperandsAndResultElementType]> {
-  let summary = "Elementwise subtraction operator";
+  let summary = "Elementwise subtraction operator.";
 
   let description = [{
     Elementwise subtraction of input1 and input2. Axis of size 1 will be
@@ -1078,7 +1077,7 @@ def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [SameOperandsAndResultElementType]> {
 // Operator: table
 //===----------------------------------------------------------------------===//
 def Tosa_TableOp : Tosa_InferShapedTypeOp<"table"> {
-  let summary = "Table lookup op";
+  let summary = "Table lookup operator.";
 
   let description = [{
     Table lookup operation. For int8_t TABLE operation, perform a 256 entry
@@ -1119,15 +1118,14 @@ def Tosa_TableOp : Tosa_InferShapedTypeOp<"table"> {
 }
 
 //===----------------------------------------------------------------------===//
-// Operator Class: Elementwise unary/binary/ternary operators.
-// Operator Subclass: Elementwise unary ops.
+// Operator Class: Elementwise Unary Operators.
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
 // Operator: abs
 //===----------------------------------------------------------------------===//
 def Tosa_AbsOp : Tosa_ElementwiseUnaryOp<"abs"> {
-  let summary = "Elementwise abs op";
+  let summary = "Elementwise abs operator.";
 
   let description = [{
     Elementwise absolute value operation.
@@ -1159,7 +1157,7 @@ def Tosa_AbsOp : Tosa_ElementwiseUnaryOp<"abs"> {
 // Operator: bitwise_not
 //===----------------------------------------------------------------------===//
 def Tosa_BitwiseNotOp : Tosa_ElementwiseUnaryOp<"bitwise_not"> {
-  let summary = "Bitwise NOT operator";
+  let summary = "Bitwise NOT operator.";
 
   let description = [{
     Elementwise bitwise NOT of input tensor.
@@ -1183,10 +1181,10 @@ def Tosa_BitwiseNotOp : Tosa_ElementwiseUnaryOp<"bitwise_not"> {
 // Operator: ceil
 //===----------------------------------------------------------------------===//
 def Tosa_CeilOp : Tosa_ElementwiseUnaryOp<"ceil"> {
-  let summary = "Elementwise ceil op";
+  let summary = "Elementwise ceil operator.";
 
   let description = [{
-    Elementwise ceiling operation
+    Elementwise ceiling operation.
   }];
 
   let arguments = (ins
@@ -1207,10 +1205,10 @@ def Tosa_CeilOp : Tosa_ElementwiseUnaryOp<"ceil"> {
 // Operator: clz
 //===----------------------------------------------------------------------===//
 def Tosa_ClzOp : Tosa_ElementwiseUnaryOp<"clz"> {
-  let summary = "Elementwise count leading zero op";
+  let summary = "Elementwise count leading zero operator.";
 
   let description = [{
-    Elementwise count leading zeros operation
+    Elementwise count leading zeros operation.
   }];
 
   let arguments = (ins
@@ -1231,7 +1229,7 @@ def Tosa_ClzOp : Tosa_ElementwiseUnaryOp<"clz"> {
 // Operator: cos
 //===----------------------------------------------------------------------===//
 def Tosa_CosOp : Tosa_ElementwiseUnaryOp<"cos"> {
-  let summary = "Elementwise cos op";
+  let summary = "Elementwise cos operator.";
 
   let description = [{
     Elementwise cosine operation for values given in radians.
@@ -1255,7 +1253,7 @@ def Tosa_CosOp : Tosa_ElementwiseUnaryOp<"cos"> {
 // Operator: exp
 //===----------------------------------------------------------------------===//
 def Tosa_ExpOp : Tosa_ElementwiseUnaryOp<"exp"> {
-  let summary = "Elementwise exp op";
+  let summary = "Elementwise exp operator.";
 
   let description = [{
     Elementwise e to the x operation
@@ -1281,7 +1279,7 @@ def Tosa_ExpOp : Tosa_ElementwiseUnaryOp<"exp"> {
 // Operator: floor
 //===----------------------------------------------------------------------===//
 def Tosa_FloorOp : Tosa_ElementwiseUnaryOp<"floor"> {
-  let summary = "Elementwise floor op";
+  let summary = "Elementwise floor operator.";
 
   let description = [{
     Elementwise floor operation.
@@ -1305,7 +1303,7 @@ def Tosa_FloorOp : Tosa_ElementwiseUnaryOp<"floor"> {
 // Operator: log
 //===----------------------------------------------------------------------===//
 def Tosa_LogOp : Tosa_ElementwiseUnaryOp<"log"> {
-  let summary = "Elementwise log op";
+  let summary = "Elementwise log operator.";
 
   let description = [{
     Elementwise natural logarithm operation
@@ -1331,7 +1329,7 @@ def Tosa_LogOp : Tosa_ElementwiseUnaryOp<"log"> {
 // Operator: logical_not
 //===----------------------------------------------------------------------===//
 def Tosa_LogicalNotOp : Tosa_ElementwiseUnaryOp<"logical_not"> {
-  let summary = "Returns the truth value of NOT x element-wise.";
+  let summary = "Returns the truth value of NOT input1 element-wise.";
 
   let description = [{
     Elementwise logical NOT of input.
@@ -1357,7 +1355,7 @@ def Tosa_LogicalNotOp : Tosa_ElementwiseUnaryOp<"logical_not"> {
 def Tosa_NegateOp : Tosa_InferShapedTypeOp<"negate", [
     TosaElementwiseOperator,
     Pure]> {
-  let summary = "Elementwise negate op";
+  let summary = "Elementwise negate operator.";
 
   let description = [{
     Elementwise negation operation.
@@ -1398,7 +1396,7 @@ def Tosa_NegateOp : Tosa_InferShapedTypeOp<"negate", [
 // Operator: reciprocal
 //===----------------------------------------------------------------------===//
 def Tosa_ReciprocalOp : Tosa_ElementwiseUnaryOp<"reciprocal"> {
-  let summary = "Elementwise reciprocal op";
+  let summary = "Elementwise reciprocal operator.";
 
   let description = [{
     Elementwise reciprocal operation. For integer operation, a TABLE should be
@@ -1434,7 +1432,7 @@ def Tosa_ReciprocalOp : Tosa_ElementwiseUnaryOp<"reciprocal"> {
 // Operator: rsqrt
 //===----------------------------------------------------------------------===//
 def Tosa_RsqrtOp : Tosa_ElementwiseUnaryOp<"rsqrt"> {
-  let summary = "Elementwise 1/sqrt op";
+  let summary = "Elementwise 1/sqrt operator.";
 
   let description = [{
     Elementwise reciprocal square root operation. For integer operation, a TABLE
@@ -1459,7 +1457,7 @@ def Tosa_RsqrtOp : Tosa_ElementwiseUnaryOp<"rsqrt"> {
 // Operator: sin
 //===----------------------------------------------------------------------===//
 def Tosa_SinOp : Tosa_ElementwiseUnaryOp<"sin"> {
-  let summary = "Elementwise sin op";
+  let summary = "Elementwise sin operator.";
 
   let description = [{
     Elementwise sine operation for values given in radians.
@@ -1480,15 +1478,14 @@ def Tosa_SinOp : Tosa_ElementwiseUnaryOp<"sin"> {
 }
 
 //===----------------------------------------------------------------------===//
-// Operator Class: Elementwise unary/binary/ternary operators.
-// Operator Subclass: Elementwise ternary ops.
+// Operator Class: Elementwise Unary Operators.
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
 // Operator: select
 //===----------------------------------------------------------------------===//
 def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
-  let summary = "Elementwise select operator";
+  let summary = "Elementwise select operator.";
 
   let description = [{
     Elementwise select of the output based on a condition.
@@ -1520,7 +1517,7 @@ def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
 }
 
 //===----------------------------------------------------------------------===//
-// Operator Class: Logical Operations.
+// Operator Class: Comparison Operators.
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
@@ -1530,10 +1527,10 @@ def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
     InferTensorType,
     Commutative,
     SameOperandsElementType]> {
-  let summary = "Returns the truth value of (x == y) element-wise.";
+  let summary = "Returns the truth value of (input1 == input2) element-wise.";
 
   let description = [{
-     Elementwise comparison operation
+     Elementwise comparison operation.
   }];
 
   let arguments = (ins
@@ -1563,10 +1560,10 @@ def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
 // Operator: greater
 //===----------------------------------------------------------------------===//
 def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [SameOperandsElementType]> {
-  let summary = "Returns the truth value of (x > y) element-wise.";
+...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/132835


More information about the Mlir-commits mailing list