[Mlir-commits] [mlir] 8e3be5c - [mlir][arith] Clean up select op implementation (#93351)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri May 24 15:24:45 PDT 2024
Author: Jakub Kuderski
Date: 2024-05-24T18:24:42-04:00
New Revision: 8e3be5c38d3c8f04d04ea72dd1fa57dc9afbbf26
URL: https://github.com/llvm/llvm-project/commit/8e3be5c38d3c8f04d04ea72dd1fa57dc9afbbf26
DIFF: https://github.com/llvm/llvm-project/commit/8e3be5c38d3c8f04d04ea72dd1fa57dc9afbbf26.diff
LOG: [mlir][arith] Clean up select op implementation (#93351)
Inline traits used by `arith.select` only into `ArithOps.td`. Trim
trailing whitespace in op description.
Added:
Modified:
mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
mlir/include/mlir/IR/OpBase.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index 4e4c6fd601777..ead52332e8eec 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -1540,6 +1540,18 @@ def Arith_CmpFOp : Arith_CompareOp<"cmpf",
// SelectOp
//===----------------------------------------------------------------------===//
+class AnyBooleanTypeMatch<list<string> names> :
+ AnyMatchOperatorTrait<names, "$_self.getType().isSignlessInteger(1)",
+ "scalar type">;
+
+class ScalarConditionOrMatchingShape<list<string> names> :
+ PredOpTrait<
+ !head(names) # " is scalar or has matching shape",
+ Or<[AnyBooleanTypeMatch<[!head(names)]>.predicate,
+ AllShapesMatch<names>.predicate]>> {
+ list<string> values = names;
+}
+
def SelectOp : Arith_Op<"select", [Pure,
AllTypesMatch<["true_value", "false_value", "result"]>,
ScalarConditionOrMatchingShape<["condition", "result"]>,
@@ -1548,16 +1560,16 @@ def SelectOp : Arith_Op<"select", [Pure,
let summary = "select operation";
let description = [{
The `arith.select` operation chooses one value based on a binary condition
- supplied as its first operand.
-
- If the value of the first operand (the condition) is `1`, then the second
- operand is returned, and the third operand is ignored, even if it was poison.
-
- If the value of the first operand (the condition) is `0`, then the third
- operand is returned, and the second operand is ignored, even if it was poison.
-
- If the value of the first operand (the condition) is poison, then the
- operation returns poison.
+ supplied as its first operand.
+
+ If the value of the first operand (the condition) is `1`, then the second
+ operand is returned, and the third operand is ignored, even if it was poison.
+
+ If the value of the first operand (the condition) is `0`, then the third
+ operand is returned, and the second operand is ignored, even if it was poison.
+
+ If the value of the first operand (the condition) is poison, then the
+ operation returns poison.
The operation applies to vectors and tensors elementwise given the _shape_
of all operands is identical. The choice is made for each element
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 7866ac24c1ccb..4481e56615b8b 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -670,16 +670,4 @@ class TCopVTEtAreSameAt<list<int> indices> : CPred<
"[this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); "
"}))">;
-class AnyScalarTypeMatch<list<string> names> :
- AnyMatchOperatorTrait<names, "$_self.getType().isSignlessInteger(1)",
- "scalar type">;
-
-class ScalarConditionOrMatchingShape<list<string> names> :
- PredOpTrait<
- !head(names) # " is scalar or has matching shape",
- Or<[AnyScalarTypeMatch<[!head(names)]>.predicate,
- AllShapesMatch<names>.predicate]>> {
- list<string> values = names;
-}
-
#endif // OP_BASE
More information about the Mlir-commits
mailing list