[mlir][Vector] Support 0-D vectors in BitCastOp
The implementation only allows to bit-cast between two 0-D vectors. We could probably support casting from/to vectors like `vector<1xf32>`, but I wasn't convinced that this would be important and it would require breaking the invariant that `BitCastOp` works only on vectors with equal rank. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D114854
This commit is contained in:
committed by
Nicolas Vasilache
parent
8e2b373396
commit
1423e8bf5d
@@ -121,9 +121,9 @@ public:
|
||||
LogicalResult
|
||||
matchAndRewrite(vector::BitCastOp bitCastOp, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
// Only 1-D vectors can be lowered to LLVM.
|
||||
VectorType resultTy = bitCastOp.getType();
|
||||
if (resultTy.getRank() != 1)
|
||||
// Only 0-D and 1-D vectors can be lowered to LLVM.
|
||||
VectorType resultTy = bitCastOp.getResultVectorType();
|
||||
if (resultTy.getRank() > 1)
|
||||
return failure();
|
||||
Type newResultTy = typeConverter->convertType(resultTy);
|
||||
rewriter.replaceOpWithNewOp<LLVM::BitcastOp>(bitCastOp, newResultTy,
|
||||
|
||||
Reference in New Issue
Block a user