Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalizers and Declarative Rewrite Patterns #19

Merged
merged 8 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/Dialect/Poly/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ td_library(
srcs = [
"PolyDialect.td",
"PolyOps.td",
"PolyPatterns.td",
"PolyTypes.td",
],
includes = ["@heir//include"],
deps = [
"@llvm-project//mlir:BuiltinDialectTdFiles",
"@llvm-project//mlir:InferTypeOpInterfaceTdFiles",
Expand Down Expand Up @@ -80,6 +80,23 @@ gentbl_cc_library(
],
)

gentbl_cc_library(
name = "canonicalize_inc_gen",
tbl_outs = [
(
["-gen-rewriters"],
"PolyCanonicalize.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "PolyPatterns.td",
deps = [
":td_files",
":types_inc_gen",
"@llvm-project//mlir:ComplexOpsTdFiles",
],
)

cc_library(
name = "Poly",
srcs = [
Expand Down
13 changes: 13 additions & 0 deletions lib/Dialect/Poly/PolyPatterns.td
Copy link

@UtkarshKunwar UtkarshKunwar May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the tutorial and got stuck here e55bab9 with MLIR v18.1.x. I've described the issue on the LLVM repo here in detail. Just wanted to know if someone else has also faced this issue as I couldn't find the solution for it.

EDIT: This issue with the API was fixed later in the tutorial in the commits fa6d030 and d2e0a72 of #26. It has to do with the API changes with Complex operators like ConjOp now requiring two arguments $input and attribute $fastmath.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I haven't seen people use MLIR by installing the tools as separate binaries, and instead they tend to build everything from source at a specific LLVM commit (or HEAD).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit I'm not very familiar with the standard MLIR development process. Building a large project like LLVM can take some time on potato computers or in CI/CD setups. So I prefer stable binary releases for such dependencies as they enable faster "clean build" iterations. The dependencies are supposed to be frozen anyway! :)

I also faced problems with some MLIR support tools (LSP servers in particular) when building from source (I filed that issue here).

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef LIB_DIALECT_POLY_POLYPATTERNS_TD_
#define LIB_DIALECT_POLY_POLYPATTERNS_TD_

include "PolyOps.td"
include "mlir/Dialect/Complex/IR/ComplexOps.td"
include "mlir/IR/PatternBase.td"

def LiftConjThroughEval : Pat<
(Poly_EvalOp $f, (ConjOp $z)),
(ConjOp (Poly_EvalOp $f, $z))
>;

#endif // LIB_DIALECT_POLY_POLYPATTERNS_TD_