[Mlir-commits] [mlir] [mlir][spirv][vector] Support converting vector.from_elements to SPIR-V (PR #118540)
Andrea Faulds
llvmlistbot at llvm.org
Wed Dec 4 04:29:19 PST 2024
================
@@ -220,6 +220,34 @@ struct VectorFmaOpConvert final : public OpConversionPattern<vector::FMAOp> {
}
};
+struct VectorFromElementsOpConvert final
+ : public OpConversionPattern<vector::FromElementsOp> {
+ using OpConversionPattern::OpConversionPattern;
+
+ LogicalResult
+ matchAndRewrite(vector::FromElementsOp op, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ Type resultType = getTypeConverter()->convertType(op.getType());
+ auto elements = op.getElements();
+ if (!resultType)
+ return failure();
+ if (isa<spirv::ScalarType>(resultType)) {
+ // In the case with a single scalar operand / single-element result,
+ // pass through the scalar.
+ rewriter.replaceOp(op, elements[0]);
+ return success();
+ } else if (cast<VectorType>(resultType).getRank() == 1) {
----------------
andfau-amd wrote:
See here, I was trying to pre-empt this comment: https://github.com/llvm/llvm-project/pull/118540#discussion_r1868331381
I guess I was afraid of using an `assert`, but maybe it's fine. Does this look better now?
https://github.com/llvm/llvm-project/pull/118540
More information about the Mlir-commits
mailing list