Implement simple type polymorphism for linalg named ops.
authorStella Laurenzo <stellaraccident@gmail.com>
Sun, 21 Feb 2021 06:46:27 +0000 (22:46 -0800)
committerStella Laurenzo <stellaraccident@gmail.com>
Sun, 21 Feb 2021 22:30:31 +0000 (14:30 -0800)
commit6c9541d4ddfdab0dcb11436485b466a759c3126c
treef646093afa0e1a701b9d853b9cc31b8bbabe0d20
parentb568d3d6c915a515624f6292af0785c43ffaba37
Implement simple type polymorphism for linalg named ops.

* It was decided that this was the end of the line for the existing custom tc parser/generator, and this is the first step to replacing it with a declarative format that maps well to mathy source languages.
* One such source language is implemented here: https://github.com/stellaraccident/mlir-linalgpy/blob/main/samples/mm.py
  * In fact, this is the exact source of the declarative `polymorphic_matmul` in this change.
  * I am working separately to clean this python implementation up and add it to MLIR (probably as `mlir.tools.linalg_opgen` or equiv). The scope of the python side is greater than just generating named ops: the ops are callable and directly emit `linalg.generic` ops fully dynamically, and this is intended to be a feature for frontends like npcomp to define custom linear algebra ops at runtime.
* There is more work required to handle full type polymorphism, especially with respect to integer formulations, since they require more specificity wrt types.
* Followups to this change will bring the new generator to feature parity with the current one and delete the current. Roughly, this involves adding support for interface declarations and attribute symbol bindings.

Differential Revision: https://reviews.llvm.org/D97135
mlir/docs/Dialects/Linalg.md
mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml [new file with mode: 0644]
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/generalize-named-polymorphic-ops.mlir [new file with mode: 0644]
mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp [new file with mode: 0644]