Skip to content

Commit

Permalink
[mlir][sparse] run canonicalization pass after DenseOpBufferize.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PeimingLiu committed Oct 29, 2022
1 parent b925509 commit e5cb0ee
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e5cb0ee

Please sign in to comment.