This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Sparse] Move `buildLattices` into Merger
ClosedPublic

Authored by gussmith23 on Jun 24 2021, 3:34 PM.

Details

Summary

This allows us to use buildLattices in the Merger unittests.

Diff Detail

Event Timeline

gussmith23 created this revision.Jun 24 2021, 3:34 PM
gussmith23 requested review of this revision.Jun 24 2021, 3:34 PM
gussmith23 retitled this revision from Move `buildLattices` into Merger to [MLIR][Sparse] Move `buildLattices` into Merger.Jun 24 2021, 3:35 PM
aartbik added inline comments.Jun 24 2021, 4:32 PM
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
152

Add: Returns index of the root expression.

since it is now public API

153

Since we are pulling this out, perhaps we should use the Linalg in the name, something like "buildLatticesFromLinalgOp". That way, we can later add other "builders"

mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
140–141

we don't generally repeat the comment from header in cc file

(style in a nutshell: header comments explain API, CC comments explain implementation)

aartbik added inline comments.Jun 25 2021, 12:49 PM
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
153

I was actually confusing my feedback with buildTensorExp(), which perhaps should be moved into the merger as well.

For this case, it only uses the linalg op for getNumInputsAndOutputs(), which the merger already knows about. So I think you can simplify the API and not rely on linalg at this point

gussmith23 marked 4 inline comments as done.

Address Aart's comments

mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
153

Removed the dependence on the GenericOp!

mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
140–141

Whoops, I forgot to delete this! Thanks for catching.

aartbik added inline comments.Jun 25 2021, 3:17 PM
mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
147

I was thinking, since we have this in its own self-contained file and class now,
shall we add a new constant

const unsigned syntheticTensor;

and initialize that to t in the constructor? This will read a bit nice than all the numTensors - 1 an outPut tensor + 1 we have at other places ;-)

Address Aart's comment -- add syntheticTensor

gussmith23 marked an inline comment as done.Jun 25 2021, 3:37 PM
gussmith23 added inline comments.
mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
147

Added! I looked for other places to use syntheticTensor but this seems to be the only place we need to use it.

gussmith23 marked an inline comment as done.

Rebase

aartbik accepted this revision.Jun 25 2021, 4:27 PM

Looking good! Ship it!

This revision is now accepted and ready to land.Jun 25 2021, 4:27 PM
This revision was automatically updated to reflect the committed changes.