This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] refactoring isAdmissibleTensorExp into codegen
ClosedPublic

Authored by Peiming on Jan 18 2023, 10:25 AM.

Details

Summary

This patch moves some utils into CodegenEnv class, it should make the code easier to follow and it eliminates several indirect value assignment that use ptr**.

Diff Detail

Event Timeline

Peiming created this revision.Jan 18 2023, 10:25 AM
Herald added a project: Restricted Project. · View Herald Transcript
Peiming requested review of this revision.Jan 18 2023, 10:25 AM
Peiming edited the summary of this revision. (Show Details)
Peiming edited the summary of this revision. (Show Details)
Peiming updated this revision to Diff 490223.Jan 18 2023, 10:30 AM

fix style.

aartbik added inline comments.Jan 25 2023, 9:17 AM
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp
91

These section names correspond 1:1 with the comments in the header file.
You now introduce the "verify functions" section, but there is none in the header

So I would org them consistently

mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h
45

empty line after the general methods section

54

I would group initTensorExp/getTensorExp together

mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
1444

is this a functional change?
(as part of the refactoring?)

Peiming added inline comments.Jan 25 2023, 9:21 AM
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
1444

Maybe? but not really? it was in isAdmissibleTensorExp that was called in the loop that iterates over sort masks, but this value is loop invariant, so i think it might be better to move it out to reject the kernel earlier. (See L568 in the original code)

Peiming updated this revision to Diff 492157.Jan 25 2023, 9:39 AM

address comments.

Peiming marked 3 inline comments as done.Jan 25 2023, 9:40 AM
aartbik added inline comments.Jan 26 2023, 11:59 AM
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp
91

The order does not match the header. In the header we have this order

topo / verify / output

but in the CC you have

verify / topo / output

Probably easiest to just fix this in header?

131

here and below, no longer needed to call op()

136

here and below, no longer need to call merger()

mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h
110

/// style more consistent with rest

112

empty line before second comment/method

112

You need to switch the order here in the header

admissibleTensorExp appears before admissibleTopoOrder in CC file

(also, that is the logical order of calling, so I like to see that reflected here)

112

also, add

// Sets outerParNest on success with sparse output

113

Setting sparseOutput is also rather essential in making sure we can split it into two admissible methods, i.e. first admissable tensor exp then admissible topoorder. I had to think about that for a bit!

mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
1444

Fair enough but, AFAIK, the "NFC" tag is really reserved for textual refactoring only, not for something that actually changes behavior (even if the overall behavior stays the same) ;-)

1458–1460

Keep a comment here on what it does

Peiming retitled this revision from [mlir][sparse] refactoring isAdmissibleTensorExp into codegen (NFC) to [mlir][sparse] refactoring isAdmissibleTensorExp into codegen.Jan 26 2023, 12:02 PM
Peiming updated this revision to Diff 492859.Jan 27 2023, 11:28 AM
Peiming marked 9 inline comments as done.

address comments.

aartbik accepted this revision.Jan 27 2023, 11:33 AM
aartbik added inline comments.
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
1458–1460

Typo: Constructs

1459

add: returns failure if the tree cannot be build, or the tensor expression is inadmissible

This revision is now accepted and ready to land.Jan 27 2023, 11:33 AM
Peiming updated this revision to Diff 492861.Jan 27 2023, 11:35 AM
Peiming marked 3 inline comments as done.

fix typo.

This revision was landed with ongoing or failed builds.Jan 27 2023, 11:37 AM
This revision was automatically updated to reflect the committed changes.