Skip to content
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

[mlir][vector] Disable vector.matrix_multiply for scalable vectors #102573

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2683,13 +2683,13 @@ def Vector_MatmulOp : Vector_Op<"matrix_multiply", [Pure,
TCresVTEtIsSameAsOpBase<0, 1>>]>,
Arguments<(
// TODO: tighten vector element types that make sense.
ins VectorOfRankAndType<[1],
ins FixedVectorOfRankAndType<[1],
[AnySignlessInteger, AnySignedInteger, Index, AnyFloat]>:$lhs,
VectorOfRankAndType<[1],
FixedVectorOfRankAndType<[1],
[AnySignlessInteger, AnySignedInteger, Index, AnyFloat]>:$rhs,
I32Attr:$lhs_rows, I32Attr:$lhs_columns, I32Attr:$rhs_columns)>,
Results<(
outs VectorOfRankAndType<[1],
outs FixedVectorOfRankAndType<[1],
[AnySignlessInteger, AnySignedInteger, Index, AnyFloat]>:$res)>
{
let summary = "Vector matrix multiplication op that operates on flattened 1-D"
Expand All @@ -2707,7 +2707,10 @@ def Vector_MatmulOp : Vector_Op<"matrix_multiply", [Pure,
<rhs_columns> and multiplies them. The result matrix is returned embedded in
the result vector.

Also see:
Note, the semantics of the corresponding LLVM intrinsic,
`@llvm.matrix.multiply.*`, are not clear in the context of scalable
vectors. Hence, this Op is only available for fixed-width vectors. Also
see:
banach-space marked this conversation as resolved.
Show resolved Hide resolved

http://llvm.org/docs/LangRef.html#llvm-matrix-multiply-intrinsic

Expand Down
8 changes: 8 additions & 0 deletions mlir/include/mlir/IR/CommonTypeConstraints.td
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ class VectorOfRankAndType<list<int> allowedRanks,
VectorOf<allowedTypes>.summary # VectorOfRank<allowedRanks>.summary,
"::mlir::VectorType">;

// Fixed-width vector where the rank is from the given `allowedRanks` list and
// the type is from the given `allowedTypes` list
class FixedVectorOfRankAndType<list<int> allowedRanks,
list<Type> allowedTypes> : AllOfType<
banach-space marked this conversation as resolved.
Show resolved Hide resolved
[FixedVectorOf<allowedTypes>, VectorOfRank<allowedRanks>],
FixedVectorOf<allowedTypes>.summary # VectorOfRank<allowedRanks>.summary,
"::mlir::VectorType">;

// Whether the number of elements of a vector is from the given
// `allowedLengths` list
class IsVectorOfLengthPred<list<int> allowedLengths> :
Expand Down
13 changes: 13 additions & 0 deletions mlir/test/Dialect/Vector/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1862,3 +1862,16 @@ func.func @invalid_step_2d() {
vector.step : vector<2x4xf32>
return
}

// -----

func.func @matrix_matmul_scalable(%a: vector<[4]xf64>, %b: vector<4xf64>) {
banach-space marked this conversation as resolved.
Show resolved Hide resolved
// expected-error @+1 {{'vector.matrix_multiply' op operand #0 must be fixed-length vector of signless integer or signed integer or index or floating-point values of ranks 1, but got 'vector<[4]xf64>'}}
%c = vector.matrix_multiply %a, %b {
lhs_rows = 2: i32,
lhs_columns = 2: i32 ,
rhs_columns = 2: i32 }
: (vector<[4]xf64>, vector<4xf64>) -> vector<4xf64>

return
}
Loading