This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse][gpu] Impl 2:4 SpMM rewrite for linalg op w/ DENSE24 attr
ClosedPublic

Authored by K-Wu on Jul 8 2023, 12:30 PM.

Diff Detail

Event Timeline

K-Wu created this revision.Jul 8 2023, 12:30 PM
Herald added a project: Restricted Project. · View Herald Transcript
K-Wu requested review of this revision.Jul 8 2023, 12:30 PM
K-Wu updated this revision to Diff 538385.Jul 8 2023, 12:31 PM

add test case

K-Wu added inline comments.Jul 8 2023, 12:34 PM
mlir/test/Dialect/SparseTensor/GPU/gpu_matmul_lib_2to4.mlir
62

I am not familiar with the attribute. Shall we use a flag like attr_name =1/0, or a flag where attr_name means set and its non-presence means not set? Is the latter possible in MLIR?

aartbik added inline comments.Jul 10 2023, 9:51 AM
mlir/test/Dialect/SparseTensor/GPU/gpu_matmul_lib_2to4.mlir
62

You can simply assign a string attribute to any MLIR op. So that would be a possible way until we have 2:4 properly defined into our sparse tensor type

K-Wu updated this revision to Diff 538728.Jul 10 2023, 10:32 AM

updating attr in the test case

K-Wu marked an inline comment as done.Jul 10 2023, 10:57 AM
K-Wu added inline comments.
mlir/test/Dialect/SparseTensor/GPU/gpu_matmul_lib_2to4.mlir
62

SG!

aartbik added inline comments.Jul 10 2023, 2:18 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
252

can you move this to the "Library helper methods" where we have all the is/are tests on type
this section is really more for the genXXX methods

also, this should probably use the isAllDense() or hasEncoding() utils from SparseTensorType

678

remove comment altogether

1021

use LLVM preferred style

if (op->getAttr("DENSE24"))

rewrite2To4SpMM(rewriter, op);

rewriteSpMM(rewriter, op, enableRT);

K-Wu marked 3 inline comments as done.Jul 10 2023, 2:41 PM
K-Wu added inline comments.
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
252

Addressed. Please check if it works.

K-Wu updated this revision to Diff 538827.Jul 10 2023, 2:41 PM

addressing comments

aartbik added inline comments.Jul 10 2023, 3:18 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
40

Oh, I meant to the section near L378, where the other type testers are

and, can't this be simply

return (getSparseTensorType(type).isAllDense())

or

return (getSparseTensorType(type).hasEncoding()

K-Wu updated this revision to Diff 538854.Jul 10 2023, 3:29 PM
K-Wu marked an inline comment as done.

addressing comments

K-Wu marked an inline comment as done.Jul 10 2023, 3:35 PM
aartbik accepted this revision.Jul 10 2023, 3:36 PM
This revision is now accepted and ready to land.Jul 10 2023, 3:36 PM
This revision was landed with ongoing or failed builds.Jul 10 2023, 3:43 PM
This revision was automatically updated to reflect the committed changes.