[Mlir-commits] [mlir] e5cb0ee - [mlir][sparse] run canonicalization pass after DenseOpBufferize.
Peiming Liu
llvmlistbot at llvm.org
Fri Oct 28 18:00:11 PDT 2022
Author: Peiming Liu
Date: 2022-10-29T01:00:05Z
New Revision: e5cb0ee3836aacd8cc377a5a91659fc7512909c9
URL: https://github.com/llvm/llvm-project/commit/e5cb0ee3836aacd8cc377a5a91659fc7512909c9
DIFF: https://github.com/llvm/llvm-project/commit/e5cb0ee3836aacd8cc377a5a91659fc7512909c9.diff
LOG: [mlir][sparse] run canonicalization pass after DenseOpBufferize.
As pointed out by Matthias: "DenseBufferizationPass should be run right after TensorCopyInsertionPass. (Running it after bufferizing the sparse IR is also OK.) The reason for this is that whether copies are needed for not depends on the structure of the program (SSA use-def chains). In particular, running the canonicalizer in-between is problematic because it could introduce new RaW conflicts"
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D136980
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
index b3b70575b055d..a16340dbc459e 100644
--- a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
@@ -66,9 +66,9 @@ void mlir::sparse_tensor::buildSparseCompiler(
else
pm.addPass(createSparseTensorCodegenPass());
pm.addPass(createSparseBufferRewritePass());
- pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
pm.addPass(createDenseBufferizationPass(
getBufferizationOptions(/*analysisOnly=*/false)));
+ pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
pm.addNestedPass<func::FuncOp>(
mlir::bufferization::createFinalizingBufferizePass());
// TODO(springerm): Add sparse support to the BufferDeallocation pass and add
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
index 43a8eed607253..59e7f33c22c88 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
@@ -91,10 +91,6 @@ module {
// Release the resources.
bufferization.dealloc_tensor %a : tensor<?x?xi32, #SparseMatrix>
- // TODO(springerm): auto release!
- bufferization.dealloc_tensor %b : tensor<?xi32>
- bufferization.dealloc_tensor %x : tensor<?xi32>
-
return
}
}
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
index 4ee5e1e0ac1c4..42aa6c149c2c0 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
@@ -115,11 +115,6 @@ module {
// Release the resources.
bufferization.dealloc_tensor %b : tensor<?x?x?xf64, #SparseTensor>
- // TODO(springerm): auto release!
- bufferization.dealloc_tensor %a : tensor<?x?xf64>
- bufferization.dealloc_tensor %c : tensor<?x?xf64>
- bufferization.dealloc_tensor %d : tensor<?x?xf64>
-
return
}
}
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
index b368670c100bc..e8b61e10ea026 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
@@ -108,11 +108,6 @@ module {
// Release the resources.
bufferization.dealloc_tensor %s : tensor<?x?xf32, #SparseMatrix>
- // TODO(springerm): auto release!
- bufferization.dealloc_tensor %x : tensor<?x?xf32>
- bufferization.dealloc_tensor %a : tensor<?x?xf32>
- bufferization.dealloc_tensor %b : tensor<?x?xf32>
-
return
}
}
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
index 7e3aefdbb8343..5a8e908f7f629 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
@@ -90,9 +90,6 @@ module {
// Release the resources.
bufferization.dealloc_tensor %a : tensor<?x?xf64, #SparseMatrix>
- // TODO(springerm): auto release!
- bufferization.dealloc_tensor %b : tensor<?x?xf64>
- bufferization.dealloc_tensor %x : tensor<?x?xf64>
return
}
More information about the Mlir-commits
mailing list