This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add a pass to print content of memrefs and the related ops IR.
AbandonedPublic

Authored by pifon2a on Apr 1 2022, 2:02 AM.

Details

Diff Detail

Event Timeline

pifon2a created this revision.Apr 1 2022, 2:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 2:03 AM
pifon2a requested review of this revision.Apr 1 2022, 2:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 2:03 AM
rriddle requested changes to this revision.Apr 1 2022, 2:09 AM
rriddle added inline comments.
mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
113

This should be camelCase.

121

Drop the llvm here.

mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
177

Please keep these passes sorted.

177

This feels like it needs a lot more documentation. It isn't clear from reading this definition what the "printing" is supposed to entail.

mlir/lib/Dialect/MemRef/Transforms/EmbedMemRefPrints.cpp
32

The drop directly to LLVM feels off for this level of abstraction, why is this necessary?

212

This doesn't look great, I don't see why MemRef should be depending on SCF and Linalg here.

This revision now requires changes to proceed.Apr 1 2022, 2:09 AM
pifon2a marked 6 inline comments as done.Apr 1 2022, 2:36 AM
pifon2a added inline comments.
mlir/lib/Dialect/MemRef/Transforms/EmbedMemRefPrints.cpp
32

This is because I am adding global string constants and printing them. Is there any other way to print a string in MLIR right now?

212

Can't we depend on other dialects in transformations at least?

Just wondering, I removed Linalg and SCF dependency.

pifon2a updated this revision to Diff 419685.Apr 1 2022, 2:36 AM
pifon2a marked 2 inline comments as done.

Address the comments.

mehdi_amini added inline comments.Apr 1 2022, 11:08 AM
mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
122

I'm concerned about C++ injection in passes: it breaks reproducibility.

pifon2a added inline comments.Apr 4 2022, 9:10 AM
mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
122

Fair enough.

It can be fixed by:

  • introducing an interface for the ops. I think it is an overkill for this debuggging pass.
  • creating a utility function,
mlir::memref::embedMemRefPrints(ExtractValuesFunc extract_values_func)

and creating a test pass that exercises it with the default extract_values_func. After that every user, who wants to print memref content will have to create a pass and call embedMemRefPrints inside runOnOperation with the filter they want. WDYT?

mehdi_amini added inline comments.Apr 4 2022, 10:42 AM
mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
122

utility function + test pass it the common pattern AFAIK

pifon2a updated this revision to Diff 420459.Apr 5 2022, 5:07 AM

Address the concerns. :)

pifon2a abandoned this revision.Mar 20 2023, 12:38 PM