Created
October 7, 2023 13:22
-
-
Save Max191/2943817a47b7199bb53c4a51419b8846 to your computer and use it in GitHub Desktop.
MLIR patch for llama2 CPU performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp b/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp | |
index 7f8322bd5f6f..762de3b99494 100644 | |
--- a/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp | |
+++ b/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp | |
@@ -460,6 +460,10 @@ LogicalResult LoadOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite( | |
rewriter.replaceOpWithNewOp<decltype(op)>( | |
loadOp, expandShapeOp.getViewSource(), sourceIndices); | |
}) | |
+ .Case([&](vector::LoadOp op) { | |
+ rewriter.replaceOpWithNewOp<vector::LoadOp>( | |
+ loadOp, loadOp.getType(), expandShapeOp.getViewSource(), sourceIndices); | |
+ }) | |
.Default([](Operation *) { llvm_unreachable("unexpected operation."); }); | |
return success(); | |
} | |
@@ -493,6 +497,10 @@ LogicalResult LoadOpOfCollapseShapeOpFolder<OpTy>::matchAndRewrite( | |
rewriter.replaceOpWithNewOp<decltype(op)>( | |
loadOp, collapseShapeOp.getViewSource(), sourceIndices); | |
}) | |
+ .Case([&](vector::LoadOp op) { | |
+ rewriter.replaceOpWithNewOp<vector::LoadOp>( | |
+ loadOp, loadOp.getType(), collapseShapeOp.getViewSource(), sourceIndices); | |
+ }) | |
.Default([](Operation *) { llvm_unreachable("unexpected operation."); }); | |
return success(); | |
} | |
@@ -689,10 +697,12 @@ void memref::populateFoldMemRefAliasOpPatterns(RewritePatternSet &patterns) { | |
StoreOpOfSubViewOpFolder<gpu::SubgroupMmaStoreMatrixOp>, | |
LoadOpOfExpandShapeOpFolder<affine::AffineLoadOp>, | |
LoadOpOfExpandShapeOpFolder<memref::LoadOp>, | |
+ LoadOpOfExpandShapeOpFolder<vector::LoadOp>, | |
StoreOpOfExpandShapeOpFolder<affine::AffineStoreOp>, | |
StoreOpOfExpandShapeOpFolder<memref::StoreOp>, | |
LoadOpOfCollapseShapeOpFolder<affine::AffineLoadOp>, | |
LoadOpOfCollapseShapeOpFolder<memref::LoadOp>, | |
+ LoadOpOfCollapseShapeOpFolder<vector::LoadOp>, | |
StoreOpOfCollapseShapeOpFolder<affine::AffineStoreOp>, | |
StoreOpOfCollapseShapeOpFolder<memref::StoreOp>, | |
SubViewOfSubViewFolder, NvgpuAsyncCopyOpSubViewOpFolder>( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment