[MLIR] Fix 0-dimensional case of conversion of vector ops to GPU (#128075)

This is a follow-up to #127844. That PR got vectors of arbitrary rank
working, but I hadn't thought about the rank-0 case.

Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
This commit is contained in:
Benoit Jacob
2025-02-20 19:43:33 -05:00
committed by GitHub
parent 4d92975b5c
commit 3c46debe6b
2 changed files with 16 additions and 1 deletions

View File

@@ -624,7 +624,8 @@ LogicalResult impl::scalarizeVectorOp(Operation *op, ValueRange operands,
const LLVMTypeConverter &converter) {
TypeRange operandTypes(operands);
if (llvm::any_of(operandTypes, llvm::IsaPred<VectorType>)) {
VectorType vectorType = cast<VectorType>(op->getResultTypes()[0]);
VectorType vectorType =
cast<VectorType>(converter.convertType(op->getResultTypes()[0]));
rewriter.replaceOp(op, scalarizeVectorOpHelper(op, operands, vectorType,
rewriter, converter));
return success();

View File

@@ -516,6 +516,20 @@ module {
// -----
module @test_module {
// CHECK: llvm.func @__ocml_sin_f16(f16) -> f16
// CHECK-LABEL: func @math_sin_vector_0d
func.func @math_sin_vector_0d(%arg : vector<f16>) -> vector<f16> {
// CHECK: llvm.extractelement {{.*}} : vector<1xf16>
// CHECK: llvm.call @__ocml_sin_f16(%{{.*}}) : (f16) -> f16
// CHECK: llvm.insertelement {{.*}} : vector<1xf16>
%result = math.sin %arg : vector<f16>
func.return %result : vector<f16>
}
}
// -----
module @test_module {
// CHECK: llvm.func @__ocml_sin_f16(f16) -> f16
// CHECK-LABEL: func @math_sin_vector_1d