Extend OpDSL with a `defines` method that can set the `hasCanonicalizer` flag for an OpDSL operation. If the flag is set via `defines(Canonicalizer)` the operation needs to implement the `getCanonicalizationPatterns` method. The revision specifies the flag for linalg.fill_tensor and adds an empty `FillTensorOp::getCanonicalizationPatterns` implementation. This revision is a preparation step to replace linalg.fill by its OpDSL counterpart linalg.fill_tensor. The two are only functionally equivalent if both specify the same canonicalization patterns. The revision is thus a prerequisite for the linalg.fill replacement. Depends On D120725 Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D120726
21 lines
588 B
Python
21 lines
588 B
Python
# RUN: %PYTHON -m mlir.dialects.linalg.opdsl.dump_oplib --file %s | FileCheck %s
|
|
|
|
from mlir.dialects.linalg.opdsl.lang import *
|
|
|
|
|
|
# CHECK: ---
|
|
# CHECK-LABEL: matmul
|
|
# CHECK: implements:
|
|
# CHECK-NEXT: - LinalgContractionOpInterface
|
|
# CHECK: defines:
|
|
# CHECK-NEXT: - hasCanonicalizer
|
|
@linalg_structured_op
|
|
def matmul(
|
|
A=TensorDef(T, S.M, S.K),
|
|
B=TensorDef(T, S.K, S.N),
|
|
C=TensorDef(U, S.M, S.N, output=True)):
|
|
implements(ContractionOpInterface)
|
|
defines(Canonicalizer)
|
|
C[D.m, D.n] += TypeFn.cast_signed(U, A[D.m, D.k]) * TypeFn.cast_signed(
|
|
U, B[D.k, D.n])
|