Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 7265930

Browse files
authored
[mlir][linalg] Introduce transpose semantic to 'linalg.matmul' ops. (#104783)
The main goal of this patch is to extend the semantic of 'linalg.matmul' named op to include per operand transpose semantic while also laying out a way to move ops definition from OpDSL to tablegen. Hence, it is implemented in tablegen. Transpose semantic is as follows. By default 'linalg.matmul' behavior will remain as is. Transpose semantics can be appiled on per input operand by specifying the optional permutation attributes (namely 'permutationA' for 1st input and 'permutationB' for 2nd input) for each operand explicitly as needed. By default, no transpose is mandated for any of the input operand. Example: ``` %val = linalg.matmul ins(%arg0, %arg1 : memref<5x3xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>) permutationA = [1, 0] permutationB = [0, 1] ```
1 parent 4540f92 commit 7265930

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,23 +383,6 @@ def select(
383383
O[None] = TernaryFn.select(cond[None], lhs[None], rhs[None])
384384

385385

386-
@linalg_structured_op
387-
def matmul(
388-
A=TensorDef(T1, S.M, S.K),
389-
B=TensorDef(T2, S.K, S.N),
390-
C=TensorDef(U, S.M, S.N, output=True),
391-
cast=TypeFnAttrDef(default=TypeFn.cast_signed),
392-
):
393-
"""Performs a matrix multiplication of two 2D inputs.
394-
395-
Numeric casting is performed on the operands to the inner multiply, promoting
396-
them to the same data type as the accumulator/output.
397-
"""
398-
domain(D.m, D.n, D.k)
399-
implements(ContractionOpInterface)
400-
C[D.m, D.n] += cast(U, A[D.m, D.k]) * cast(U, B[D.k, D.n])
401-
402-
403386
@linalg_structured_op
404387
def quantized_matmul(
405388
A=TensorDef(T1, S.M, S.K),

0 commit comments

Comments
 (0)