[Mlir-commits] [mlir] 0280681 - [mlir][sparse] Updating TensorExp ctor to catch unknown TensorExp::Kind

wren romano llvmlistbot at llvm.org
Fri Mar 24 15:08:21 PDT 2023


Author: wren romano
Date: 2023-03-24T15:08:13-07:00
New Revision: 0280681b6d2a13607af225242835d7ab02717993

URL: https://github.com/llvm/llvm-project/commit/0280681b6d2a13607af225242835d7ab02717993
DIFF: https://github.com/llvm/llvm-project/commit/0280681b6d2a13607af225242835d7ab02717993.diff

LOG: [mlir][sparse] Updating TensorExp ctor to catch unknown TensorExp::Kind

Depends On D146562

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D146673

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
index 9b39fd04d25ee..b3ff60882fbfe 100644
--- a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
@@ -105,14 +105,14 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
   case TensorExp::Kind::kTensor:
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     tensor = x;
-    break;
+    return;
   case TensorExp::Kind::kInvariant:
     assert(x == kInvalidId && y == kInvalidId && v && !o);
-    break;
+    return;
   case TensorExp::Kind::kLoopVar:
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     loop = x;
-    break;
+    return;
   // Unary operations.
   case TensorExp::Kind::kAbsF:
   case TensorExp::Kind::kAbsC:
@@ -137,7 +137,7 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kTruncF:
   case TensorExp::Kind::kExtF:
   case TensorExp::Kind::kCastFS:
@@ -152,20 +152,20 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y == kInvalidId && v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kBinaryBranch:
   case TensorExp::Kind::kSelect:
     assert(x != kInvalidId && y == kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kUnary:
     // No assertion on y can be made, as the branching paths involve both
     // a unary (`mapSet`) and binary (`disjSet`) pathway.
     assert(x != kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   // Binary operations.
   case TensorExp::Kind::kMulF:
   case TensorExp::Kind::kMulC:
@@ -189,14 +189,15 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y != kInvalidId && !v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kBinary:
   case TensorExp::Kind::kReduce:
     assert(x != kInvalidId && y != kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   }
+  llvm_unreachable("unexpected kind");
 }
 
 LatPoint::LatPoint(const BitVector &bits, ExprId e) : bits(bits), exp(e) {}


        


More information about the Mlir-commits mailing list