[Mlir-commits] [mlir] 686ef4b - [mlir][sparse] Simplifying Merger::expContainsTensor
wren romano
llvmlistbot at llvm.org
Fri Apr 7 12:32:55 PDT 2023
Author: wren romano
Date: 2023-04-07T12:32:47-07:00
New Revision: 686ef4b4a8dd0af5639ebac9edb491386a3b6932
URL: https://github.com/llvm/llvm-project/commit/686ef4b4a8dd0af5639ebac9edb491386a3b6932
DIFF: https://github.com/llvm/llvm-project/commit/686ef4b4a8dd0af5639ebac9edb491386a3b6932.diff
LOG: [mlir][sparse] Simplifying Merger::expContainsTensor
`expContainsTensor` used to call `expIsTensor` to short-circuit the recursive calls; however, the very first thing `expContainsTensor` does is to check `expIsTensor`, so the short-circuiting code just causes the function to check that condition redundantly.
Depends On D146684
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D146688
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 a79bfbb9c1080..8bdff8de8dcfe 100644
--- a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
@@ -454,6 +454,7 @@ bool Merger::onlyDenseDiff(LatPointId i, LatPointId j) const {
bool Merger::expContainsTensor(ExprId e, TensorId t) const {
const auto &expr = exp(e);
+ // First we check `expIsTensor`.
if (expr.kind == TensorExp::Kind::kTensor)
return expr.tensor == t;
@@ -462,15 +463,11 @@ bool Merger::expContainsTensor(ExprId e, TensorId t) const {
return false;
case ExpArity::kUnary: {
const ExprId e0 = expr.children.e0;
- if (expIsTensor(e0, t))
- return true;
return expContainsTensor(e0, t);
}
case ExpArity::kBinary: {
const ExprId e0 = expr.children.e0;
const ExprId e1 = expr.children.e1;
- if (expIsTensor(e0, t) || expIsTensor(e1, t))
- return true;
return expContainsTensor(e0, t) || expContainsTensor(e1, t);
}
}
More information about the Mlir-commits
mailing list