[mlir][linalg] Use hasPureTensorSemantics in TransposeMatmul methods. (#146438)

The issue is triggered by
ee070d0816
that checks `TensorLikeType` when downstream projects use the pattern
without registering bufferization::BufferizationDialect. The
registration is needed because the interface implementation for builtin
types locate at `BufferizationDialect::initialize()`. However, we do not
need to fix it by the registration. The proper fix is using the linalg
method, i.e., hasPureTensorSemantics.

No additional tests are added because the functionality is well tested
in
[transpose-matmul.mlir](https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/Linalg/transpose-matmul.mlir).
To reproduce the issue, it requires a different setup, e.g., writing a
new C++ pass, which seems not worth it.

Signed-off-by: hanhanW <hanhan0912@gmail.com>
This commit is contained in:
Han-Chung Wang
2025-07-01 14:15:27 -07:00
committed by GitHub
parent 5d849d3a90
commit 42578e8586

View File

@@ -38,7 +38,7 @@ FailureOr<Operation *> mlir::linalg::transposeMatmul(RewriterBase &rewriter,
matmulOp, "only matmul ops with non-extended semantics are supported");
}
if (!bufferization::hasTensorSemantics(matmulOp))
if (!matmulOp.hasPureTensorSemantics())
return rewriter.notifyMatchFailure(
matmulOp, "only matmul ops with tensors are supported");
@@ -93,7 +93,7 @@ mlir::linalg::transposeBatchMatmul(RewriterBase &rewriter,
batchMatmulOp, "ops with user-defined maps are not supported");
}
if (!bufferization::hasTensorSemantics(batchMatmulOp))
if (!batchMatmulOp.hasPureTensorSemantics())
return rewriter.notifyMatchFailure(
batchMatmulOp, "only matmul ops with tensors are supported");