[Mlir-commits] [mlir] [mlir] Rewrites for I2 to I8 signed and unsigned extension (PR #121298)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Jan 14 03:44:51 PST 2025
================
@@ -1090,15 +1090,20 @@ static LogicalResult alignedConversionPrecondition(PatternRewriter &rewriter,
unsigned srcElemBitwidth = subByteVecType.getElementTypeBitWidth();
unsigned dstElemBitwidth = dstType.getElementTypeBitWidth();
- // Only {s}i4 -> (size_of({{s}i/f}) >= 8) are supported for now.
- if (srcElemBitwidth != 4 || dstElemBitwidth < 8 ||
- (dstElemBitwidth % srcElemBitwidth) != 0)
- return rewriter.notifyMatchFailure(op, "Not a supported aligned case");
+ if (dstElemBitwidth < 8)
+ return rewriter.notifyMatchFailure(
+ op, "the bitwidth of dstType must be greater than or equal to 8");
+ if (dstElemBitwidth % srcElemBitwidth != 0)
+ return rewriter.notifyMatchFailure(op, "unaligned cases are not supported");
+ if (srcElemBitwidth != 2 && srcElemBitwidth != 4)
+ return rewriter.notifyMatchFailure(
+ op, "only src bitwidth of 2 or 4 is supported at this moment");
- const int numSrcElemsPerDestElem = dstElemBitwidth / srcElemBitwidth;
- if ((subByteVecType.getShape().back() % numSrcElemsPerDestElem) != 0)
+ const int numSrcElemsPerByte = 8 / srcElemBitwidth;
+ if ((subByteVecType.getShape().back() % numSrcElemsPerByte) != 0)
return rewriter.notifyMatchFailure(
- op, "Not an even number of i4 elements in trailing dim");
+ op, "the trailing dimension of subByteVecType must be a multiple of "
+ "the srcElemBitwidth / 8");
----------------
banach-space wrote:
This doesn't feel right: "a multiple of the srcElemBitwidth / 8". Did you mean "a multiple of "8 / the srcElemBitwidth"?
In general, this is quite tricky to describe in words. Here's a suggestion:
```suggestion
op, "the trailing dimension of the input vector of sub-bytes must be a multiple of "
"8 / <sub-byte-width>");
```
https://github.com/llvm/llvm-project/pull/121298
More information about the Mlir-commits
mailing list