[all-commits] [llvm/llvm-project] 15757e: [mlir][OpDSL] Add `TypeFn` class.

Tobias Gysi via All-commits all-commits at lists.llvm.org
Fri Jan 7 04:29:25 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 15757ea80a411529e05875739b0ed625f2f58e8c
  Author: gysit <gysit at google.com>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M mlir/docs/Dialects/Linalg/OpDSL.md
    M mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
    M mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
    M mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
    M mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py
    M mlir/python/mlir/dialects/linalg/opdsl/lang/scalar_expr.py
    M mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
    M mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
    M mlir/test/python/dialects/linalg/opdsl/arguments.py
    M mlir/test/python/dialects/linalg/opdsl/assignments.py
    M mlir/test/python/dialects/linalg/opdsl/emit_convolution.py
    M mlir/test/python/dialects/linalg/opdsl/emit_matmul.py
    M mlir/test/python/dialects/linalg/opdsl/emit_misc.py
    M mlir/test/python/dialects/linalg/opdsl/emit_pooling.py
    M mlir/test/python/dialects/linalg/opdsl/interfaces.py
    M mlir/test/python/dialects/linalg/opdsl/shape_maps_iteration.py
    M mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp

  Log Message:
  [mlir][OpDSL] Add `TypeFn` class.

This revision introduces a the `TypeFn` class that similar to the `PrimFn` class contains an extensible set of type conversion functions. Having the same mechanism for both type conversion functions and arithmetic functions improves code consistency. Additionally, having an explicit function class and function name is a prerequisite to specify a conversion or arithmetic function via attribute. In a follow up commits, we will introduce function attributes to make OpDSL operations more generic. In particular, the goal is to handle signed and unsigned computation in one operations. Today, there is a linalg.matmul and a linalg.matmul_unsigned.

The commit implements the following changes:
- Introduce the class of type conversion functions `TypeFn`
- Replace the hardwired cast and cast_unsigned ops by the `TypeFn` counterparts
- Adapt the python and C++ code generation paths to support the new cast operations

cast(U, A[D.m, D.k])
changes to
TypeFn.cast(U, A[D.m, D.k])

Depends On D115237

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D115239

More information about the All-commits mailing list