-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR] Fix issues with XeGPU to XeVM pass. #155946
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,23 +259,23 @@ class UpdateNdOffsetToXeVMPattern | |
| // Only 2D offsets are supported for now. | ||
| if (mixedOffsets.size() != 2) | ||
| return rewriter.notifyMatchFailure(op, "Expected 2D offsets."); | ||
| auto tdesc = adaptor.getTensorDesc(); | ||
| auto payload = adaptor.getTensorDesc(); | ||
| // Utility for updating payload offset values from op fold result. | ||
| auto updateOffset = [&](unsigned idx, int payloadPos) -> Value { | ||
| Value offset = | ||
| getValueOrCreateConstantIntOp(rewriter, loc, mixedOffsets[idx]); | ||
| offset = getValueOrCreateCastToIndexLike(rewriter, loc, | ||
| rewriter.getI32Type(), offset); | ||
| Value oldOffset = | ||
| vector::ExtractOp::create(rewriter, loc, tdesc, payloadPos); | ||
| vector::ExtractOp::create(rewriter, loc, payload, payloadPos); | ||
| Value newOffset = arith::AddIOp::create(rewriter, loc, oldOffset, offset); | ||
| return vector::InsertOp::create(rewriter, loc, newOffset, tdesc, | ||
| return vector::InsertOp::create(rewriter, loc, newOffset, payload, | ||
| payloadPos); | ||
| }; | ||
| // Update offsets in the payload. | ||
| auto val = updateOffset(0, static_cast<int>(NdTdescOffset::TensorOffsetH)); | ||
| val = updateOffset(1, static_cast<int>(NdTdescOffset::TensorOffsetW)); | ||
| rewriter.replaceOp(op, val); | ||
| payload = updateOffset(0, static_cast<int>(NdTdescOffset::TensorOffsetH)); | ||
charithaintc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| payload = updateOffset(1, static_cast<int>(NdTdescOffset::TensorOffsetW)); | ||
| rewriter.replaceOp(op, payload); | ||
| return success(); | ||
| } | ||
| }; | ||
|
|
@@ -354,18 +354,23 @@ class LoadStorePrefetchNdToXeVMPattern : public OpConversionPattern<OpType> { | |
| auto tileH = tdescTy.getDimSize(0); | ||
| int32_t vblocks = tdescTy.getArrayLength(); | ||
| if constexpr (std::is_same_v<OpType, xegpu::StoreNdOp>) { | ||
| VectorType srcVecTy = dyn_cast<VectorType>(adaptor.getValue().getType()); | ||
| Value src = adaptor.getValue(); | ||
| // If store value is a scalar, get value from op instead of adaptor. | ||
| // Adaptor might have optimized away single element vector | ||
| if (src.getType().isIntOrFloat()) { | ||
| src = op.getValue(); | ||
| } | ||
| VectorType srcVecTy = dyn_cast<VectorType>(src.getType()); | ||
| if (!srcVecTy) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the prev code it fails here? |
||
| return rewriter.notifyMatchFailure( | ||
| op, "Expected store value to be a vector type."); | ||
| auto storeCacheControl = | ||
| translateStoreXeGPUCacheHint(op.getL1Hint(), op.getL3Hint()); | ||
| Value src = adaptor.getValue(); | ||
| // Get flat vector type of integer type with matching element bit size. | ||
| VectorType newSrcVecTy = | ||
| encodeVectorTypeTo(srcVecTy, rewriter.getIntegerType(elemBitSize)); | ||
| if (srcVecTy != newSrcVecTy) | ||
| src = vector::BitCastOp::create(rewriter, loc, newSrcVecTy, src); | ||
| auto storeCacheControl = | ||
| translateStoreXeGPUCacheHint(op.getL1Hint(), op.getL3Hint()); | ||
| xevm::BlockStore2dOp::create( | ||
| rewriter, loc, basePtrLLVM, surfaceW, baseShapeH, surfaceW, offsetW, | ||
| offsetH, elemBitSize, tileW, tileH, src, | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe separate test for update_nd? or rename the test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
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.
nit: spell the type name.