diff options
author | gysit <gysit@google.com> | 2022-02-25 08:12:34 +0000 |
---|---|---|
committer | gysit <gysit@google.com> | 2022-02-25 08:25:23 +0000 |
commit | 51fdd802c794faf6e5b57cccd6ea181c7f8a83e9 (patch) | |
tree | 6eec6a12cddd18d803af616870d678559698252e /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 3fe6f9388fd3ef61d47b1f8b573596fc44b2f144 (diff) | |
download | llvm-51fdd802c794faf6e5b57cccd6ea181c7f8a83e9.zip llvm-51fdd802c794faf6e5b57cccd6ea181c7f8a83e9.tar.gz llvm-51fdd802c794faf6e5b57cccd6ea181c7f8a83e9.tar.bz2 |
[mlir][OpDSL] Add type function attributes.
Previously, OpDSL operation used hardcoded type conversion operations (cast or cast_unsigned). Supporting signed and unsigned casts thus meant implementing two different operations. Type function attributes allow us to define a single operation that has a cast type function attribute which at operation instantiation time may be set to cast or cast_unsigned. We may for example, defina a matmul operation with a cast argument:
```
@linalg_structured_op
def matmul(A=TensorDef(T1, S.M, S.K), B=TensorDef(T2, S.K, S.N), C=TensorDef(U, S.M, S.N, output=True),
cast=TypeFnAttrDef(default=TypeFn.cast)):
C[D.m, D.n] += cast(U, A[D.m, D.k]) * cast(U, B[D.k, D.n])
```
When instantiating the operation the attribute may be set to the desired cast function:
```
linalg.matmul(lhs, rhs, outs=[out], cast=TypeFn.cast_unsigned)
```
The revsion introduces a enum in the Linalg dialect that maps one-by-one to the type functions defined by OpDSL.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D119718
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
0 files changed, 0 insertions, 0 deletions