-
Notifications
You must be signed in to change notification settings - Fork 212
[midend] Add risc version gemmini matmul pass #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few brief comments.
linalg.fill | ||
ins(%1 : i8) | ||
outs(%mem1 : memref<32x32xi8>) | ||
linalg.matmul |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the content to be check.
MatMulOptimize.cpp | ||
MatMulVectorization.cpp | ||
MatMulGemmini.cpp | ||
MatMulParallelVectorization.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can rearrange the C++ files here. Use a dictionary sort.
ShapedType ATy = A.getType().cast<ShapedType>(); | ||
Type eleTy = ATy.getElementType(); | ||
ShapedType BTy = B.getType().cast<ShapedType>(); | ||
// ShapedType CTy = C.getType().cast<ShapedType>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete the content in the comments?
Value B = op->getOperand(1); | ||
Value C = op->getOperand(2); | ||
// Get shape of input and output | ||
ShapedType ATy = A.getType().cast<ShapedType>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use miler::cast(A.getType())
ShapedType BTy = B.getType().cast<ShapedType>(); | ||
// ShapedType CTy = C.getType().cast<ShapedType>(); | ||
|
||
auto ctx = op->getContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best not to use auto.
auto ctx = op->getContext(); | ||
// Some constants. | ||
const Value c0 = | ||
rewriter.create<arith::ConstantOp>(loc, rewriter.getIndexAttr(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use constants with Value.
// This algorithm does not use the column A index. | ||
// const Value aCol = rewriter.create<memref::DimOp>(loc, A, c1); | ||
const Value bRow = rewriter.create<memref::DimOp>(loc, B, c0); | ||
const Value bCol = rewriter.create<memref::DimOp>(loc, B, c1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same applies here.
auto forI = rewriter.create<affine::AffineForOp> ( | ||
loc, 0, rewriter.getIndexAttr(ATy.getDimSize(0)).getInt(), 1, std::nullopt); | ||
// auto forI = rewriter.create<affine::AffineForOp>( | ||
// loc, ValueRange{c0}, rewriter.getDimIdentityMap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete the content here?
SmallVector<affine::AffineForOp, 6> band; | ||
band.push_back(forI); | ||
band.push_back(forJ); | ||
band.push_back(forK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SmallVector<affine::AffineForOp, 6> band = {init,}
This PR aims to reproduce the methods proposed in the Exo paper to enable matrix multiplication acceleration based on Gemmini.