Skip to content

[mlir][ArmSME] Fail instead of error in vector.outerproduct lowering #75447

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,16 +510,18 @@ struct VectorOuterProductToArmSMELowering
// We don't yet support lowering AXPY operations to SME. These could be
// lowered by masking out all but the first element of the LHS.
if (!isa<VectorType>(outerProductOp.getOperandTypeRHS()))
return outerProductOp.emitError("AXPY operations not supported");
return rewriter.notifyMatchFailure(outerProductOp,
"AXPY operations not supported");

if (!arm_sme::isValidSMETileVectorType(
outerProductOp.getResultVectorType()))
return outerProductOp.emitError(
"outer product does not fit into SME tile");
return rewriter.notifyMatchFailure(
outerProductOp, "outer product does not fit into SME tile");

auto kind = outerProductOp.getKind();
if (kind != vector::CombiningKind::ADD)
return outerProductOp.emitError(
return rewriter.notifyMatchFailure(
outerProductOp,
"unsupported kind (lowering to SME only supports ADD at the moment)");

Value lhsMask = {};
Expand Down
12 changes: 9 additions & 3 deletions mlir/test/Conversion/VectorToArmSME/unsupported.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,31 @@ func.func @transfer_write_2d__out_of_bounds(%vector : vector<[4]x[4]xf32>, %dest

// -----

// CHECK-LABEL: @vector_outerproduct_unsupported_axpy
// CHECK-NOT: arm_sme.outerproduct
// CHECK: vector.outerproduct
func.func @vector_outerproduct_unsupported_axpy(%lhs : vector<[2]xf64>, %rhs : f64, %acc : vector<[2]xf64>) -> vector<[2]xf64> {
// expected-error@+1 {{AXPY operations not supported}}
%0 = vector.outerproduct %lhs, %rhs, %acc {kind = #vector.kind<mul>} : vector<[2]xf64>, f64
return %0 : vector<[2]xf64>
}

// -----

// CHECK-LABEL: @vector_outerproduct_unsupported_kind
// CHECK-NOT: arm_sme.outerproduct
// CHECK: vector.outerproduct
func.func @vector_outerproduct_unsupported_kind(%lhs : vector<[2]xf64>, %rhs : vector<[2]xf64>) {
%acc = arm_sme.get_tile : vector<[2]x[2]xf64>
// expected-error@+1 {{unsupported kind}}
%0 = vector.outerproduct %lhs, %rhs, %acc {kind = #vector.kind<mul>} : vector<[2]xf64>, vector<[2]xf64>
"prevent.dce"(%0) : (vector<[2]x[2]xf64>) -> ()
}

// -----

// CHECK-LABEL: @vector_outerproduct_unknown_mask
// CHECK-NOT: arm_sme.outerproduct
// CHECK: vector.outerproduct
func.func @vector_outerproduct_unknown_mask(%lhs : vector<[4]xf32>, %rhs : vector<[4]xf32>, %mask : vector<[4]x[4]xi1>) {
// CHECK: vector.outerproduct
%acc = arm_sme.get_tile : vector<[4]x[4]xf32>
%0 = vector.mask %mask { vector.outerproduct %lhs, %rhs, %acc {kind = #vector.kind<add>} : vector<[4]xf32>, vector<[4]xf32> } : vector<[4]x[4]xi1> -> vector<[4]x[4]xf32>
"prevent.dce"(%0) : (vector<[4]x[4]xf32>) -> ()
Expand Down