This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Use DLT in the mangled function names for insertion.
ClosedPublic

Authored by bixia on Dec 21 2022, 8:21 AM.

Diff Detail

Event Timeline

bixia created this revision.Dec 21 2022, 8:21 AM
Herald added a project: Restricted Project. · View Herald Transcript
bixia requested review of this revision.Dec 21 2022, 8:21 AM
aartbik added inline comments.Dec 21 2022, 11:03 AM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
501

how about ordered/unordered? the code may not differ right now, but perhaps in the future? seems good to get a unique method per unique situation?

wrengr added inline comments.Dec 21 2022, 12:14 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
499–501

Now would be a good time to factor this part out into a standalone function of type DLT -> StringRef for returning the mangling itself (e.g., so we can use the same mangling elsewhere, as needed). To minimize string copying, you should write it like how toMLIRString is done (with a switch and returning the whole string at once, rather than gluing it together from parts).

501

+1, if only for the sake of getting it out of the way at the same time.

bixia updated this revision to Diff 485402.Dec 27 2022, 11:00 AM
bixia marked 3 inline comments as done.

Modify toMLIRString to add toString and use it here.

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
499–501

Add toString and use it here.

aartbik added inline comments.Dec 27 2022, 11:56 AM
mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
197

This now has runtime overhead. Since we only use it for debugging at one place, let's fix the only other place

./IR/SparseTensorDialect.cpp:

change
printer << toMLIRString(getDimLevelType()[i]);
into
printer << "\"" << toMLIRString(getDimLevelType()[i]) << "\""

and remove this one (and call your onetoMLIRString again

bixia updated this revision to Diff 485411.Dec 27 2022, 12:30 PM
bixia marked an inline comment as done.

Remove toString and modified toMLIRString.

aartbik accepted this revision.Dec 27 2022, 12:58 PM
aartbik added inline comments.
mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
194

be careful with removing this! even though all cases are covered, some tools want an "llvm_unreachable" here, and Wren was going to write one that does not need to pull in dependences into this pure include

but when you remove it, perhaps some builds will break....

This revision is now accepted and ready to land.Dec 27 2022, 12:58 PM
bixia updated this revision to Diff 485416.Dec 27 2022, 1:43 PM

Add the return statement back.

bixia retitled this revision from [mlir][sparse] Add uniqueness to the mangled function names for insertion. to [mlir][sparse] Use DLT in the mangled function names for insertion..Dec 27 2022, 3:26 PM
bixia updated this revision to Diff 485436.Dec 27 2022, 4:24 PM

Rebase.